-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_test_env.sh
More file actions
executable file
·73 lines (59 loc) · 1.85 KB
/
start_test_env.sh
File metadata and controls
executable file
·73 lines (59 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# Function to handle cleanup on script exit
cleanup() {
echo "Caught SIGINT signal! Cleaning up..."
# Kill grSim, game controller, and AutoReferee processes if they exist
if [ ! -z "$GRSIM_PID" ]; then
echo "Stopping grSim..."
kill $GRSIM_PID 2>/dev/null
fi
if [ ! -z "$GAME_CONTROLLER_PID" ]; then
echo "Stopping game controller..."
kill $GAME_CONTROLLER_PID 2>/dev/null
fi
if [ ! -z "$AUTOREFEREE_PID" ]; then
echo "Stopping AutoReferee..."
kill $AUTOREFEREE_PID 2>/dev/null
fi
echo "Cleanup complete. Exiting."
exit
}
# Trap SIGINT (Ctrl+C) and call the cleanup function
trap cleanup SIGINT
# Output reminder to open the website manually
echo "Reminder: Please open the following website in your browser:"
echo "http://localhost:8081/#/match"
echo "Once the website is opened, the script will continue..."
# Start grSim in the background, suppressing output
echo "Starting grSim..."
grSim > /dev/null 2>&1 &
GRSIM_PID=$!
# Check if grSim started successfully
if [ $? -ne 0 ]; then
echo "Failed to start grSim. Exiting."
exit 1
fi
# Change to the ssl-game-controller directory and run the game controller, suppressing output
echo "Starting game controller..."
cd ssl-game-controller/
./ssl-game-controller > /dev/null 2>&1 &
GAME_CONTROLLER_PID=$!
cd ..
# Check if the game controller started successfully
if [ $? -ne 0 ]; then
echo "Failed to start game controller. Exiting."
cleanup
fi
# Change to the AutoReferee directory and run the run.sh script, suppressing output
echo "Starting AutoReferee..."
cd AutoReferee/
./gradlew run > /dev/null 2>&1 &
AUTOREFEREE_PID=$!
cd ..
# Check if AutoReferee started successfully
if [ $? -ne 0 ]; then
echo "Failed to start AutoReferee. Exiting."
cleanup
fi
# Wait for all background processes to finish
wait