-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkioskMode-Rpi.sh
More file actions
155 lines (146 loc) · 5.14 KB
/
kioskMode-Rpi.sh
File metadata and controls
155 lines (146 loc) · 5.14 KB
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
#!/bin/bash
HOME_URL='http\:\/\/www\.youtube\.com'
H_USER=$1
WD=$(pwd)
install_packages (){
echo "INSTALLING DEPENDENCIES..."
#Installing graphical interface
apt-get install xserver-xorg
apt-get install xfce4 xfce4-terminal
apt-get install lightdm --yes
apt-get install plymouth plymouth-themes --yes
apt-get install pix-plym-splash --yes
#We will install KIOSK en chromium
apt-get install --no-install-recommends chromium-browser --yes
#Install other packages required
apt-get install xdotool unclutter sed --yes
}
uninstall_packages (){
echo "UNINSTALLING GRAPHIC ENVIRONMENT..."
#Installing graphical interface
apt-get purge xserver-xorg
apt-get purge xfce4 xfce4-terminal
apt-get purge lightdm --yes
apt-get purge plymouth plymouth-themes --yes
apt-get purge pix-plym-splash --yes
#We will install KIOSK en chromium
apt-get purge chromium-browser --yes
#Install other packages required
apt-get clean --yes
apt-get autoremove --yes
}
case $2 in
install)
#Install required packages
if [ $3 == 'full' ]
then
install_packages
fi
#Activating graphical interface from raspi-config
if [ -e /etc/init.d/lightdm ]
then
systemctl set-default graphical.target
ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << EOF
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin ${H_USER} --noclear %I \$TERM
EOF
sed /etc/lightdm/lightdm.conf -i -e "s/^\(#\|\)autologin-user=.*/autologin-user=${H_USER}/"
#Disable Raspi-Config at boot
if [ -e /etc/profile.d/raspi-config.sh ]; then
rm -f /etc/profile.d/raspi-config.sh
if [ -e /etc/systemd/system/getty@tty1.service.d/raspi-config-override.conf ]; then
rm /etc/systemd/system/getty@tty1.service.d/raspi-config-override.conf
fi
telinit q
fi
else
echo "You need to install LigthDM. Run :"
echo " sudo kioskMode.sh pi install full"
echo "Change pi if you have another user name (echo \$USER)"
exit
fi
#Set video preferences
rm -f /boot/config.txt
cp ${WD}/files/config.txt /boot/config.txt
rm -f /boot/cmdline.txt
cp ${WD}/files/cmdline /boot/cmdline.txt
#Set Splash
if [ ! -d /home/${H_USER}/.kiosk ]
then
mkdir /home/${H_USER}/.kiosk
fi
if [ -d /usr/share/plymouth ]
then
cp ${WD}/files/splash.png /usr/share/plymouth/themes/pix
rm -f /usr/share/plymouth/themes/pix/pix.script
cp ${WD}/files/plymouth /usr/share/plymouth/themes/pix/pix.script
else
echo "You need install PLYMOUTH to complete the instalation. Re-run as 'YOUR_USER_NAME install full' see 'help'"
fi
#"No Desktop"
cp ${WD}/files/splash.png /home/${H_USER}/.kiosk
if [ -e /home/${H_USER}/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml ]
then
sed -i "s/true/false/g" /home/${H_USER}/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml
sed -i "s/\/usr\/share\/images\/desktop\-base\/desktop\-background\/\/home\/${H_USER}\/Pictures\/" /home/${H_USER}/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml
else
echo "Some steps of the installation will be applied after reboot..."
fi
#Forcing chromium
if [ ! -d /home/${H_USER}/.config/chromium/Default ]
then
mkdir /home/${H_USER}/.config/chromium/Default
touch /home/${H_USER}/.config/chromium/Default/Preferences
fi
#Creating service to handle kiosk
if [ ! -e /etc/systemd/system/kiosk.service ]
then
cp ${WD}/files/kiosk.service ${WD}/kiosk.service
sed -i "s/USER/${H_USER}/g" ${WD}/kiosk.service
sed -i "s/ARGS/\ /g" ${WD}/kiosk.service
sed -i "s/HOMEPAGE/${HOME_URL}/g" ${WD}/kiosk.service
cp ${WD}/kiosk.service /etc/systemd/system/kiosk.service
rm kiosk.service
cp ${WD}/files/kiosk.sh /home/${H_USER}/.kiosk/kiosk.sh
systemctl enable kiosk
else
echo "Kiosk service already installed, you need to reboot to start kiosk mode..."
fi
;;
uninstall)
echo "Removing service..."
systemctl stop kiosk
systemctl disable kiosk
rm /etc/systemd/system/multi-user.target.wants/kiosk.service
rm /etc/systemd/system/kiosk.service
rm /home/${H_USER}/kiosk.sh
echo "Setting as Console without Autologin..."
systemctl set-default multi-user.target
ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
rm /etc/systemd/system/getty@tty1.service.d/autologin.conf
#Restoring cmdline and config.txt
rm -f /boot/cmdline.txt
cp ${WD}/files/cmdlinebase /boot/cmdline.txt
read -p "¿Do you want to restore default config.txt?(y/n): " answer
if [ answer == 'y' ]
then
rm -f /boot/config.txt
cp ${WD}/files/configbase /boot/config.txt
fi
if [ $3 == 'full' ]
then
uninstall_packages
fi
;;
esac
if [ $1 == 'help' ]
then
echo "This script configure KIOSK mode on RaspberryPi"
echo "USE:"
echo " kioskMode pi install full-> on RPi headless (install graphic mode) "
echo " kioskMode pi install -> if have already downloaded graphic environment"
echo " kioskMode pi uninstall full -> remove service and all installed packages"
echo " kioskMode pi uninstall -> remove service that handle kioskMode"
fi