-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup.sh
63 lines (52 loc) · 1.89 KB
/
setup.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
59
60
61
62
63
#!/usr/bin/env bash
#====================================================
# Prepare config file
#====================================================
monitor_files=('jobs/monitor_exec' 'jobs/monitor.log')
schedule_files=('jobs/booking.csv' 'jobs/using.csv' 'jobs/used.csv')
cfg_files=('capability_config.yaml' 'host_deploy.yaml' 'users_config.yaml')
monitor_program_file="$(pwd)/src/monitor/Monitor.py"
check_restart_file="$(pwd)/src/monitor/check_restart.py"
mkdir jobs
# check and create
for key in ${!monitor_files[*]}; do
if ! [ -f "${monitor_files[$key]}" ]; then
touch "${monitor_files[$key]}"
fi
done
# check and copy
for key in ${!schedule_files[*]}; do
if ! [ -f "${schedule_files[$key]}" ]; then
cp cfg/templates/schedule.csv "${schedule_files[$key]}"
fi
done
# check and copy
for key in ${!cfg_files[*]}; do
if ! [ -f "cfg/${cfg_files[$key]}" ]; then
cp "cfg/templates/${cfg_files[$key]}" cfg
fi
done
#====================================================
# Add command to the cron job
#====================================================
#write out current crontab
crontab -l > temp_crontab
#echo new cron into cron file
if [ "$(grep "${monitor_program_file}" temp_crontab)" == "" ]; then
echo "*/30 * * * * python3 ${monitor_program_file}" >> temp_crontab
fi
if [ "$(grep "${check_restart_file}" temp_crontab)" == "" ]; then
echo "@reboot python3 ${check_restart_file}" >> temp_crontab
fi
crontab temp_crontab
rm temp_crontab
#====================================================
# Install package and images
#====================================================
pip3 install -r requirements.txt
docker pull --all-tags rober5566a/aivc-server
#====================================================
# Deploy booking container
#====================================================
docker container stop booking && docker container rm booking
bash run_booking.sh