-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirstboot
executable file
·148 lines (144 loc) · 6.72 KB
/
firstboot
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/sh
### BEGIN INIT INFO
# Provides: firstboot
# Required-Start: $local_fs $syslog $remote_fs dbus
# Required-Stop: $local_fs $syslog $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start firstboot script
### END INIT INFO
# load definitions & settings ---->
if [[ $(echo $PREFIX | grep -o "com.termux") == "com.termux" ]];
then
. /data/data/com.termux/files/usr/lib/floflis/./config
else
. /usr/lib/floflis/./config
export FLOPREFIX
fi
export flofmach && export flofdistro && export flofarch && export osfullname && export osname && export osversion && export osbuild && export osbuildcodename && export updatepatch && export year && export layer && export nxtlayer && export distrobase && export user && export specialbuildattempt
# <---- load definitions & settings
if [ "$(df ~ | tail -1 | awk '{print $1;}')" = "/cow" ]; then
exit
fi
if cat /proc/1/cgroup | tail -1 | grep -q "container"; then
echo "linux container. Floflis' firstboot won't run."
else
full_fs=$(df ~ | tail -1 | awk '{print $1;}') # /dev/sda1
fs=$(basename $full_fs) # sda1
if grep -q "$fs" /proc/partitions; then
echo "regular linux install. Floflis' firstboot will proceed."
FLAG="/var/log/firstboot.log"
if [ ! -f $FLAG ] # if the flag hasn't been placed, this is the first boot
then
#Put here your initialization cmds
echo "This is the first boot."
if [[ $(echo $PREFIX | grep -o "com.termux") != "com.termux" ]];
then
sudo mv "$FLOPREFIX"usr/lib/floflis/layers/core/firstlogon.sh /home
sudo mv "$FLOPREFIX"usr/lib/floflis/layers/core/firstlogonroot.sh /home
sudo chmod +x "$FLOPREFIX"home/firstlogon.sh
sudo chmod +x "$FLOPREFIX"home/firstlogonroot.sh
cd /home
for D in `find . -mindepth 1 -maxdepth 1 -type d`
do
pure=$(echo "${D}" | tr -d "/" | tr -d ".")
cd ${D}
if [ ! -e .config ]; then mkdir .config; fi
if [ ! -e .config/autostart ]; then mkdir .config/autostart; fi
# cd .config/autostart
cat > "$FLOPREFIX"home/$pure/.config/autostart/firstlogon.sh << ENDOFFILE
[Desktop Entry]
Type=Application
Exec=gnome-terminal --tab --title="Welcome to Floflis! 👭" -- /bin/sh -c 'cd /home; sh ./firstlogon.sh; exec bash'
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=FirstLogon
Name=FirstLogon
Comment[en_US]=
Comment=
Icon=utilities-terminal
StartupNotify=true
Terminal=false
ENDOFFILE
sudo chmod -R a+rwX "$FLOPREFIX"home/$pure/.config/autostart && sudo chown $pure:$pure "$FLOPREFIX"home/$pure/.config/autostart
sudo chown $pure:$pure "$FLOPREFIX"home/$pure/.local/share/gvfs-metadata/home*
sudo chmod +x "$FLOPREFIX"home/$pure/.config/autostart/firstlogon.sh
sudo chown $pure:$pure "$FLOPREFIX"home/$pure/.config/autostart/firstlogon.sh
# cd .config/autostart
sudo mv "$FLOPREFIX"home/$pure/.config/autostart/firstlogon.sh "$FLOPREFIX"home/$pure/.config/autostart/firstlogon.desktop
sudo chown $pure:$pure "$FLOPREFIX"home/$pure/.config/autostart/firstlogon.desktop
# cd ..
# cd ..
else
: #no-op cmd, thanks to https://stackoverflow.com/a/17583599
fi
echo "- Cleanning install..."
if [ -e "$FLOPREFIX"home/$pure/.config/autostart/firstlogon.sh ]; then sudo rm -rf "$FLOPREFIX"home/$pure/.config/autostart/firstlogon.sh; fi
cd ..
sudo chmod -R a+rwX ${D} && sudo chown $pure:$pure ${D}
done
cd
# knows if upper layers are present, and install their firstboot
if [ -e "$FLOPREFIX"usr/lib/floflis/layers/soil ] || [ -e "$FLOPREFIX"usr/lib/floflis/layers/server ]
then
echo "- Upper layers are here. Detecting..."
# Server>
if [ -f "$FLOPREFIX"usr/lib/floflis/layers/server/firstboot ];then
echo "- Openning Floflis Server firstboot installer..."
sudo chmod +x "$FLOPREFIX"usr/lib/floflis/layers/server/firstboot && cd "$FLOPREFIX"usr/lib/floflis/layers/server && sh ./firstboot
fi
# <Server
# Soil>
if [ -f "$FLOPREFIX"usr/lib/floflis/layers/soil/firstboot ];then
echo "- Openning Floflis Soil firstboot installer..."
sudo chmod +x "$FLOPREFIX"usr/lib/floflis/layers/soil/firstboot && cd "$FLOPREFIX"usr/lib/floflis/layers/soil && sh ./firstboot
fi
# <Soil
# Grass>
if [ -f "$FLOPREFIX"usr/lib/floflis/layers/grass/firstboot ];then
echo "- Openning Floflis Grass firstboot installer..."
sudo chmod +x "$FLOPREFIX"usr/lib/floflis/layers/grass/firstboot && cd "$FLOPREFIX"usr/lib/floflis/layers/grass && sh ./firstboot
fi
# <Grass
# Base>
if [ -f "$FLOPREFIX"usr/lib/floflis/layers/base/firstboot ];then
echo "- Openning Floflis Base firstboot installer..."
sudo chmod +x "$FLOPREFIX"usr/lib/floflis/layers/base/firstboot && cd "$FLOPREFIX"usr/lib/floflis/layers/base && sh ./firstboot
fi
# <Base
# Home>
if [ -f "$FLOPREFIX"usr/lib/floflis/layers"$FLOPREFIX"home/firstboot ];then
echo "- Openning Floflis Home firstboot installer..."
sudo chmod +x "$FLOPREFIX"usr/lib/floflis/layers"$FLOPREFIX"home/firstboot && cd "$FLOPREFIX"usr/lib/floflis/layers/home && sh ./firstboot
fi
# <Home
# Ultimate>
if [ -f "$FLOPREFIX"usr/lib/floflis/layers/ultimate/firstboot ];then
echo "- Openning Floflis Ultimate firstboot installer..."
sudo chmod +x "$FLOPREFIX"usr/lib/floflis/layers/ultimate/firstboot && cd "$FLOPREFIX"usr/lib/floflis/layers/ultimate && sh ./firstboot
fi
# <Ultimate
# Planetary>
if [ -f "$FLOPREFIX"usr/lib/floflis/layers/planetary/firstboot ];then
echo "- Openning Floflis Planetary firstboot installer..."
sudo chmod +x "$FLOPREFIX"usr/lib/floflis/layers/planetary/firstboot && cd "$FLOPREFIX"usr/lib/floflis/layers/planetary && sh ./firstboot
fi
# <Planetary
# Quantum>
if [ -f "$FLOPREFIX"usr/lib/floflis/layers/quantum/firstboot ];then
echo "- Openning Floflis Quantum firstboot installer..."
sudo chmod +x "$FLOPREFIX"usr/lib/floflis/layers/quantum/firstboot && cd "$FLOPREFIX"usr/lib/floflis/layers/quantum && sh ./firstboot
fi
# <Quantum
fi
#the next line creates an empty file so it won't run the next boot
touch $FLAG
else
echo "No need to run Floflis' first boot script."
#task: remove this script from init.d
fi
else
echo "live OS running from RAM. Floflis' firstboot won't run."
fi
fi