a geicko-2 based round robin ranking system designed to test c++ battleship submissions battleship.dunkirk.sh
at main 3.3 kB view raw
1#!/bin/bash 2 3# Batch upload script - uploads all test submissions using admin passcode 4# This bypasses normal SSH key authentication for testing/setup 5 6HOST="localhost" 7PORT="2222" 8SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 9PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" 10 11# Load from .env file if exists 12if [ -f "$PROJECT_ROOT/.env" ]; then 13 export $(cat "$PROJECT_ROOT/.env" | grep -v '^#' | xargs) 14fi 15 16# Admin passcode (set via environment variable or use default) 17ADMIN_PASSCODE="${BATTLESHIP_ADMIN_PASSCODE:-battleship-admin-override}" 18 19echo "🚢 Battleship Arena - Batch Upload Script (Admin Mode)" 20echo "=======================================================" 21echo "" 22echo "This script uses admin passcode authentication to:" 23echo " 1. Auto-create users if they don't exist" 24echo " 2. Upload AI files for each user" 25echo " 3. Queue submissions for testing" 26echo "" 27echo "⚠️ Admin passcode: ${ADMIN_PASSCODE:0:10}..." 28echo "" 29echo "Press Enter to continue or Ctrl+C to cancel..." 30read 31 32# Define all submissions: username, filename 33declare -a SUBMISSIONS=( 34 "alice:memory_functions_random.cpp" 35 "bob:memory_functions_hunter.cpp" 36 "charlie:memory_functions_klukas.cpp" 37 "dave:memory_functions_diagonal.cpp" 38 "eve:memory_functions_edge.cpp" 39 "frank:memory_functions_spiral.cpp" 40 "grace:memory_functions_parity.cpp" 41 "henry:memory_functions_probability.cpp" 42 "iris:memory_functions_cluster.cpp" 43 "jack:memory_functions_snake.cpp" 44) 45 46# Upload each submission using admin passcode 47success_count=0 48fail_count=0 49 50for submission in "${SUBMISSIONS[@]}"; do 51 IFS=':' read -r username filename <<< "$submission" 52 53 echo "📤 Uploading for user: $username" 54 echo " File: test-submissions/$filename" 55 56 if [ ! -f "$SCRIPT_DIR/test-submissions/$filename" ]; then 57 echo "❌ Error: File not found" 58 ((fail_count++)) 59 echo "" 60 continue 61 fi 62 63 # Use sshpass to provide password authentication automatically 64 if command -v sshpass &> /dev/null; then 65 sshpass -p "$ADMIN_PASSCODE" scp -o StrictHostKeyChecking=no -P $PORT "$SCRIPT_DIR/test-submissions/$filename" "$username@$HOST:~/$filename" 2>&1 | grep -q "100%" 66 result=$? 67 else 68 echo "❌ Error: sshpass not installed. Install with: brew install hudochenkov/sshpass/sshpass" 69 echo " Or set ADMIN_PASSCODE env var and enter manually when prompted" 70 scp -P $PORT "$SCRIPT_DIR/test-submissions/$filename" "$username@$HOST:~/$filename" 2>&1 | grep -q "100%" 71 result=$? 72 fi 73 74 if [ $result -eq 0 ]; then 75 echo "✅ Upload successful for $username" 76 ((success_count++)) 77 else 78 echo "❌ Upload failed for $username" 79 ((fail_count++)) 80 fi 81 echo "" 82 83 # Small delay to avoid overwhelming the server 84 sleep 0.5 85done 86 87echo "=======================================================" 88echo "✨ Batch upload complete!" 89echo "" 90echo "Results:" 91echo " ✅ Successful: $success_count" 92echo " ❌ Failed: $fail_count" 93echo "" 94echo "Next steps:" 95echo " - View web leaderboard: http://$HOST:8081" 96echo " - View all users: http://$HOST:8081/users" 97echo " - Check compilation logs in server output" 98echo "" 99echo "Note: Compilation and testing will happen automatically in the background."