Incorporate changes for version 1.1.0

This commit is contained in:
2026-02-25 14:05:59 -05:00
parent b2402566a5
commit 6c9c0e3dcf
15 changed files with 869 additions and 205 deletions

View File

@@ -6,30 +6,72 @@
# SPDX-License-Identifier: GPL-2.0
OK_VERSION="1.0.2"
APP_NAME="OpenKiosk"
APP_VERSION="1.1.0"
# Test for superuser
current_user=`whoami`
current_login=`who am i | awk '{print $1}'`
if [ "$current_user" != "root" ]
then
echo "You must have root privileges to run this setup."
echo "Try 'sudo ./kiosk-setup.sh'"
exit 1
fi
function clean_exit() {
# Re-enable unattended-upgrades
if $restart_uu; then systemctl start unattended-upgrades; fi
exit 0
}
function abort_exit() {
# Re-enable unattended-upgrades
if $restart_uu; then systemctl start unattended-upgrades; fi
exit 1
}
function privilege_check() {
# test for superuser rights
if [[ $EUID -ne 0 ]]; then
echo "This script must be run with superuser privileges. Try sudo $0"
exit 1
fi
}
function disable_unattended_upgrades() {
# Prevent unattended-upgrades from interfering
restart_uu=false
while systemctl status unattended-upgrades >/dev/null 2>&1
do
systemctl stop unattended-upgrades
sleep 5
restart_uu=true
done
}
# -------------- Begin execution --------------
privilege_check
echo ""
echo " Welcome to OpenKiosk $OK_VERSION"
echo " Welcome to $APP_NAME $APP_VERSION installation"
echo ""
echo ""
echo "This script will configure a Debian based system to be a Kiosk Browser terminal."
echo "This script will configure a Debian based system to be a kiosk browser terminal."
echo ""
echo ""
echo "To continue with the setup of OpenKiosk, press enter. Otherwise,"
echo -n "press ctrl-c to quit."
read continueok
echo ""
continueok=false
while ! $continueok
do
read -p "Would you like to continue with OpenKiosk setup [Y/n]: " -r continueok
if [[ $continueok == "n" || $continueok == "N" ]]
then
exit 1
elif [[ $continueok == "y" || $continueok == "Y" || $continueok == "" ]]
then
continueok=true
echo "Continuing with OpenKiosk setup."
else
continueok=false
echo "Please answer Y (default) or N."
fi
done
echo ""
echo "Preparing for installation. Please wait..."
disable_unattended_upgrades
# Determine OS Release version
echo -n "OS information: "
@@ -41,9 +83,9 @@ sleep 5
# Copy in the needed files
echo "Copying files..."
chmod +x usr/local/bin/*
cp -Rv etc/* /etc/
cp -v usr/local/bin/* /usr/local/bin
cp -v lib/systemd/system/getty@tty1.service /lib/systemd/system
cp -Rvf etc/* /etc/
cp -vf usr/local/bin/* /usr/local/bin
cp -vf lib/systemd/system/getty@tty1.service /lib/systemd/system
rm /lib/systemd/system/ctrl-alt-del.target
ln -s /dev/null /lib/systemd/system/ctrl-alt-del.target
echo "...done."
@@ -51,9 +93,16 @@ echo "...done."
# Make sure OS is up to date
echo "Updating Operating System..."
sleep 5
apt update && apt dist-upgrade -y
echo "...done."
echo ""
if apt-get update && apt-get dist-upgrade -y
then
echo "...done."
echo ""
else
echo "A problem was encountered during installation."
echo "the command that failed was:"
echo " apt-get update && apt-get dist-upgrade -y"
abort_exit
fi
# Remove snap if installed
if snap list >/dev/null 2>&1; then
@@ -64,7 +113,7 @@ if snap list >/dev/null 2>&1; then
systemctl stop snapd
systemctl disable snapd
systemctl mask snapd
apt purge snapd -y
apt-get purge snapd -y
apt-mark hold snapd
rm -rf /home/*/snap/
rm -rf /root/snap/
@@ -72,8 +121,6 @@ if snap list >/dev/null 2>&1; then
rm -rf /var/snap
rm -rf /var/lib/snapd
echo "...done."
# Add the firefox deb repository since we won't be getting snap
add-apt-repository -y ppa:mozillateam/ppa
fi
# Install packages
@@ -87,83 +134,182 @@ echo ""
# xorg server to start
if cat /proc/cpuinfo|grep -q "Raspberry Pi 5" >/dev/null 2>&1
then
apt install -y gldriver-test
echo "Installing gl driver for Raspberry Pi 5..."
if apt-get install -y gldriver-test
then
echo "...done."
echo ""
else
echo "A problem was encountered during installation."
echo "the command that failed was:"
echo " apt-get install -y gldriver-test"
abort_exit
fi
fi
# If we are on a Raspberry Pi running Raspbian we use chromium-browser.
# If we are on anything else, we use firefox.
if cat /etc/os-release|grep -q "Raspbian" >/dev/null 2>&1
# Install X server
echo "Installing X server..."
if apt-get install -y --no-install-recommends xorg openbox xterm xpdf
then
browser_pkg="chromium-browser"
ln -sf /etc/openkiosk.conf-chromium /etc/openkiosk.conf
echo "...done."
systemctl enable getty@tty1.service
echo ""
else
browser_pkg="firefox"
ln -sf /etc/openkiosk.conf-firefox /etc/openkiosk.conf
echo "A problem was encountered during installation."
echo "the command that failed was:"
echo " apt-get install -y --no-install-recommends xorg openbox"
abort_exit
fi
# Install required packages
apt update
apt install -y --no-install-recommends xorg openbox $browser_pkg
apt install -y cups libcups2-dev cmake
systemctl enable getty@tty1.service
cd brlaser-master && cmake . && make && make install && cd ..
myhn=`hostname`
infotimer=10
echo ""
echo ""
echo ""
echo "The cups print server has been installed."
echo "After the kiosk is set up and working, you can use another network"
echo "computer to point a web browser to $myhn:631 to add a printer"
echo "of your choosing."
while [ $infotimer -gt 0 ]
# Try to install chromium-browser package, but if that fails, add
# repository and install chromium package
while ! apt-get install -y chromium
do
sleep 1
((infotimer-=1))
if add-apt-repository ppa:xtradeb/apps -y
then
echo "added chromium repository"
echo ""
else
echo "A problem was encountered during installation."
echo "the command that failed was:"
echo " apt-get install -y gldriver-test"
abort_exit
fi
apt-get update
done
echo ""
# Download and install webmin
echo "Installing webmin..."
skipwebmin="false"
curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh
if [ $? -ne 0 ]
# Check for webmin installation and prompt for install
echo ""
echo "Checking for webmin installation..."
echo ""
if dpkg -l|grep webmin >/dev/null 2>&1
then
echo "Warning: failed to download Webmin repo setup script."
echo -n "Ignore and [c]ontinue or [A]bort? [c/A]: "
read wmfailchoice
if [ "$wmfailchoice" = "C" -o "$wmfailchoice" = "c" ]
then
skipwebmin="true"
echo "Continuing without installing Webmin. You should investigate the failure"
echo "and install Webmin manually after the kiosk is set up if you would like"
echo "to be able to manage the kiosk from another computer with a GUI instead"
echo "of through ssh only."
echo -n "Press enter to continue."
read continueok
echo ""
else
echo "Aborting kiosk setup."
exit 1
fi
echo ""
echo "webmin is installed. Continuing."
echo ""
else
echo "webmin doesn't seem to be installed."
echo "It is an optional package that enables system administration"
echo "using a friendly GUI. It is highly recommended, especially for"
echo "headless servers without any way to log in directly on the machine."
echo "Note that this has the potential to be a security risk, especially"
echo "if your passwords aren't sufficiently strong."
echo -n "Install it now? [Y/n]: "
read reqinstall
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
then
echo "Proceeding without installing webmin. System administration"
echo "will require login to the server either directly or via ssh."
else
echo ""
echo "Proceeding with webmin installation"
echo ""
sleep 3
echo "Installing webmin..."
skipwebmin="false"
if ! curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh
then
echo "Warning: failed to download Webmin repo setup script."
echo -n "Ignore and [c]ontinue or [A]bort? [c/A]: "
read wmfailchoice
if [ "$wmfailchoice" = "C" -o "$wmfailchoice" = "c" ]
then
skipwebmin="true"
echo "Continuing without installing Webmin. You should investigate the failure"
echo "and install Webmin manually after the server is set up if you would like"
echo "to be able to manage the server from another computer with a GUI instead"
echo "of through ssh only."
echo -n "Press enter to continue."
read continueok
echo ""
fi
fi
if [ "$skipwebmin" = "false" ]
then
sh setup-repos.sh -f
apt-get install -y --install-recommends webmin
fi
echo "...done."
echo ""
echo "You can now access webmin using a web browser pointed to:"
echo "https://$HOSTNAME:10000"
echo "Unless you have obtained valid ssl certificates, your server is"
echo "using self-signed certs. This is not necessarily a problem, but"
echo "your browser will complain. You can tell the browser to accept the"
echo "self signed certificates and the traffic will still be encrypted,"
echo "however you may be vulnerable to man-in-the-middle attacks. You can"
echo "get free valid certificates through LetsEncrypt."
echo "See http://letsencrypt.org for more information."
echo ""
echo -n "Press enter to continue."
read continueok
echo ""
echo "Finished with webmin installation"
echo ""
sleep 3
fi
fi
if [ "$skipwebmin" = "false" ]
# Prompt whether to install print server
echo ""
echo "Checking for cups print server and driver installation..."
echo ""
if dpkg -l|grep cups-common >/dev/null 2>&1 && \
test -f "/usr/share/cups/drv/brlaser.drv" >/dev/null 2>&1
then
sh setup-repos.sh -f
apt install -y --install-recommends webmin
echo ""
echo "cups is installed. Continuing."
echo ""
else
echo "The cups print server or driver doesn't seem to be installed."
echo "If this will be an interactive kiosk and you would like to"
echo "be able to print from it, cups will need to be installed."
read -p "Install it now? [Y/n]: " -r reqinstall
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
then
echo "Proceeding without installing cups."
else
echo ""
echo "Proceeding with cups installation"
echo ""
sleep 3
echo "Installing cups print server and drivers..."
apt-get install -y cups libcups2-dev cmake
cd brlaser-master && cmake . && make && make install && cd ..
chmod -R a+w brlaser-master
usermod -G lpadmin $(who am i|cut -d" " -f1)
myhn=`hostname`
echo ""
echo ""
echo ""
echo "The cups print server has been installed."
echo "After the kiosk is set up and working, edit /etc/openkiosk.conf"
echo "and set the TGT_URL parameter to:"
echo " https://localhost:631"
echo "to add or manage printers via the kiosk browser."
echo "When you are finished, change it back to your normal URL."
echo "Note that the kiosk browser will, by default, print to the server"
echo "default printer."
echo ""
echo -n "Press enter to continue."
read continueok
echo ""
echo "Finished with cups print server installation"
echo ""
sleep 3
fi
fi
echo "...done."
# Install user config
echo ""
echo "Creating default user..."
cloneuser `who am i | awk '{print $1}'` customer
mkdir -p /home/customer/.config/openbox
cp home/customer/.profile /home/customer
cp home/customer/.config/openbox/rc.xml /home/customer/.config/openbox
cp home/customer/openkiosk_mozilla_profile.tar.gz /home/customer
chown customer:customer /home/customer/openkiosk_mozilla_profile.tar.gz
chown -R customer:customer /home/customer/.config /home/customer/.profile
echo "Creating kiosk user..."
cloneuser.sh `who am i | awk '{print $1}'` kioskuser
mkdir -p /home/kioskuser/.config/openbox
cp -Rv home/kioskuser /home/
cp home/kioskuser/.profile /home/kioskuser
cp home/kioskuser/.config/openbox/rc.xml /home/kioskuser/.config/openbox
chown -R kioskuser:kioskuser /home/kioskuser/.config /home/kioskuser/.profile
echo "...done."
echo ""
@@ -171,38 +317,56 @@ echo ""
echo ""
echo "This web browser based kiosk will need to know the site you would"
echo "like to load. This can be a normal website or a file to be displayed"
echo "in the browser, but must be available as a web URL."
echo "in the browser, but must be available as a web URL (http://something)."
echo ""
echo "Note that in kiosk mode, your normal navigation buttons and mouse"
echo "right-click menus are not available, so you will have no way to go"
echo "back or forward in a page unless the page itself provides that"
echo "capability."
url_ok=false
server_url="https://localhost:10000"
server_url="file:/home/kioskuser/openkiosk_welcome.html"
while ! $url_ok
do
echo ""
echo "Please enter complete URL."
echo -n "[https://localhost:10000] :"
read server_url
echo "Please enter complete URL. Valid formats are:"
echo "\"http://somesite.com/somepage\""
echo "\"file:/path/to/file.name\""
echo ""
read -p "[file:/home/kioskuser/openkiosk_welcome.html] :" -r server_url
if [[ $server_url == "" ]]
then
server_url="https://localhost:10000"
server_url="file:/home/kioskuser/openkiosk_welcome.html"
fi
if ! `wget --no-check-certificate -q -o /dev/null -O /dev/null $server_url`
if [[ $server_url == "test" ]]
then
echo ""
echo "There was an error retrieving the URL you entered. The URL must"
echo "be a complete URL of the format \"http://somesite.com/somepage\"."
echo "If this URL is on the local network, try using the IP address or"
echo "the local domain. For example, instead of \"http://myserver/mypage\","
echo "try \"http://192.168.1.1/mypage\" or \"http://myserver.local/mypage\"."
else
url_ok=true
elif echo "$server_url" | grep -q '^file:'
then
filepath=$(echo "$server_url"|cut -d":" -f2-)
if [ ! -f "$filepath" ]
then
echo ""
echo "There was an error reading the file you entered. The URL must"
echo "be a complete valid path specification of the format:"
echo "\"file:/path/to/file.name\" on the kiosk's filesystem."
else
url_ok=true
fi
else
if ! `wget --no-check-certificate -q -o /dev/null -O /dev/null $server_url`
then
echo ""
echo "There was an error retrieving the URL you entered. The URL must"
echo "be a complete URL of the format \"http://somesite.com/somepage\"."
echo "If this URL is on the local network, try using the IP address or"
echo "the local domain. For example, instead of \"http://myserver/mypage\","
echo "try \"http://192.168.1.1/mypage\" or \"http://myserver.local/mypage\"."
else
url_ok=true
fi
fi
done
sed -i 's,'TGT_URL=.*','TGT_URL="\"$server_url\""',' /etc/openkiosk.conf-firefox
sed -i 's,'TGT_URL=.*','TGT_URL="\"$server_url\""',' /etc/openkiosk.conf-chromium
sed -i 's,'TGT_URL=.*','TGT_URL="\"$server_url\""',' /etc/openkiosk.conf
echo ""
type_choice="none"
while [ "$type_choice" = "none" ]
@@ -211,7 +375,7 @@ do
echo -n "[I]nteractive or [D]isplay-only? [I] :"
read kiosk_type
echo ""
if [ "$kiosk_type" = "D" -o "$kiosk_type" = "d" ]
if [[ $kiosk_type == "D" || $kiosk_type == "d" ]]
then
echo "Configuring for display-only kiosk."
echo "How often would you like to check for changes to the page being"
@@ -220,14 +384,12 @@ do
echo -n "Seconds between checks? [60] :"
read poll_interval
echo ""
if [ "$poll_interval" = "" ]; then poll_interval=60; fi
sed -i 's,'POLL_INTERVAL=.*','POLL_INTERVAL="\"$poll_interval\""',' /etc/openkiosk.conf-firefox
sed -i 's,'POLL_INTERVAL=.*','POLL_INTERVAL="\"$poll_interval\""',' /etc/openkiosk.conf-chromium
if [[ $poll_interval == "" ]]; then poll_interval=60; fi
sed -i 's,'POLL_INTERVAL=.*','POLL_INTERVAL="\"$poll_interval\""',' /etc/openkiosk.conf
echo "Disabling screen blanking."
sed -i 's,'INHIBIT_BLANK=.*','INHIBIT_BLANK="\"1\""',' /etc/openkiosk.conf-firefox
sed -i 's,'INHIBIT_BLANK=.*','INHIBIT_BLANK="\"1\""',' /etc/openkiosk.conf-chromium
sed -i 's,'INHIBIT_BLANK=.*','INHIBIT_BLANK="\"1\""',' /etc/openkiosk.conf
type_choice="D"
elif [ "$kiosk_type" = "I" -o "$kiosk_type" = "i" ]
elif [[ $kiosk_type == "I" || $kiosk_type = "i" || $kiosk_type == "" ]]
then
echo "Configuring for interactive kiosk."
type_choice="I"
@@ -239,11 +401,11 @@ echo ""
echo "Kiosk configuration is now complete. "
echo ""
echo "The system must be rebooted for the configuration to take effect."
echo -n "Enter R to reboot now, or hit enter to return to shell. "
read rebootok
if [ "$rebootok" = "R" -o "$rebootok" = "r" ]
echo ""
read -p "Would you like to reboot now? [Y/n]: " -r rebootok
if [[ $rebootok == "Y" || $rebootok == "y" || $rebootok == "" ]]
then
reboot
else
exit 0
clean_exit
fi