forked from treehouses/builder
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplanet_RTC_autorunonce
75 lines (62 loc) · 2.13 KB
/
planet_RTC_autorunonce
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/bash
hostname='ole'
hotspotname='treehouse'
# real time clock: rasclock or ds3231
rtc='rasclock'
# rtc='ds3231'
# On the first boot the RED led mode will be heartbeat and the GREEN led will be off
treehouses led red heartbeat
treehouses led green none
treehouses rename $hostname
treehouses expandfs
treehouses bluetooth on
# this script was made to run using ethernet. If you have no access to it we recommend you switch to bridge
#treehouses wifi <wifiname> [password]
treehouses ap internet $hotspotname
#treehouses bridge <wifiname> $hotspotname [password] [hotspotpassword]
# real time clock
treehouses rtc on "$rtc"
# download Planet
mkdir -p /srv/planet
cd /srv/planet/ || exit 1
wget https://raw.githubusercontent.com/open-learning-exchange/planet/master/docker/planet.yml
wget https://raw.githubusercontent.com/open-learning-exchange/planet/master/docker/volumes.yml
wget https://raw.githubusercontent.com/open-learning-exchange/planet/master/docker/install.yml
sync; sync; sync
docker-compose -f planet.yml -f volumes.yml -f install.yml -p planet pull
docker tag treehouses/planet:db-init treehouses/planet:db-init-local
docker tag treehouses/planet:latest treehouses/planet:local
sync; sync; sync
# second autorunonce
mv /boot/autoranonce* /boot/autoranonce.first
sync
{
echo '#!/bin/sh'
echo
echo "sudo treehouses led green timer"
echo "sudo treehouses led red timer"
echo
echo "while ! curl -X GET https://google.com ; do"
echo " sleep 5"
echo "done"
echo
# On the second boot the GREEN led mode will be heartbeat and the RED led will be off
echo "sudo treehouses led green heartbeat"
echo "sudo treehouses led red none"
echo
echo "sudo treehouses ntp local"
echo
echo "sync;sync;sync; reboot"
} > /boot/autorunonce
{
echo "#!/bin/sh"
echo
echo "sleep 1"
echo
echo "if [ -f /srv/planet/pwd/credentials.yml ]; then"
echo " docker-compose -f /srv/planet/planet.yml -f /srv/planet/volumes.yml -f /srv/planet/pwd/credentials.yml -p planet up -d"
echo "else"
echo " docker-compose -f /srv/planet/planet.yml -f /srv/planet/volumes.yml -p planet up -d"
echo "fi"
} > /boot/autorun
sync; sync; sync; reboot