-
Notifications
You must be signed in to change notification settings - Fork 0
/
conf.sh
executable file
·188 lines (136 loc) · 3.89 KB
/
conf.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
#!/bin/bash
./rmconf.sh &> /dev/null
source secrets &> /dev/null
if [ -z "$username" ] || [ -z "$password" ] || [ -z "$wifi_ssid" ] || [ -z "$wifi_password" ] || [ -z "$hostname" ] || [ -z "$ip_addr" ]; then
read -p "Enter username: " username
read -s -p "Enter password: " password
echo
read -p "Enter your WiFi SSID: " wifi_ssid
read -s -p "Enter your WiFi password: " wifi_password
echo
read -p "Enter hostname: " hostname
read -p "Enter webpage to display on kiosk: " url
echo "Enter IP Address and Subnet-Mask in \"1.2.3.4/24\" format. "
read -p "Leave Empty for DHCP. IP: " ip_addr
if [ -z "$ip_addr" ]; then
echo "Using DHCP"
else
read -p "Enter Gateway IP: " ip_gw
read -p "Enter DNS Server IP: " ip_dns
fi
fi
if [ -z "$username" ] || [ -z "$password" ] || [ -z "$wifi_ssid" ] || [ -z "$wifi_password" ] || [ -z "$hostname" ]; then
echo "Invalid input. Exiting script."
exit 1
fi
cat <<EOF > kiosk.sh
#!/bin/bash
#cog $url
chromium-browser $url --touch-noise-filtering --start-fullscreen --window-size=1280,1024 --window-position=0,0 --kiosk --noerrdialogs --disable-infobars --disable-translate --no-first-run --fast --fast-start --disable-features=TranslateUI --disk-cache-dir=/dev/null --password-store=basic
EOF
cat <<EOF > 25-wlan.network
[Match]
Name=wlan0
EOF
if [ -z "$ip_addr" ]; then
cat <<EOF >> 25-wlan.network
[Network]
DHCP=ipv4
EOF
echo "nameserver 1.1.1.1" > resolv.conf
else
cat <<EOF >> 25-wlan.network
[Network]
Address=$ip_addr
Gateway=$ip_gw
DNS=$ip_dns
EOF
cat <<EOF >> resolv.conf
nameserver $ip_dns
nameserver 1.1.1.1
EOF
fi
cat <<EOF > wpa_supplicant-wlan0.conf
ctrl_interface=/run/wpa_supplicant
ctrl_interface_group=netdev
update_config=1
country=AT
network={
ssid="$wifi_ssid"
psk="$wifi_password"
}
EOF
cat <<EOF > firstboot.sh
echo "Unblocking wifi"
rfkill unblock all
echo "Creating user 'kiosk'..."
useradd -m kiosk
usermod -aG video kiosk
usermod -aG input kiosk
echo "Copying Kiosk config"
mkdir /home/kiosk/.config
mv /kiosksetup/weston.ini /home/kiosk/.config
echo "Copying Kiosk scripts"
mv /kiosksetup/kiosk.sh /home/kiosk
echo "Reloading systemd daemon..."
systemctl daemon-reload
echo "Enabling kiosk service..."
systemctl enable kiosk.service
echo "Copying hardware database files..."
mv /kiosksetup/61-evdev-local.hwdb /etc/udev/hwdb.d
mv /kiosksetup/99-touch-mirror.rules /etc/udev/rules.d
echo "Creating symbolic link to override libinput rules..."
ln -sf /dev/null /etc/udev/rules.d/90-libinput-fuzz-override.rules
echo "Updating hardware database..."
systemd-hwdb update
echo "Disabling getty service..."
systemctl disable [email protected]
echo "Changing ownership of /home/kiosk to user 'kiosk'..."
chown -R kiosk /home/kiosk
echo "$hostname" > /etc/hostname
systemctl enable ssh
passwd -l root
useradd -m $username
echo '$username:$password' | chpasswd
usermod -aG sudo $username
chsh r3 -s /bin/bash
apt update
apt upgrade -y
apt install weston xwayland chromium-browser -y
echo "Setting logind configuration options..."
echo "NAutoVTs=0" >> /etc/systemd/logind.conf
echo "ReserveVT=10" >> /etc/systemd/logind.conf
rm -rf /usr/share/icons/Adwaita/cursors/*
cp /kiosksetup/left_ptr /usr/share/icons/Adwaita/cursors
echo "avoid_warnings=1" >> /boot/config.txt
echo "disable_splash=1" >> /boot/config.txt
echo "gpu_mem=256" >> /boot/config.txt
sed -i 's/$/ \*quiet nosplash loglevel=0 vt.global_cursor_default=0\*/' /boot/cmdline.txt
rm -rf /kiosksetup
reboot
EOF
cat <<EOF > kiosk.service
[Unit]
Description=Fullscreen Kiosk
RequiresMountsFor=/run
After=network-online.target
[Service]
User=kiosk
WorkingDirectory=/home/kiosk
PermissionsStartOnly=true
Restart=always
PAMName=login
UtmpIdentifier=tty1
TTYPath=/dev/tty1
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
StandardOutput=tty
StandardInput=tty
StandardError=journal
ExecStartPre=/bin/chvt 1
ExecStart=weston
IgnoreSIGPIPE=no
[Install]
WantedBy=multi-user.target
EOF