This repository has been archived by the owner on Feb 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
129 lines (108 loc) · 4.98 KB
/
install.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
#!/usr/bin/env bash
# Kiosk mode Install Script
#--------------------------------------------------------------------------------------------------------------------#
# data on how to do this was pulled mainly from:
# https://die-antwort.eu/techblog/2017-12-setup-raspberry-pi-for-kiosk-mode/
# data on how to refresh the screen - https://www.raspberrypi.org/forums/viewtopic.php?t=178206#p1300301
#--------------------------------------------------------------------------------------------------------------------#
# MIT License
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
#documentation files (the "Software"), to deal in the Software without restriction, including without limitation
#the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
#and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
#THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
#OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
#OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#--------------------------------------------------------------------------------------------------------------------#
# Run this script as root or under sudo
screen_size=$(stty size 2>/dev/null || echo 24 80)
rows=$(echo $screen_size | awk '{print $1}')
columns=$(echo $screen_size | awk '{print $2}')
# Divide by two so the dialogues take up half of the screen, which looks nice.
r=$(( rows / 2 ))
c=$(( columns / 2 ))
# Unless the screen is tiny
r=$(( r < 20 ? 20 : r ))
c=$(( c < 70 ? 70 : c ))
if [[ $EUID -eq 0 ]];then
echo "::: You are root."
else
echo "::: sudo will be used."
# Check if it is actually installed
# If it isn't, exit because the install cannot complete
if [[ $(dpkg-query -s sudo) ]];then
export SUDO="sudo"
else
echo "::: Please install sudo or run this script as root."
exit 1
fi
fi
whiptail --msgbox --title "Pi-Kiosk automated installer" "\nThis installer turns your Raspberry Pi and Wifi Dongle into \nan awesome kiosk or webpage displayer!" ${r} ${c}
whiptail --msgbox --title "Pi-Kiosk automated installer" "\n\nFirst things first... Lets set up some variables!" ${r} ${c}
var1=$(whiptail --inputbox "Webpage to show" ${r} ${c} http://192.168.XX.XX:XXXX --title "Kiosk Display Selection" 3>&1 1>&2 2>&3)
var2=$(whiptail --inputbox "Kiosk name --> hostname" ${r} ${c} kiosk --title "Kiosk name" 3>&1 1>&2 2>&3)
whiptail --msgbox --title "Pi-Kiosk automated installer" "\n\nOk all the data has been entered...The install will now complete!" ${r} ${c}
function update_distro() {
#updating the distro...
echo ":::"
echo "::: Running an update to your distro :::"
$SUDO apt update
echo "::: DONE! :::"
}
function upgrade_distro() {
#updating the distro...
echo "::::::::::::"
echo "::: Running upgrades :::"
$SUDO apt upgrade -y
echo "::: DONE! :::"
}
function install_wifi() {
# installing wifi drivers
echo "::::::::::::"
echo "::: Installing wifi drivers :::"
$SUDO wget http://downloads.fars-robotics.net/wifi-drivers/install-wifi -O /usr/bin/install-wifi
$SUDO chmod +x /usr/bin/install-wifi
$SUDO install-wifi
echo "::: DONE! :::"
}
function install_the_things() {
# installing all the programs to enable kiosk mode
echo "::::::::::::"
echo "::: Installing programs :::"
$SUDO apt install -y xinit xserver-xorg x11-xserver-utils unclutter chromium-browser matchbox-window-manager xdotool
echo "::: DONE installing all the things! :::"
}
function edit_startup() {
# editing startup files to auto start
echo ":::"
echo "::: Editing Files :::"
echo "chromium-browser --no-sandbox --noerrdialogs --disable-infobars --incognito --kiosk $var1
/home/pi/pi-kiosk/xauth_root.sh
/home/pi/pi-kiosk/autorefresh-chromium.sh" | sudo tee --append startup.sh > /dev/null
# make the startup executeable
chmod +x startup.sh
# change rc.local to run the startup script
$SUDO sed -i.bak "s+exit 0+#exit 0+g" /etc/rc.local
echo 'sudo xinit ./home/pi/pi-kiosk/startup.sh &' | sudo tee --append /etc/rc.local > /dev/null
echo 'exit 0 ' | sudo tee --append /etc/rc.local > /dev/null
# get xinit to run matchbox
$SUDO touch ~/.xinitrc
echo '#!/bin/bash
matchbox-window-manager' | sudo tee --append ~/.xinitrc > /dev/null
# change the hostname
$SUDO echo $var2 > /etc/hostname # changes the hostname of the machine
# setup a xdotool to be allwed to run in root
sudo chmod 755 xauth_root.sh
# setup the auto refresh script
sudo chmod 755 autorefresh-chromium.sh
echo "::: DONE :::"
echo "::: PLEASE RESTART :::"
#sleep 5
#$SUDO reboot
}
update_distro
upgrade_distro
install_wifi
install_the_things
edit_startup