-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrc.local
executable file
·88 lines (77 loc) · 2.41 KB
/
rc.local
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
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sleep 30
if ! command -v jq >/dev/null 2>&1
then
sudo apt-get update
sudo apt-get install -y jq
fi
value=$(jq -r '.action' /boot/efi/src/config.json)
client=$(jq -r '.client' /boot/efi/src/config.json)
if [ "$value" = "reset" ] || [ "$value" = "hardReset" ] || [ ! -d "/root/kasarOs" ]; then
if command -v docker >/dev/null 2>&1; then
sudo docker stop $(docker ps -aq) > /dev/null 2>&1 || true
sudo docker rm $(docker ps -aq) > /dev/null 2>&1 || true
fi
if [ "$value" = "reset" ] && [ -d "/root/kasarOs" ]; then
rm -rf /root/kasarOs
elif [ "$value" = "hardReset" ]; then
rm -rf /root/*
rm -rf /home/starknode/*
fi
cd /root/
git clone https://github.com/KasarLabs/kasarOs && cd kasarOs && git checkout roc-dev
if ! cmp -s "/root/kasarOs/rc.local" "/etc/rc.local"; then
cp "/root/kasarOs/rc.local" "/etc/rc.local"
/etc/rc.local &
exit 0
fi
fi
cd /root/kasarOs
echo "Version 0.1" > /root/version.log
cp /boot/efi/src/config.json /root/kasarOs/
if [ "$value" = "update" ] || [ "$value" = "autoUpdate" ]; then
if ! command -v git >/dev/null 2>&1
then
sudo apt-get update
sudo apt-get install -y git
fi
git config user.email "[email protected]" > /dev/null 2>&1 || true
git config user.name "starknode" > /dev/null 2>&1 || true
git pull > /dev/null 2>&1 || true
if command -v docker >/dev/null 2>&1; then
sudo docker stop $(docker ps -aq) > /dev/null 2>&1 || true
sudo docker rm $(docker ps -aq) > /dev/null 2>&1 || true
if [ "$client" = "pathfinder" ]; then
sudo docker pull eqlabs/pathfinder
elif [ "$client" = "juno" ]; then
echo ""
elif [ "$client" = "papyrus" ]; then
echo ""
fi
fi
if ! cmp -s "./rc.local" "/etc/rc.local"; then
cp "./rc.local" "/etc/rc.local"
sudo reboot
exit 0
fi
fi
./verify.sh > /root/Verifylogs 2>&1 &
./start.sh > /root/first_logs 2>&1 &
sleep 35
pgrep "verify" > /dev/null
if [ "$?" -ne 0 ]; then
sudo rm -rf /root/kasarOs
sudo reboot
fi
exit 0