-
Notifications
You must be signed in to change notification settings - Fork 0
/
cron-boot
95 lines (79 loc) · 2.09 KB
/
cron-boot
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
logbox_home=/home/logbox
# Default hostname will be used to indicate setup of pi.
mac=$(sed s/://gi /sys/class/net/eth0/address)
mac=${mac:(-6)}
hostname="LogBox-$mac"
default_hostname="LogBox-new"
current_hostname=$(cat /etc/hostname)
if [ "$hostname" != "$current_hostname" ]
then
echo "$hostname" | sudo tee /etc/hostname
echo -e "127.0.0.1\t$hostname" | sudo tee --append /etc/hosts
rm -f ~/www/logbox/cfg.dat
sudo reboot
fi
until /home/logbox/os/report-ip.bash
do
echo "Waiting for internet..."
sleep 1
done
# TODO: Set up WiFi if config file exists.
# Update any libraries or system code:
arduinoLibrariesDir=/usr/share/arduino/libraries
library_EnableInterrupt=${arduinoLibrariesDir}/EnableInterrupt
if [ ! -d $library_EnableInterrupt ]
then
cd $arduinoLibrariesDir
sudo git clone https://github.com/GreyGnome/EnableInterrupt.git EnableInterrupt
cd -
sudo reboot
fi
# Individual logbox settings:
if [ "$mac" == "9cb911" ] # 1908 test
then
if [ ! -f /home/logbox/masson-fix-1 ]
then
cd /home/logbox/hat
git fetch && git checkout 1908-masson
cd /home/logbox/os
git fetch && git checkout 1908-masson
touch /home/logbox/masson-fix-1
sudo reboot
fi
fi
# security patch
sudo apt-get update && sudo apt-get install -y apt apt-transport-https ca-certificates curl libcurl3 libssl1.0.2 libssl1.1 openssl
# Update all components:
rebootNeeded=false
declare -a component_list=("avr" "hat" "hat-update" "os")
for component in "${component_list[@]}"
do
cd "$logbox_home/$component"
git reset --hard
gitMessage=`git pull | tail -n 1`
if [ "$gitMessage" != "Already up-to-date." ]
then
rebootNeeded=true
fi
done
cd $logbox_home
if [ "$rebootNeeded" = true ]
then
sudo reboot
fi
sudo /usr/bin/logbox-hat-update
sudo crontab -u logbox "$logbox_home/os/cron.conf"
sudo touch /var/www/logbox/cfg.dat
sudo chown logbox:logbox /var/www/logbox/cfg.dat
sudo chmod a+w /var/www/logbox/cfg.dat
if [ "$mac" == "9cb911" ] # 1908 test
then
if [ ! -f /home/logbox/masson-fix-2 ]
then
touch /home/logbox/masson-fix-2
sudo reboot
fi
fi
python os/data-log.py &
echo $! > /home/logbox/data-log.pid