-
Notifications
You must be signed in to change notification settings - Fork 0
/
starter.sh
executable file
·57 lines (43 loc) · 1.13 KB
/
starter.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
#!/bin/bash
# This shell script is called by cron when reboot.
# And this shell script start pizero-workshop.service (systemd).
set -eu
echo -n 'Started at '
date
if ! [ $(whoami) = root ]; then echo 'Root permission required.'; exit 1; fi
. env.sh
ScriptDir=$(cd $(dirname $BASH_SOURCE); pwd)
Origin="${BootDir}/config.js"
ConfigJs=$(mktemp)
CheckConfig="${Dir}/checkConfig.js"
if [ -f $Origin ]; then
echo "Using Following config file:$Origin ... "
cat $Origin
echo "Converting '$Origin' to UTF-8 LF ... "
nkf -w -d < $Origin > $ConfigJs
echo "ok"
echo -n 'syntax ... '
node -c $ConfigJs
echo 'ok'
echo 'value ... '
node $CheckConfig $ConfigJs
echo 'ok'
else
echo "$Origin is not found, may be using ${Dir}/setting/config.js ."
fi
set +e
echo -n 'ping ... '
while :; do
ping webdino.org -c 1 > /dev/null 2>&1
if [ $? = 0 ]; then break; fi
sleep 10
done
echo 'ok'
echo 'Restart systemd-timesyncd ... '
systemctl restart systemd-timesyncd
echo 'ok'
echo 'Start sensing and records ... '
systemctl start pizero-workshop
echo 'ok'
echo 'All start process finished.'
exit 0