-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetupkiosk.sh
278 lines (247 loc) · 7.64 KB
/
setupkiosk.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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#!/bin/bash
check_deb-multimedia() {
if [ ! -f /etc/apt/trusted.gpg.d/deb-multimedia-keyring.gpg ]; then
apt-get install -y --force-yes deb-multimedia-keyring
apt-get update
fi
}
msgbox() { # $1 is the msg
whiptail --backtitle "$TITLE" --msgbox "$1" 0 0 0
}
change_hostname(){
msgbox "Change the hostname for your kiosk.
The RFC requires that the hostname contains only:
letters 'a' to 'z'
numbers '0' to '9'
and hyphen (-)
Note that a hostname cannot begin or end with a hyphen.
No other char/symbol/punctuation or white-spaces are allowed." 0 0 0
CH=`cat /etc/hostname | tr -d " \t\n\r"`
NH=$(whiptail --backtitle "$TITLE" --inputbox "Hostname" 0 40 "$CH" 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then
echo $NH > /etc/hostname
cat /etc/hosts | sed s/"$CH"/"$NH"/g > /tmp/hosts
mv /tmp/hosts /etc/hosts
fi
}
fix_c2_audio(){
if [ -f /etc/pulse/default.pa ] && [ "x$board" == "xodroidc2" ]; then
if [ `grep "set-default-sink alsa_output.platform-odroid_hdmi.37.analog-stereo" /etc/pulse/default.pa | wc -l` -lt 1 ]; then
echo "set-default-sink alsa_output.platform-odroid_hdmi.37.analog-stereo" >> /etc/pulse/default.pa
fi
fi
}
odroid_dac(){
if [ `cat /etc/modules | grep ^snd-soc-odroid-dac | wc -l` -lt 1 ]; then
echo "snd-soc-odroid-dac" >> /etc/modules
fi
if [ `cat /etc/modules | grep ^snd-soc-pcm5102 | wc -l` -lt 1 ]; then
echo "snd-soc-pcm5102" >> /etc/modules
fi
if [ `grep "^set-default-sink alsa_output.platform-odroid_sound_card.5.analog-stereo" /etc/pulse/default.pa | wc -l` -lt 1 ]; then
echo "set-default-sink alsa_output.platform-odroid_sound_card.5.analog-stereo
suspend-sink alsa_output.platform-odroid_sound_card.5.analog-stereo 1" >> /etc/pulse/default.pa
fi
#msgbox "ODROID DAC support enabled"
echo "pcm.!default {
type hw;
card 1;
}
ctl.!default {
type hw;
card 1;
}" > /etc/asound.conf
}
install_xorg() {
cat <<_EOT_>> /root/.xsession
#!/bin/bash
export DISPLAY=:0
xset +dpms
xset dpms 30 60 300
xset s off
xterm
_EOT_
apt-get install xserver-xorg xinit x11-xserver-utils xterm -y
}
install_gpu() {
if [ ! -z $fbdev ]; then
apt-get install -y mali450-fbdev-odroid
#msgbox "Installed mali450-fbdev-odroid driver"
else
apt-get install -y mali450-odroid
#msgbox "Installed mali450-odroid driver"
fi
}
install_ddx() {
if [ ! -z $fbdev ]; then
# nothing here yet
continue
else
apt-get install -y xf86-video-fbturbo-odroid libump-odroid
cp -f /usr/local/share/setup-odroid/xorg/c2/fbturbo/xorg.conf /etc/X11
#msgbox "Installed xf86-video-fbturbo-odroid driver"
fi
}
install_backlightpwm(){ # currently unsupported
sed -i "s/exit\ 0//g" /etc/rc.local
tee -a /etc/rc.local.new << _EOT_
echo 234 | tee export
echo out | tee /sys/class/gpio/gpio234/direction
echo 0 | tee /sys/class/gpio/gpio234/value
chown chrome:chrome /sys/class/gpio/gpio234/value
echo 214 | tee export
echo out | tee /sys/class/gpio/gpio214/direction
echo 0 | tee /sys/class/gpio/gpio214/value
chown chrome:chrome /sys/class/gpio/gpio214/value
exit 0
_EOT_
echo -e "$CHROMIUM &" >> /home/chrome/.xsession
tee -a /home/chrome/.xsession <<_EOT_
backlight_stat = "On"
while true
do
sleep 1
stat=$(xset -q|sed -ne 's/^[ ]*Monitor is //p')
if [ "$stat" == "Off" -a "$cur_stat" == "On" ]; then
echo "monitor goes to Off"
# backlight off first
echo 1 | tee /sys/class/gpio/gpio214/value
echo 1 | tee /sys/class/gpio/gpio234/value
cur_stat=$stat
elif [ "$stat" == "On" -a "$cur_stat" == "Off" ]; then
echo "monitor turns back On"
echo 0 | tee /sys/class/gpio/gpio234/value
echo 0 | tee /sys/class/gpio/gpio214/value
cur_stat=$stat
fi
done
_EOT_
}
config_xsession(){
cat <<_EOT_>> /home/chrome/.xsession
#!/bin/bash
export DISPLAY=:0
xset +dpms
xset dpms 30 60 120
xset s off
rm -f /home/chrome/.cache/chromium/Default/Cache/*
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' /home/chrome/.config/chromium/'Local State'
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences
_EOT_
echo $CHROMIUM >> /home/chrome/.xsession
chown chrome:chrome /home/chrome/.xsession
chmod 755 /home/chrome/.xsession
}
install_tomcat(){
apt-get install default-jdk tomcat8 -y
sed -i s/http:\/\/localhost/http:\/\/localhost:8080/g /home/chrome/.xsession
cat <<_EOT_>> /var/lib/tomcat8/webapps/ROOT/index.html
<html>
<head></head>
<body>
<table width="100%">
<tr>
<td nowrap><h1>Tomcat8:</h1>
Tomcat installed at: <br />
<code>/usr/share/tomcat8</code> <br />
Conf:<br />
<code>/etc/tomcat8</code> <br />
Doc root:<br />
<code>/var/lib/tomcat8/webapps/ROOT</code>
</td>
<td width="100%" valign="center">
<center>
<h2><a href="http://google.com">Google</h2>
<h2><a href="http://www.pandora.com">Pandora</h2>
<h2><a href="http://amazon.com">Amazon</h2>
</center>
</td>
</tr>
</table>
</body>
</html>
_EOT_
msgbox "Installed Tomcat"
}
install_ngix(){
apt-get install nginx -y
cat <<_EOT_>> /var/www/nginx-default/index.html
<html>
<head></head>
<body>
<table width="100%">
<tr>
<td nowrap><h1>ngix:</h1>
ngix doc root at: <br />
<code>/var/www/nginx-default/</code>
</td>
<td width="100%" valign="center">
<center>
<h2><a href="http://google.com">Google</h2>
<h2><a href="http://www.pandora.com">Pandora</h2>
<h2><a href="http://amazon.com">Amazon</h2>
</center>
</td>
</tr>
</table>
</body>
</html>
_EOT_
msgbox "Installed nginx as basic webserver"
}
kiosk_URL_setother(){
CU=http://www.google.com
NU=$(whiptail --backtitle "Set the the default URL for your kiosk:" --inputbox "Default URL" 0 40 "$CU" 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then
sed -i -e "s/http:\/\/localhost/http:\/$NU/g" /home/chrome/.xsession
fi
}
kiosk_URL(){
CC=$(whiptail --backtitle "Default Kiosk URL" --menu "WebServer Menu" 0 0 1 --nocancel --ok-button "Select one..." \
"1" "Install Tomcat (Java Server)" \
"2" "Install nGIX (Basic webserver)" \
"3" "Set a specific URL" \
3>&1 1>&2 2>&3)
case "$CC" in
"1") install_tomcat;;
"2") install_ngix;;
"3") kiosk_URL_setother;;
*) msgbox "Error 001. Please report on the forums" && exit 0 ;;
esac || msgbox "I don't know how you got here! >> $CC << Report on the forums"
}
#========================================================
# START SCRIPT
#========================================================
CHROMIUM="/usr/bin/chromium --kiosk --no-first-run --disable-translate --disable-infobars --use-gl=egl --ignore-gpu-blacklist --num-raster-threads=4 --enable-zero-copy --enable-floating-virtual-keyboard http://localhost"
check_deb-multimedia
apt-get install console-setup keyboard-configuration pulseaudio -y
dpkg-reconfigure keyboard-configuration
dpkg-reconfigure locales
dpkg-reconfigure tzdata
change_hostname
CC=$(whiptail --backtitle "ODROID audio device" --yesno "Will you be using an ODROID audio device (Stereo Bonnet or HiFi Shield)?" 0 0 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then
odroid_dac
else
fix_c2_audio
fi
install_xorg
install_gpu
install_ddx
apt-get install nodm chromium -y
ln -sf /usr/lib/aarch64-linux-gnu/libGLESv2.so /usr/lib/chromium/libGLESv2.so
ln -sf /usr/lib/aarch64-linux-gnu/libEGL.so /usr/lib/chromium/libEGL.so
useradd -m chrome
echo -e "chrome\nchrome" | passwd chrome
adduser chrome video
adduser chrome audio
adduser chrome adm
adduser chrome cdrom
adduser chrome input
adduser chrome tty
sed -i -e "s/root/chrome/g" /etc/default/nodm
kiosk_URL
config_xsession
sed -i "s/setenv\ condev\ \"consoleblank=0\ console=ttyS0,115200n8\ console=tty0\"/setenv\ condev\ \"consoleblank=1\ console=ttyS0,115200n8\"/" /boot/boot.ini
apt autoremove -y
reboot