-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto_run.sh
executable file
·58 lines (49 loc) · 1.99 KB
/
auto_run.sh
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
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 <hours>"
exit 1
fi
hours=$1
end_time=$(($(date +%s) + hours * 3600))
apollo_container_name="apollo_dev_$USER"
carla_container_name="carla-$USER"
log_file="command_execution_log.txt"
echo "Command execution log - $(date)"
echo "Command execution log - $(date)" > $log_file
echo "Executing for $hours hours"
echo "Executing for $hours hours" >> $log_file
start_carla_script=~/apollo_carla_8/apollo-r8.0.0/modules/MS_fuzz/run_carla_offscreen.sh
run_cmd='cd /apollo/modules/MS_fuzz/ && python msfuzz.py --town 4'
while [ $(date +%s) -lt $end_time ]; do
if docker ps | grep -q $carla_container_name; then
start_time=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$start_time] Carla container is already running"
echo "[$start_time] Carla container is already running" >> $log_file
elif docker ps -a | grep -q $carla_container_name; then
start_time=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$start_time] Starting stopped Carla container"
echo "[$start_time] Starting stopped Carla container" >> $log_file
docker start $carla_container_name
sleep 10
else
start_time=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$start_time] Carla container not found, starting with script"
echo "[$start_time] Carla container not found, starting with script" >> $log_file
$start_carla_script
sleep 10
fi
if docker ps | grep -q $apollo_container_name; then
start_time=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$start_time] Starting test program"
echo "[$start_time] Starting test program" >> $log_file
docker exec -it -u $USER -e HISTFILE=/apollo/.dev_bash_hist $apollo_container_name /bin/bash -i -c "$run_cmd"
else
start_time=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$start_time] Apollo dev container not running, skipping test program"
echo "[$start_time] Apollo dev container not running, skipping test program" >> $log_file
exit 1
fi
sleep 3
done
echo "Execution completed at $(date)"
echo "Execution completed at $(date)" >> $log_file