Work on standalone mode
This commit is contained in:
@@ -31,7 +31,8 @@ ConditionPathExists=/dev/tty0
|
||||
|
||||
[Service]
|
||||
# the VT is cleared by TTYVTDisallocate
|
||||
ExecStart=-/sbin/agetty -a kioskuser --noclear %I $TERM
|
||||
ExecStart=
|
||||
ExecStart=-/sbin/agetty --autologin kioskuser --noclear %I $TERM
|
||||
Type=idle
|
||||
Restart=always
|
||||
RestartSec=0
|
||||
|
||||
@@ -11,7 +11,7 @@ url="$1"
|
||||
conf_file="$2"
|
||||
|
||||
source $conf_file
|
||||
if [[ "$EUID" == "0" || $(who|cut -d" " -f1) == "kioskuser" ]]
|
||||
if [[ "$EUID" == "0" || $(whoami) == "kioskuser" ]]
|
||||
then
|
||||
# Use standalone args
|
||||
chromargs="--test-type --ignore-certificate-errors --kiosk --no-first-run --check-for-update-interval=1 --simulate-upgrade --incognito"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
# openkiosk
|
||||
|
||||
if [[ "$EUID" == "0" || $(who|cut -d" " -f1) == "kioskuser" ]]
|
||||
if [[ "$EUID" == "0" || $(whoami) == "kioskuser" ]]
|
||||
then
|
||||
conf_file="/etc/openkiosk/openkiosk.conf"
|
||||
run_type="standalone"
|
||||
@@ -111,17 +111,12 @@ function check_url() {
|
||||
function debuglog() {
|
||||
if [[ "$DEBUG" == "1" ]]
|
||||
then
|
||||
if [[ "$run_type" == "standalone" ]]
|
||||
logfile="$HOME/openkiosk.log"
|
||||
if [[ ! -e "$logfile" ]]
|
||||
then
|
||||
logfile_path="/var/log/openkiosk.log"
|
||||
else
|
||||
logfile_path="$HOME/openkiosk.log"
|
||||
echo "openkiosk log started : "$(date +%Y-%m-%d %H:%M:%S) > $logfile
|
||||
fi
|
||||
if [[ ! -e "$logfile_path" ]]
|
||||
then
|
||||
echo "openkiosk log started : "$(date +%Y-%m-%d %H:%M:%S) > $logfile_path
|
||||
fi
|
||||
echo $(date +%H:%M:%S) "$1">>$logfile_path
|
||||
echo $(date +%H:%M:%S) "$1">>$logfile
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
140
kiosk-setup.sh
140
kiosk-setup.sh
@@ -44,20 +44,23 @@ function disable_unattended_upgrades() {
|
||||
function update_os() {
|
||||
# Make sure OS is up to date
|
||||
echo "Updating Operating System..."
|
||||
sleep 5
|
||||
apt-get update -qq
|
||||
apt-get update -qq
|
||||
if [[ "$kconfig" == "standalone" ]]
|
||||
then
|
||||
if apt-get dist-upgrade -y
|
||||
if ((apt-get dist-upgrade -y >/dev/null 2>&1)&
|
||||
task_pid=$!
|
||||
spinner $task_pid
|
||||
unset task_pid)
|
||||
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"
|
||||
echo " apt-get dist-upgrade -y"
|
||||
abort_exit
|
||||
fi
|
||||
unset task_result
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -82,34 +85,29 @@ function remove_snap() {
|
||||
fi
|
||||
}
|
||||
|
||||
function install_rpi5_gl() {
|
||||
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
|
||||
}
|
||||
|
||||
function install_x_server() {
|
||||
# Install X server
|
||||
echo "Installing X server..."
|
||||
if apt-get install -y --no-install-recommends xorg openbox xterm xpdf
|
||||
then
|
||||
echo "...done."
|
||||
systemctl enable getty@tty1.service
|
||||
echo ""
|
||||
else
|
||||
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
|
||||
function install_package() {
|
||||
# Install a specified package.
|
||||
local pkg=$1
|
||||
echo "Checking for $pkg installation..."
|
||||
if dpkg -l|grep -q $pkg
|
||||
then
|
||||
echo ""
|
||||
echo "$pkg is installed. Continuing."
|
||||
echo ""
|
||||
else
|
||||
echo "Installing $pkg..."
|
||||
if ! ((apt-get install -y --no-install-recommends $pkg >/dev/null 2>&1)&
|
||||
task_pid=$!
|
||||
spinner $task_pid
|
||||
unset task_pid)
|
||||
then
|
||||
echo "A problem was encountered during installation."
|
||||
echo "the command that failed was:"
|
||||
echo " apt-get install -y --no-install-recommends $pkg"
|
||||
abort_exit
|
||||
fi
|
||||
fi
|
||||
echo "...done."
|
||||
}
|
||||
|
||||
function install_webmin() {
|
||||
@@ -142,7 +140,7 @@ function install_webmin() {
|
||||
sleep 3
|
||||
echo "Installing webmin..."
|
||||
skipwebmin="false"
|
||||
if ! curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh
|
||||
if ! curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh >/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]: "
|
||||
@@ -161,8 +159,13 @@ function install_webmin() {
|
||||
fi
|
||||
if [ "$skipwebmin" = "false" ]
|
||||
then
|
||||
sh setup-repos.sh -f
|
||||
apt-get install -y --install-recommends webmin
|
||||
(
|
||||
sh setup-repos.sh -f >/dev/null 2>&1
|
||||
apt-get install -y --install-recommends webmin >/dev/null 2>&1
|
||||
)&
|
||||
task_pid=$!
|
||||
spinner $task_pid
|
||||
unset task_pid
|
||||
fi
|
||||
echo "...done."
|
||||
echo ""
|
||||
@@ -211,8 +214,11 @@ function install_cups() {
|
||||
echo ""
|
||||
sleep 3
|
||||
echo "Installing cups print server..."
|
||||
apt-get install -y cups
|
||||
usermod -G lpadmin $(who|cut -d" " -f1)
|
||||
(apt-get install -y cups > /dev/null 2>&1)&
|
||||
task_pid=$!
|
||||
spinner $task_pid
|
||||
unset task_pid
|
||||
usermod -aG lpadmin $SUDO_USER
|
||||
myhn=`hostname`
|
||||
echo ""
|
||||
echo ""
|
||||
@@ -240,11 +246,11 @@ function create_standalone_user() {
|
||||
# Install standalone kiosk user config
|
||||
echo ""
|
||||
echo "Creating kiosk user..."
|
||||
cloneuser.sh `who am i | awk '{print $1}'` kioskuser
|
||||
cloneuser $SUDO_USER kioskuser >/dev/null 2>&1
|
||||
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
|
||||
cp -R distfiles/home/kioskuser /home/
|
||||
cp distfiles/home/kioskuser/.profile /home/kioskuser
|
||||
cp distfiles/home/kioskuser/.config/openbox/rc.xml /home/kioskuser/.config/openbox
|
||||
chown -R kioskuser:kioskuser /home/kioskuser/.config /home/kioskuser/.profile
|
||||
echo "...done."
|
||||
echo ""
|
||||
@@ -380,7 +386,10 @@ function install_required_packages() {
|
||||
echo "Proceeding with $preferred_pkg installation"
|
||||
echo ""
|
||||
sleep 3
|
||||
apt-get install -y $preferred_pkg
|
||||
(apt-get install -y $preferred_pkg > /dev/null 2>&1)&
|
||||
task_pid=$!
|
||||
spinner $task_pid
|
||||
unset task_pid
|
||||
echo ""
|
||||
echo "Finished with $preferred_pkg installation"
|
||||
echo ""
|
||||
@@ -391,6 +400,19 @@ function install_required_packages() {
|
||||
done
|
||||
}
|
||||
|
||||
function spinner() {
|
||||
local pid="$1"
|
||||
local delay="0.1"
|
||||
local spinstr='|/-\\'
|
||||
local i=0
|
||||
|
||||
while ps -p "$pid" > /dev/null; do
|
||||
i=$(( (i+1) % 4 ))
|
||||
printf "\r[%c]" "${spinstr:$i:1}"
|
||||
sleep "$delay"
|
||||
done
|
||||
printf "\r \r" # Clear the spinner line
|
||||
}
|
||||
|
||||
# -------------- Begin execution --------------
|
||||
|
||||
@@ -467,14 +489,7 @@ echo "Preparing for $kconfig installation. Please wait..."
|
||||
|
||||
disable_unattended_upgrades
|
||||
apt-get update -qq
|
||||
install_required_packages "chromium" "xpdf"
|
||||
|
||||
# Determine OS Release version
|
||||
echo -n "OS information: "
|
||||
echo ""
|
||||
cat /etc/os-release
|
||||
echo ""
|
||||
sleep 5
|
||||
install_required_packages "rsync" "curl" "psmisc"
|
||||
|
||||
chmod +x distfiles/usr/local/bin/*
|
||||
|
||||
@@ -482,23 +497,30 @@ case "$kconfig" in
|
||||
"standalone")
|
||||
# Copy in the needed files
|
||||
echo "Copying files..."
|
||||
cp -vf distfiles/usr/local/bin/* /usr/local/bin
|
||||
cp -Rvf distfiles/etc/* /etc/
|
||||
cp -vf distfiles/lib/systemd/system/getty@tty1.service /lib/systemd/system
|
||||
cp -f distfiles/usr/local/bin/* /usr/local/bin
|
||||
cp -Rf distfiles/etc/* /etc/
|
||||
cp -f distfiles/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."
|
||||
echo ""
|
||||
update_os
|
||||
remove_snap
|
||||
# If we are on a Raspberry Pi 5, we'll need to install this for the
|
||||
install_package "xorg"
|
||||
install_package "openbox"
|
||||
install_package "xterm"
|
||||
echo "Enabling autologin for standalone kiosk mode."
|
||||
systemctl enable getty@tty1.service >/dev/null 2>&1
|
||||
# If we are on a Raspberry Pi 5, we'll need to install this for the
|
||||
# xorg server to start
|
||||
if cat /proc/cpuinfo|grep -q "Raspberry Pi 5" >/dev/null 2>&1
|
||||
then
|
||||
install_rpi5_gl
|
||||
echo "Raspberry Pi 5 detected."
|
||||
install_package "gldriver-test"
|
||||
fi
|
||||
install_x_server
|
||||
install_webmin
|
||||
install_package "chromium"
|
||||
install_package "xpdf"
|
||||
install_webmin
|
||||
install_cups
|
||||
create_standalone_user
|
||||
set_kiosk_url
|
||||
@@ -529,7 +551,9 @@ case "$kconfig" in
|
||||
mkdir -p /etc/openkiosk
|
||||
cp -vf distfiles/etc/openkiosk/openkiosk.conf /etc/openkiosk/
|
||||
cp -vf distfiles/etc/openkiosk/openkiosk_welcome.html /etc/openkiosk/
|
||||
install_cups
|
||||
install_package "chromium"
|
||||
install_package "xpdf"
|
||||
install_cups
|
||||
set_kiosk_url
|
||||
set_kiosk_type
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user