forked from projectbuendia/server-status
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathboot_script.sh
More file actions
50 lines (36 loc) · 1.35 KB
/
boot_script.sh
File metadata and controls
50 lines (36 loc) · 1.35 KB
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/sh
# reset in case battery_status script fails
echo 0 > /home/root/debian/home/buendia/battery_shutdown.txt
cd /home/root/gpio
# mount SD, test it is writable, and if not unmount
mount /dev/mmcblk1p1 /home/root/debian/home/buendia/sd/ || touch sd_mount_failed
touch sd/write_test && rm sd/write_test || umount -l /dev/mmcblk1p1
mkdir -p sd/logs
echo $(date) >> boot_script_log.txt
# update system time from RTC
python systime/set_edison_from_rtc > sd/logs/rtc_log.txt 2>&1 &
# splash screen
python splash_screen.py &
sleep 15
# SERVER STATUS
python server_status.py >> sd/logs/server_status_log.txt 2>&1 &
# BATTERY STATUS
echo 101 > battery_charge.txt # reset status file
#sleep 15 # sleep briefly to allow default UART pin boot sequence to finish (a bug workaround)
python battery_status.py >> sd/logs/battery_status_log.txt 2>&1 &
# SHUTDOWN BUTTON
python button_shutdown.py >> /dev/null 2>&1 &
# OTHER SCRIPTS
# monitor scripts
#sleep 20
#. scripts_check.sh >> sd/scripts_check_log.txt 2>&1 &
# prevent truncate errors from any missing files
touch sd/logs/server_status_log.txt
touch sd/logs/battery_status_log.txt
touch sd/logs/battery_charge_log.txt
# truncate log files
. truncate_logs.sh >> /dev/null 2>&1 &
# truncate battery log
truncate() { tail -$2 $1 > $1.tmp; cat $1.tmp > $1; rm $1.tmp; }
truncate sd/logs/battery_charge_log.txt 1000
exit 0