-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathautorun.sh
29 lines (27 loc) · 877 Bytes
/
autorun.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
#!/bin/bash
echo timer > /sys/class/leds/led0/trigger
cd /data
rm -f new.sha1
if wget http://pirate.sh/latest-pirateship.img.gz.sha1 -O new.sha1; then
if [[ ! -e latest-pirateship.img.gz ]] || [[ ! -e latest-pirateship.img.gz.sha1 ]] || [[ `cat new.sha1` != `cat latest-pirateship.img.gz.sha1` ]]; then
rm -f latest-pirateship.img.gz
wget http://pirate.sh/latest-pirateship.img.gz
rm -f latest-pirateship.img.gz.sha1
wget http://pirate.sh/latest-pirateship.img.gz.sha1
fi
fi
echo heartbeat > /sys/class/leds/led0/trigger
if [[ -b /dev/sdb ]] ; then
if [[ -e latest-pirateship.img.gz ]]; then
zcat latest-pirateship.img.gz > /dev/sdb
else
echo u > /proc/sysrq-trigger
dd if=/dev/mmcblk0 bs=1M of=/dev/sdb count=4K
fi
sync
sync
sync
echo none > /sys/class/leds/led0/trigger
else
echo default-on > /sys/class/leds/led0/trigger
fi