-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKioskInstall.sh
executable file
·202 lines (176 loc) · 7.15 KB
/
KioskInstall.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
#!/bin/bash
#######################################################
# This script will help do the heavy lifting when trying
# to create a simple Kiosk on a Rpi 3.
#######################################################
# Logo Call
echo "###################################################"
echo "###################################################"
echo -e "\n"
cat jhart_shell_logo.txt
echo -e "\n"
echo "###################################################"
echo "###################################################"
#######################################################
sudo apt-get update
echo -e "\n"
echo "###################################################"
echo "###################################################"
echo " Going to check for needed tools. If they are not found they will be installed."
_PKG_OK=$(dpkg-query -W --showformat='${Status}\n' unclutter|grep "install ok installed")
echo -e "\nChecking for unclutter: '$_PKG_OK'"
if [ "" == "$_PKG_OK" ]; then
echo "No unclutter tool found. Installing and Setting up unclutter now."
sleep 3
sudo apt-get -y install unclutter
fi
_PKG_OKTwo=$(dpkg-query -W --showformat='${Status}\n' vim|grep "install ok installed")
echo -e "\nChecking for vim: '$_PKG_OKTwo'"
if [ "" == "$_PKG_OKTwo" ]; then
echo "No vim editor found. Installing and Setting up vim now."
sleep 3
sudo apt-get -y install vim
fi
#######################################################
# Now going to ask the user for input about the desired screen rotation
# and write it to the appropriate config file.
echo -e "\n"
echo "###################################################"
echo "###################################################"
echo -e "\n"
while true; do
_Prev_Ran=$(ls /boot/ | grep "config.txt.DSbackup")
if [ "" == "$_Prev_Ran" ];
then
#echo "IF ONE MADE"
#sleep 3
echo "Please specify what screen orientation you will be using. (Answer with 'landscape' or 'portrait')"
read _Rotate
if [ "$_Rotate" == "landscape" ];
then
#echo "IF TWO MADE"
#sleep 3
echo "Now writing orientation to config file."
sleep 2
sudo cp /boot/config.txt /boot/config.txt.DSbackup
echo -e "# Display orientation. Landscape = 0, Portrait = 1\ndisplay_rotate=0" | sudo tee -a /boot/config.txt
echo -e "\n# Use 24 bit colors\nframebuffer_depth=24" | sudo tee -a /boot/config.txt
break
else
if [ "$_Rotate" == "portrait" ];
then
#echo "ELSE TWO MADE"
#sleep 3
echo "Now writing orientation to config file."
sleep 2
echo -e "# Display orientation. Landscape = 0, Portrait = 1\ndisplay_rotate=1" | sudo tee -a /boot/config.txt
echo -e "\n# Use 24 bit colors\nframebuffer_depth=24" | sudo tee -a /boot/config.txt
break
fi
fi
else
#echo "ELSE ONE MADE"
#sleep 3
sudo mv /boot/config.txt.DSbackup /boot/config.txt
fi
done
#######################################################
# Here we ask the user to input their desired kiosk, video, or slideshow
# URL. Then we write remaining settings to the appropriate config file.
echo -e "\n"
echo "##################################################"
echo "##################################################"
echo -e "\n"
while true; do
_Prev_RanTwo=$(ls /etc/xdg/lxsession/LXDE-pi/ | grep "autostart.DSbackup")
if [ "" == "$_Prev_RanTwo" ];
then
echo "Please enter the URL of the kiosk, video, or slideshow that you wish to show."
read _URL
echo "You entered the URL as '$_URL'. Is that correct? y/n"
read _yn
if [ "$_yn" == "y" ];
then
echo "Now writing chromium and kiosk configurations to config file. There will be a backup of original config file created. It will be located /etc/xdg/lxsession/LXDE-pi/autostart.backup."
sleep 5
cp /etc/xdg/lxsession/LXDE-pi/autostart /etc/xdg/lxsession/LXDE-pi/autostart.DSbackup
echo -e "@lxpanel --profile LXDE-pi\n@pcmanfm --desktop --profile LXDE-pi\n@xscreensaver -no-splash\npoint-rpi\n@xset s off\n@xset -dpms\n@xset s noblank" | sudo tee -a /etc/xdg/lxsession/LXDE-pi/autostart
echo -e "@chromium-browser --noerrdialogs --disable-infobars --disable-session-crashed-bubble --incognito --kiosk $_URL" | sudo tee -a /etc/xdg/lxsession/LXDE-pi/autostart
break
fi
else
sudo mv /etc/xdg/lxsession/LXDE-pi/autostart.DSbackup /etc/xdg/lxsession/LXDE-pi/autostart
fi
done
##########################################################
# Here we edit the chromium defualt preferences file so that there will be no crash flag upon reboot
sudo sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' /home/pi/.config/chromium/Default/Preferences
sudo sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' /home/pi/.config/chromium/Default/Preferences
##########################################################
# Here we edit the /etc/lightdm/lightdm.conf file to completely remove the mouse cursor from the system.
echo -e "\n"
echo "##################################################"
echo "##################################################"
echo -e "\n"
while true; do
echo "The mouse cursor has been hidden until moved in your kiosk. Would you like to remove the mouse cursor permenantly (Even when moved)? Answer 'Yes' or 'No'"
read _rmCursor
if [ "$_rmCursor" == "Yes" ];
then
echo "Now going to back up the lightdm.conf file and edit the new lightdm.conf to remove mouse cursor."
sleep 5
sudo cp /etc/lightdm/lightdm.conf /etc/lightdm/lightdm.conf.DSbackup
sudo sed -i 's/#xserver-command=X/xserver-command=X -nocursor/' /etc/lightdm/lightdm.conf
break
else
if [ "$_rmCursor" == "No" ];
then
break
fi
fi
done
#########################################################
# Here we ask the user if they would like to change the RPi Memory split
echo -e "\n"
echo "##################################################"
echo "##################################################"
echo -e "\n"
echo "Finally, would you like to change your Pi's Memory Split? Type YES or NO. (If you do not know what this means type NO)"
read _Mem_Split
if [ "$_Mem_Split" == "YES" ];
then
while true; do
echo "Please enter the Memory Split you would like. (Must be one of the following values '64, 128, 256, 512' NOTE 64 is the default)"
read _Mem_Val
if [ "$_Mem_Val" == "64" ] || [ "$_Mem_Val" == "128" ] || [ "$_Mem_Val" == "256" ] || [ "$_Mem_Val" == "512" ];
then
echo " You have entered your desired memory split to be '$_Mem_Val', is that correct? y/n"
read _Mem_Yn
if [ "$_Mem_Yn" == "y" ];
then
_Mem_Set=$(cat /boot/config.txt | grep "gpu_mem=")
if [ "" == "$_Mem_Set" ];
then
echo -e "\ngpu_mem=$_Mem_Val" | sudo tee -a /boot/config.txt
echo "Your new memory split has been added to /boot/config file!"
sleep 3
break
else
sudo sed -i "s/gpu_mem=[0-9]\+/gpu_mem=$_Mem_Val/" /boot/config.txt
echo "Your new memory split has been added to /boot/config file!"
break
fi
fi
fi
done
else if [ "$_Mem_Split" == "NO" ];
then
echo "Your Pi's memory split will remain set to default."
sleep 3
break
fi
fi
##########################################################
echo "All done!! Please restart your Raspberry Pi now. Chromium will start in kiosk mode displaying the page you specified with the URL you specfied. Thank you -JHart"
sleep 5
exit