-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_train_spotter.sh
executable file
·50 lines (43 loc) · 1.42 KB
/
start_train_spotter.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
#!/bin/bash
# Exit if any command below fails.
set -e
# Clear the startup.log file
startup_log=/home/pi/train_spotter/startup.log
> $startup_log
intersection=$(cat /home/pi/intersection | sed 's/ *$//')
api_secret=$(cat /home/pi/api_secret | sed 's/ *$//')
# Read configuration variables based on intersection file
if [ "chestnut" == "$intersection" ]; then
source /home/pi/train_spotter/runtime_configs/chestnut_config.sh >> $startup_log 2>&1
elif [ "fourth" == "$intersection" ]; then
source /home/pi/train_spotter/runtime_configs/fourth_config.sh >> $startup_log 2>&1
else
echo "Unrecognized intersection: $intersection." >> $startup_log
exit 1
fi
# Mount the USB drive
if ! grep -qs "$usb_directory " /proc/mounts; then
if [ -e "$usb_device" ]; then
mount $usb_device $usb_directory >> $startup_log 2>&1
fi
fi
# Check if the spotter script is running
if pgrep -f "train_spotter.py" > /dev/null 2>&1; then
echo "Train spotter is already running." >> $startup_log
else
su -c "source $venv_file && \
nohup python $spotter_file \
-i $intersection \
-t $train_model_weights \
-s $signal_model_weights \
-e $events_directory \
-c $camera_ip \
-r $threshold \
-l $sleep_length \
-g $logging_directory \
--api-secret $api_secret \
--contrast-alpha $contrast_alpha \
--contrast-threshold $contrast_threshold \
> $stdout_stderr_file 2>&1 &" - pi
fi
exit 0