-
Notifications
You must be signed in to change notification settings - Fork 230
/
start_chroot_script
executable file
·170 lines (146 loc) · 5.67 KB
/
start_chroot_script
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/usr/bin/env bash
# FullPageOS generation script
# Helper script that runs in a Raspbian/others chroot to create the FullPageOS distro
# Written by Guy Sheffer <guysoft at gmail dot com>
# GPL V3
########
set -x
set -e
source /common.sh
unpack /filesystem/opt /opt
unpack /filesystem/boot /"${BASE_BOOT_MOUNT_PATH}"
unpack /filesystem/root_init /
apt-get update
# Display a custom Splashscreen when booting the Rpi
if [ "$FULLPAGEOS_CUSTOM_SPLASHSCREEN" == "yes" ]
then
apt-get install -y fbi
sed -i 's/$/ logo.nologo consoleblank=0 loglevel=0 quiet/' /"${BASE_BOOT_MOUNT_PATH}"/cmdline.txt
echo "disable_splash=1" >> /"${BASE_BOOT_MOUNT_PATH}"/config.txt
systemctl enable splashscreen.service
systemctl disable getty@tty1
fi
remove_extra=$(remove_if_installed scratch squeak-plugins-scratch squeak-vm python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk bluej greenfoot libreoffice-common libreoffice-core freepats)
apt-get remove -y --purge $remove_extra
apt-get autoremove -y
#apt-get tools
apt-get -y --force-yes install git screen checkinstall avahi-daemon libavahi-compat-libdnssd1 xterm xdotool vim expect feh
if [ "$FULLPAGEOS_INCLUDE_CHROMIUM" == "yes" ]
then
apt-get install -y --force-yes chromium-browser
sed -i 's@%BROWSER_START_SCRIPT%@/opt/custompios/scripts/start_chromium_browser@g' /opt/custompios/scripts/run_onepageos
fi
#Install web stack
if [ "$FULLPAGEOS_INCLUDE_LIGHTTPD" == "yes" ]
then
apt-get install -y lighttpd php-common php-cgi php
lighty-enable-mod fastcgi-php
#service lighttpd force-reload
chown -R www-data:www-data /var/www/html
chmod 775 /var/www/html
usermod -a -G www-data pi
systemctl enable clear_lighttpd_cache.service
pushd /var/www/html
#Put git clones in place
if [ "$FULLPAGEOS_INCLUDE_DASHBOARD" == "yes" ]
then
gitclone FULLPAGEOS_DASHBOARD_REPO FullPageDashboard
chown -R pi:pi FullPageDashboard
chown -R www-data:www-data FullPageDashboard
chmod 775 FullPageDashboard
pushd FullPageDashboard
sed -i "s@'INIT_URL_PATH', __DIR__ . '/init.txt'@'INIT_URL_PATH', '/"${BASE_BOOT_MOUNT_PATH}"/fullpagedashboard.txt'@g" config.php
popd
fi
#Set Welcome screen
if [ "$FULLPAGEOS_INCLUDE_WELCOME" == "yes" ]
then
gitclone FULLPAGEOS_WELCOME_REPO welcome
chown -R www-data:www-data welcome
fi
popd
echo "enabled" > /"${BASE_BOOT_MOUNT_PATH}"/check_for_httpd
else
echo "disabled" > /"${BASE_BOOT_MOUNT_PATH}"/check_for_httpd
fi
#override timezone
if [ "$FULLPAGEOS_OVERRIDE_TIMEZONE" != "default" ]
then
ln -fs /usr/share/zoneinfo/"$FULLPAGEOS_OVERRIDE_TIMEZONE" /etc/localtime
dpkg-reconfigure -f noninteractive tzdata
fi
#override locale
if [ "$FULLPAGEOS_OVERRIDE_LOCALE" != "default" ]
then
sed -i '/^#.* '"$FULLPAGEOS_OVERRIDE_LOCALE"' /s/^# //' /etc/locale.gen
locale-gen
update-locale LANG="$FULLPAGEOS_OVERRIDE_LOCALE"
fi
#override keyboard model and layout
if [ "$FULLPAGEOS_OVERRIDE_KBD_MODEL" != "default" ]
then
sed -i 's/^XKBMODEL=.*/XKBMODEL="'$FULLPAGEOS_OVERRIDE_KBD_MODEL'"/' /etc/default/keyboard
fi
if [ "$FULLPAGEOS_OVERRIDE_KBD_LAYOUT" != "default" ]
then
sed -i 's/^XKBLAYOUT=.*/XKBLAYOUT="'$FULLPAGEOS_OVERRIDE_KBD_LAYOUT'"/' /etc/default/keyboard
fi
if [ "$FULLPAGEOS_OVERRIDE_KBD_MODEL" != "default" ] || [ "$FULLPAGEOS_OVERRIDE_KBD_LAYOUT" != "default" ]
then
setupcon -k --save-only
fi
# Add emoji support
sudo -u pi mkdir -p /home/pi/.fonts
sudo -u pi wget --directory-prefix /home/pi/.fonts https://github.com/googlefonts/noto-emoji/raw/main/fonts/NotoColorEmoji.ttf
#override password
if [ "$FULLPAGEOS_OVERRIDE_PASSWORD" != "default" ]
then
#root password
echo "pi:$FULLPAGEOS_OVERRIDE_PASSWORD" | chpasswd
fi
#Setup x11vnc
if [ "$FULLPAGEOS_INCLUDE_X11VNC" == "yes" ]
then
apt-get install -y --force-yes x11vnc
# Set x11vnc password
if [ "$FULLPAGEOS_OVERRIDE_PASSWORD" != "default" ]
then
sudo -u pi /opt/custompios/scripts/setX11vncPass "$FULLPAGEOS_OVERRIDE_PASSWORD"
sync
if [ ! -f /home/pi/.vnc/passwd ] || [ ! -s /home/pi/.vnc/passwd ]; then
echo "/home/pi/.vnc/passwd was not created. Trying again."
sudo -u pi /opt/custompios/scripts/setX11vncPass "$FULLPAGEOS_OVERRIDE_PASSWORD"
sync
if [ ! -f /home/pi/.vnc/passwd ] || [ ! -s /home/pi/.vnc/passwd ]; then
echo "/home/pi/.vnc/passwd was not created again. Giving up."
echo "Failed to set a VNC password. Aborting build."
exit 1
fi
fi
else
sudo -u pi /opt/custompios/scripts/setX11vncPass raspberry
sync
if [ ! -f /home/pi/.vnc/passwd ] || [ ! -s /home/pi/.vnc/passwd ]; then
echo "/home/pi/.vnc/passwd was not created. Trying again."
sudo -u pi /opt/custompios/scripts/setX11vncPass raspberry
sync
if [ ! -f /home/pi/.vnc/passwd ] || [ ! -s /home/pi/.vnc/passwd ]; then
echo "/home/pi/.vnc/passwd was not created again. Giving up."
echo "Failed to set a VNC password. Aborting build."
exit 1
fi
fi
fi
ls -l /home/pi/.vnc/passwd
#Enable x11vnc service
systemctl enable x11vnc.service
fi
#echo "sudo -u pi startx /opt/custompios/scripts/run_onepageos &" >> /etc/rc.local
#echo "(sleep 15 ; sudo -u pi /opt/custompios/scripts/fullscreen) &" >> /etc/rc.local
#####################################################################
### setup services
echo "server time.nist.gov" >> /etc/ntp.conf
echo "server ntp.ubuntu.com" >> /etc/ntp.conf
#cleanup
apt-get clean
apt-get autoremove -y