-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathstart.sh
76 lines (67 loc) · 2.51 KB
/
start.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
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
echo Y > /sys/module/usbcore/parameters/old_scheme_first
echo -1 >/sys/module/usbcore/parameters/autosuspend
ACTION=""
MD51=`md5sum /root/startup.sh`
MD52=`md5sum /root/sd_card_update.js`
if [ "$MD51" = "72cc8b90d9ecaff265e29a3b5c836b40 /root/startup.sh" ] || [ "$MD52" = "44fb0e4e8ea2dd85a7119b88dc2597ae /root/sd_card_update.js" ]
then
test -e /home/view/current/media/view-splash-updating.png && cp /home/view/current/media/view-splash-updating.png /root/view-splash-updating.png
test -e /home/view/current/sd_card_update.js && cp /home/view/current/sd_card_update.js /root/sd_card_update.js
echo "md5 matches, copied files"
fi
test -e /home/view/current/start.sh && cp /home/view/current/start.sh /root/startup.sh
if (/opt/sunxi-tools/pio -m PB10 | grep -q "PB10<0><1><0><0>") && test -e /sys/class/block/mmcblk1p1; then
echo "button pressed"
mount /dev/mmcblk1p1 /media
if ls /media/VIEW-*.zip 1> /dev/null 2>&1; then
echo "firmware available"
ACTION="install"
else
umount /media
fi
fi
if [ "$ACTION" = "install" ]; then
killall fbi
fbi -T 1 -d /dev/fb0 -noverbose /root/view-splash-updating.png &
killall node
sleep 1
killall -s 9 node
cd /root;
node sd_card_update.js
echo "installation complete!"
umount /media
fi
echo "current script=$0"
if [ "$0" != "/home/view/current/start.sh" ] && [ -e /home/view/current/start.sh ]
then
echo "starting installed version...";
sh /home/view/current/start.sh;
exit;
else
if [ "$0" != "/home/view/current/start.sh" ]
then
echo "running recovery version...";
else
echo "running installed version...";
fi
fi
echo "STARTING processes...";
killall fbi
fbi -T 1 -d /dev/fb0 -noverbose /root/view-splash.png &
killall node
sleep 1
killall -s 9 node
cd /home/view/current;
DATE=`date +"%Y%m%d-%H%M%S"`
UILOGFILE="/var/log/view-ui-$DATE.txt"
CORELOGFILE="/var/log/view-core-$DATE.txt"
cat ./logs/current.txt > ./logs/previous.txt
echo $CORELOGFILE > ./logs/current.txt
prepend_date() { while read line; do echo "$(date +%Y%m%d-%H%M%S) $line"; done }
echo "starting UI...";
forever -c "node --max_old_space_size=128" main.js 2>&1 | prepend_date >> $UILOGFILE &
sleep 35
test -e /lib/arm-linux-gnueabihf/libusb-0.1.so.4 && mv /lib/arm-linux-gnueabihf/libusb-0.1.so.4 /lib/arm-linux-gnueabihf/libusb--disabled--0.1.so.4 # disable libusb0.1 for Olympus support
echo "starting CORE...";
forever -c "node --max_old_space_size=320 --expose-gc" intervalometer/intervalometer-server.js 2>&1 | prepend_date >> $CORELOGFILE &