-
Notifications
You must be signed in to change notification settings - Fork 4
/
install.sh
executable file
·49 lines (43 loc) · 1.31 KB
/
install.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
#!/usr/bin/env bash
bepath=src/client/broker
#setup database
sqlite3 src/client/database.db "CREATE TABLE IF NOT EXISTS 'sensor_data' (id INTEGER, time TIMESTAMP UNIQUE NOT NULL, data NUMERIC NOT NULL, PRIMARY KEY(id));"
# select database mode
PS3='Do you want to use an empty or pre-filled database? '
options=("1: empty database" "2: pre-generated data")
select opt in "${options[@]}"
do
case $opt in
"1: empty database")
echo "The install will use a new, empty database."
sqlite3 src/client/database.db "DELETE FROM sensor_data;VACUUM;"
break
;;
"2: pre-generated data")
echo "The install will use pre-generated data."
cd ${bepath}
./fillBulkData.py
cd ../../../
break
;;
*) echo "invalid option $REPLY";;
esac
done
# compile back-end data handler
mkdir ${bepath}/build
cmake -H${bepath} -B${bepath}/build
make -C ${bepath}/build
mv ${bepath}/build/datahandler ${bepath}
rm -rf ${bepath}/build
# create the cronjobs
dir=$(pwd)
#write out current crontab
crontab -l > newcron
crontab newcron
#echo new cron into cron file
(crontab -l && echo -e "*/2 * * * * python3 ${dir}/${bepath}/sensorDataHandler.py\n 0 * * * * ${dir}/${bepath}/datahandler") > newcron
#install new cron file
crontab newcron
rm newcron
# setup server
npm install