Added functionality to uninstall the script or to update settings
This commit is contained in:
1 parent
3840b729a2
commit
fb04c807b9
1 file changed
+46
-9
+46
-9
@@ -6,6 +6,36 @@ warn() { echo "WARNING: $*" >&2; }
|
|||||||
|
|
||||||
[[ "${EUID}" -ne 0 ]] || die "Run as your regular user, not sudo."
|
[[ "${EUID}" -ne 0 ]] || die "Run as your regular user, not sudo."
|
||||||
|
|
||||||
|
APP_DIR="$HOME/.local/bin"
|
||||||
|
AUTOSTART_DIR="$HOME/.config/autostart"
|
||||||
|
LAUNCHER="$APP_DIR/launch-kiosk.sh"
|
||||||
|
DESKTOP_FILE="$AUTOSTART_DIR/launch-kiosk.desktop"
|
||||||
|
CONFIG_FILE="$HOME/.config/kiosk-display.conf"
|
||||||
|
|
||||||
|
echo "1) Install or update kiosk"
|
||||||
|
echo "2) Uninstall kiosk"
|
||||||
|
read -r -p "Choose an option [1/2]: " ACTION
|
||||||
|
|
||||||
|
if [[ "$ACTION" == "2" ]]; then
|
||||||
|
echo "Removing kiosk launcher and user configuration..."
|
||||||
|
rm -f "$LAUNCHER" "$DESKTOP_FILE" "$CONFIG_FILE"
|
||||||
|
|
||||||
|
if command -v systemctl >/dev/null 2>&1; then
|
||||||
|
echo "Removing daily reboot timer..."
|
||||||
|
sudo systemctl disable --now kiosk-daily-reboot.timer 2>/dev/null || true
|
||||||
|
sudo rm -f \
|
||||||
|
/etc/systemd/system/kiosk-daily-reboot.timer \
|
||||||
|
/etc/systemd/system/kiosk-daily-reboot.service
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl reset-failed
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Uninstall complete. The system hostname was left unchanged."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ "$ACTION" == "1" ]] || die "Choose 1 to install or 2 to uninstall."
|
||||||
|
|
||||||
command -v firefox >/dev/null 2>&1 || die "Firefox is not installed or not in PATH."
|
command -v firefox >/dev/null 2>&1 || die "Firefox is not installed or not in PATH."
|
||||||
command -v systemctl >/dev/null 2>&1 || die "systemctl is not available."
|
command -v systemctl >/dev/null 2>&1 || die "systemctl is not available."
|
||||||
|
|
||||||
@@ -28,13 +58,6 @@ read -r -p "Enter daily reboot time in HH:MM format (default: 06:00): " REBOOT_T
|
|||||||
REBOOT_TIME="${REBOOT_TIME:-06:00}"
|
REBOOT_TIME="${REBOOT_TIME:-06:00}"
|
||||||
[[ "$REBOOT_TIME" =~ ^([01][0-9]|2[0-3]):[0-5][0-9]$ ]] || die "Invalid time format."
|
[[ "$REBOOT_TIME" =~ ^([01][0-9]|2[0-3]):[0-5][0-9]$ ]] || die "Invalid time format."
|
||||||
|
|
||||||
APP_DIR="$HOME/.local/bin"
|
|
||||||
AUTOSTART_DIR="$HOME/.config/autostart"
|
|
||||||
XORG_CONF_DIR="/etc/X11/xorg.conf.d"
|
|
||||||
LAUNCHER="$APP_DIR/launch-kiosk.sh"
|
|
||||||
DESKTOP_FILE="$AUTOSTART_DIR/launch-kiosk.desktop"
|
|
||||||
CONFIG_FILE="$HOME/.config/kiosk-display.conf"
|
|
||||||
|
|
||||||
mkdir -p "$APP_DIR" "$AUTOSTART_DIR" "$HOME/.config"
|
mkdir -p "$APP_DIR" "$AUTOSTART_DIR" "$HOME/.config"
|
||||||
|
|
||||||
cat > "$CONFIG_FILE" <<EOF
|
cat > "$CONFIG_FILE" <<EOF
|
||||||
@@ -45,11 +68,14 @@ SETUP_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
|||||||
EOF
|
EOF
|
||||||
chmod 600 "$CONFIG_FILE"
|
chmod 600 "$CONFIG_FILE"
|
||||||
|
|
||||||
|
# Quote the URL safely for use in the generated shell script.
|
||||||
|
printf -v URL_Q '%q' "$URL"
|
||||||
|
|
||||||
cat > "$LAUNCHER" <<EOF
|
cat > "$LAUNCHER" <<EOF
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
URL="$URL"
|
URL=$URL_Q
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
rc=\$?
|
rc=\$?
|
||||||
@@ -59,6 +85,18 @@ cleanup() {
|
|||||||
}
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
if ! command -v curl >/dev/null 2>&1; then
|
||||||
|
echo "ERROR: curl is required to check whether the kiosk URL is responding." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Waiting for \$URL to respond..."
|
||||||
|
until curl -fsSL --connect-timeout 5 --max-time 10 "\$URL" -o /dev/null; do
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Kiosk URL is responding; starting Firefox."
|
||||||
|
|
||||||
if command -v xset >/dev/null 2>&1 && [[ -n "\${DISPLAY:-}" ]]; then
|
if command -v xset >/dev/null 2>&1 && [[ -n "\${DISPLAY:-}" ]]; then
|
||||||
xset s off || true
|
xset s off || true
|
||||||
xset -dpms || true
|
xset -dpms || true
|
||||||
@@ -141,4 +179,3 @@ echo "1. Reboot to test autostart: sudo reboot"
|
|||||||
echo "2. Verify Firefox opens in kiosk mode"
|
echo "2. Verify Firefox opens in kiosk mode"
|
||||||
echo "3. Check timer: systemctl list-timers kiosk-daily-reboot.timer"
|
echo "3. Check timer: systemctl list-timers kiosk-daily-reboot.timer"
|
||||||
echo "4. View logs: journalctl -u kiosk-daily-reboot.service -f"
|
echo "4. View logs: journalctl -u kiosk-daily-reboot.service -f"
|
||||||
|
|
||||||
Reference in new issue
Block a user