Enhance setup script: improve output formatting with color codes, add warnings for 'nomodeset', and refine user creation messages

This commit is contained in:
FallingLights 2025-05-07 19:54:58 +02:00
parent 3d78640e5d
commit b94f80eee7

View file

@ -4,6 +4,14 @@
# We disable this ('+e') temporarily during the nomodeset check.
set -u
# --- Color Definitions ---
RED='\e[1;31m'
BLU='\e[1;34m'
GRN='\e[1;32m'
YLW='\e[1;33m'
DEF='\e[0m'
# --- End Color Definitions ---
# --- Configuration ---
# Set the URL you want the signage to display
KIOSK_URL="https://example.com"
@ -20,52 +28,53 @@ WAYVNC_LISTEN_ADDRESS="0.0.0.0" # Listen on all interfaces
WAYVNC_PORT="5900" # Default VNC port
# --- End Configuration ---
echo "Starting Alpine Linux Signage Setup (Using Sway, greetd, WayVNC)..."
echo "Target URL: $KIOSK_URL"
echo "Signage User: $SIGNAGE_USER"
echo "WayVNC will listen on: $WAYVNC_LISTEN_ADDRESS:$WAYVNC_PORT"
echo -e "${BLU}Starting Alpine Linux Signage Setup (Using Sway, greetd, WayVNC)...${DEF}"
echo -e "${BLU}Target URL: ${GRN}$KIOSK_URL${DEF}"
echo -e "${BLU}Signage User: ${GRN}$SIGNAGE_USER${DEF}"
echo -e "${BLU}WayVNC will listen on: ${GRN}$WAYVNC_LISTEN_ADDRESS:$WAYVNC_PORT${DEF}"
echo "-------------------------------------"
# 1. Check if running as root
if [ "$(id -u)" -ne 0 ]; then
echo "ERROR: This script must be run as root" 1>&2
echo -e "${RED}ERROR: This script must be run as root${DEF}" 1>&2
exit 1
fi
# 2. Check for 'nomodeset' kernel parameter (early check)
set +e # Temporarily disable exit-on-error
KERNEL_CMDLINE=$(cat /proc/cmdline)
echo "[Step 1/13] Checking kernel command line for 'nomodeset'..."
echo -e "${BLU}[Step 1/13] Checking kernel command line for 'nomodeset'...${DEF}"
echo "Command line: $KERNEL_CMDLINE"
if echo "$KERNEL_CMDLINE" | grep -q -w 'nomodeset'; then
echo ""
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "!! WARNING: Kernel parameter 'nomodeset' detected in /proc/cmdline!"
echo "!! This PREVENTS Wayland compositors (like Sway) from working correctly with DRM."
echo "!! You MUST remove 'nomodeset' from your bootloader configuration"
echo "!! (e.g., /etc/default/grub or /boot/extlinux.conf) and update/reboot"
echo "!! for the graphical kiosk to function."
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo -e "${RED}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!${DEF}"
echo -e "${RED}!! ${YLW}WARNING: Kernel parameter 'nomodeset' detected in /proc/cmdline! ${RED}!!${DEF}"
echo -e "${RED}!! ${YLW}This PREVENTS Wayland compositors (like Sway) from working correctly with DRM.${RED}!!${DEF}"
echo -e "${RED}!! ${YLW}You MUST remove 'nomodeset' from your bootloader configuration ${RED}!!${DEF}"
echo -e "${RED}!! ${YLW}(e.g., /etc/default/grub or /boot/extlinux.conf) and update/reboot ${RED}!!${DEF}"
echo -e "${RED}!! ${YLW}for the graphical kiosk to function. ${RED}!!${DEF}"
echo -e "${RED}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!${DEF}"
echo ""
else
echo "'nomodeset' not found. Proceeding..."
echo -e "${GRN}'nomodeset' not found. Proceeding...${DEF}"
fi
set -e # Re-enable exit-on-error
echo "-------------------------------------"
# 3. Update repositories
echo "[Step 2/13] Updating package repositories..."
echo -e "${BLU}[Step 2/13] Updating package repositories...${DEF}"
apk update
echo "-------------------------------------"
# 4. Setup base Wayland environment (includes enabling community repo)
echo "[Step 3/13] Setting up base Wayland environment (elogind, eudev)..."
echo -e "${BLU}[Step 3/13] Setting up base Wayland environment (elogind, eudev)...${DEF}"
apk add --no-cache alpine-conf
setup-wayland-base # This enables community repository
echo -e "${GRN}Base Wayland environment setup complete.${DEF}"
echo "-------------------------------------"
# 5. Install necessary packages
echo "[Step 4/13] Installing Sway, Chromium, Mesa, D-Bus, Fonts, Firmware, Greetd, WayVNC, swaybg, open-vm-tools..."
echo -e "${BLU}[Step 4/13] Installing Sway, Chromium, Mesa, D-Bus, Fonts, Firmware, Greetd, WayVNC, swaybg, open-vm-tools...${DEF}"
apk add \
sway \
swayidle \
@ -84,101 +93,98 @@ apk add \
greetd \
greetd-agreety \
wayvnc \
open-vm-tools # open-vm-tools-desktop has been removed
open-vm-tools
echo -e "${GRN}Required packages installed.${DEF}"
echo "-------------------------------------"
# 6. Enable & Start D-Bus service
echo "[Step 5/13] Enabling and starting D-Bus service..."
echo -e "${BLU}[Step 5/13] Enabling and starting D-Bus service...${DEF}"
if ! rc-service dbus status > /dev/null 2>&1; then
rc-update add dbus default
rc-service dbus start
echo -e "${GRN}D-Bus service enabled and started.${DEF}"
else
echo "D-Bus service already running or enabled."
echo -e "${GRN}D-Bus service already running or enabled.${DEF}"
fi
echo "-------------------------------------"
# 7. Enable & Start open-vm-tools service (if installed)
echo "[Step 6/13] Enabling and starting open-vm-tools service..."
echo -e "${BLU}[Step 6/13] Enabling and starting open-vm-tools service...${DEF}"
if apk info --installed open-vm-tools > /dev/null 2>&1; then
if ! rc-service open-vm-tools status > /dev/null 2>&1; then
echo "Enabling open-vm-tools service..."
echo -e "${BLU}Enabling open-vm-tools service...${DEF}"
rc-update add open-vm-tools default
echo "Starting open-vm-tools service..."
echo -e "${BLU}Starting open-vm-tools service...${DEF}"
rc-service open-vm-tools start
echo -e "${GRN}open-vm-tools service enabled and started.${DEF}"
else
echo "open-vm-tools service already running or enabled."
echo -e "${GRN}open-vm-tools service already running or enabled.${DEF}"
fi
else
echo "open-vm-tools not installed, skipping service setup."
echo -e "${YLW}open-vm-tools not installed, skipping service setup.${DEF}"
fi
echo "-------------------------------------"
# 8. Create the signage user and add to necessary groups
echo "[Step 7/13] Creating signage user '$SIGNAGE_USER' and configuring groups..."
echo -e "${BLU}[Step 7/13] Creating signage user '$SIGNAGE_USER' and configuring groups...${DEF}"
if ! id -u "$SIGNAGE_USER" >/dev/null 2>&1; then
echo "Creating group '$SIGNAGE_USER' (for primary group)..."
echo -e "${BLU}Creating group '$SIGNAGE_USER' (for primary group)...${DEF}"
addgroup "$SIGNAGE_USER" # Ensure primary group exists
echo "Creating user '$SIGNAGE_USER' with shell /bin/sh..."
# -D: no password, don't expire
# -G group: add user to primary group 'group'. Uses existing or creates if not.
echo -e "${BLU}Creating user '$SIGNAGE_USER' with shell /bin/sh...${DEF}"
adduser -D -G "$SIGNAGE_USER" -s /bin/sh -h "/home/$SIGNAGE_USER" "$SIGNAGE_USER"
echo "Adding user '$SIGNAGE_USER' to 'video' supplementary group..."
echo -e "${BLU}Adding user '$SIGNAGE_USER' to 'video' supplementary group...${DEF}"
addgroup "$SIGNAGE_USER" video
echo "Adding user '$SIGNAGE_USER' to 'input' supplementary group..."
echo -e "${BLU}Adding user '$SIGNAGE_USER' to 'input' supplementary group...${DEF}"
addgroup "$SIGNAGE_USER" input
echo "User '$SIGNAGE_USER' created and added to video/input groups."
echo -e "${GRN}User '$SIGNAGE_USER' created and added to video/input groups.${DEF}"
else
echo "User '$SIGNAGE_USER' already exists. Ensuring shell is /bin/sh and group memberships..."
echo -e "${YLW}User '$SIGNAGE_USER' already exists. Ensuring shell is /bin/sh and group memberships...${DEF}"
usermod -s /bin/sh "$SIGNAGE_USER"
# Ensure primary group exists (original script's safeguard)
if ! getent group "$SIGNAGE_USER" >/dev/null 2>&1; then
echo "Primary group '$SIGNAGE_USER' not found, creating it."
echo -e "${BLU}Primary group '$SIGNAGE_USER' not found, creating it.${DEF}"
addgroup "$SIGNAGE_USER"
# If primary group was missing, ensure user is member.
# This typically means user's GID needs to be updated with usermod -g if primary group was truly lost and recreated.
# For now, just ensuring membership in the group by name.
if ! groups "$SIGNAGE_USER" | grep -q -w "$SIGNAGE_USER"; then
addgroup "$SIGNAGE_USER" "$SIGNAGE_USER"
fi
fi
echo "Ensuring $SIGNAGE_USER is in 'video' supplementary group..."
echo -e "${BLU}Ensuring $SIGNAGE_USER is in 'video' supplementary group...${DEF}"
if ! groups "$SIGNAGE_USER" | grep -q -w video; then
addgroup "$SIGNAGE_USER" video
echo "$SIGNAGE_USER added to 'video'."
echo -e "${GRN}$SIGNAGE_USER added to 'video'.${DEF}"
else
echo "$SIGNAGE_USER already in 'video'."
echo -e "${GRN}$SIGNAGE_USER already in 'video'.${DEF}"
fi
echo "Ensuring $SIGNAGE_USER is in 'input' supplementary group..."
echo -e "${BLU}Ensuring $SIGNAGE_USER is in 'input' supplementary group...${DEF}"
if ! groups "$SIGNAGE_USER" | grep -q -w input; then
addgroup "$SIGNAGE_USER" input
echo "$SIGNAGE_USER added to 'input'."
echo -e "${GRN}$SIGNAGE_USER added to 'input'.${DEF}"
else
echo "$SIGNAGE_USER already in 'input'."
echo -e "${GRN}$SIGNAGE_USER already in 'input'.${DEF}"
fi
fi
SIGNAGE_HOME="/home/$SIGNAGE_USER"
if [ ! -d "$SIGNAGE_HOME" ]; then
echo "Creating home directory '$SIGNAGE_HOME'..."
echo -e "${BLU}Creating home directory '$SIGNAGE_HOME'...${DEF}"
mkdir -p "$SIGNAGE_HOME"
fi
chown "$SIGNAGE_USER:$SIGNAGE_USER" "$SIGNAGE_HOME"
chmod 750 "$SIGNAGE_HOME"
# Create user's .local/share directory for logs
SIGNAGE_LOCAL_SHARE="$SIGNAGE_HOME/.local/share"
mkdir -p "$SIGNAGE_LOCAL_SHARE/sway" # For sway logs
mkdir -p "$SIGNAGE_LOCAL_SHARE/sway"
chown -R "$SIGNAGE_USER:$SIGNAGE_USER" "$SIGNAGE_HOME/.local"
chmod 700 "$SIGNAGE_HOME/.local" # Restrict access
chmod 700 "$SIGNAGE_HOME/.local"
chmod 700 "$SIGNAGE_LOCAL_SHARE"
chmod 700 "$SIGNAGE_LOCAL_SHARE/sway"
echo -e "${GRN}User home directory and local share directory configured.${DEF}"
echo "-------------------------------------"
# 9. Configure user's .profile for WayVNC password and other environment variables
echo "[Step 8/13] Configuring $SIGNAGE_HOME/.profile for $SIGNAGE_USER..."
echo -e "${BLU}[Step 8/13] Configuring $SIGNAGE_HOME/.profile for $SIGNAGE_USER...${DEF}"
SIGNAGE_PROFILE="$SIGNAGE_HOME/.profile"
cat > "$SIGNAGE_PROFILE" << EOF
# Profile for $SIGNAGE_USER executed by /bin/sh on login
@ -191,9 +197,9 @@ EOF
if [ -n "$WAYVNC_PASSWORD_TO_SET" ]; then
echo "export WAYVNC_PASSWORD=\"$WAYVNC_PASSWORD_TO_SET\"" >> "$SIGNAGE_PROFILE"
echo "WAYVNC_PASSWORD has been pre-set in $SIGNAGE_PROFILE. Review for security."
echo -e "${YLW}WAYVNC_PASSWORD has been pre-set in $SIGNAGE_PROFILE. Review for security.${DEF}"
else
echo "INFO: WAYVNC_PASSWORD is not set. Edit $SIGNAGE_PROFILE to set it for WayVNC security."
echo -e "${YLW}INFO: WAYVNC_PASSWORD is not set. Edit $SIGNAGE_PROFILE to set it for WayVNC security.${DEF}"
fi
cat >> "$SIGNAGE_PROFILE" << EOF
@ -208,23 +214,24 @@ cat >> "$SIGNAGE_PROFILE" << EOF
# export _JAVA_AWT_WM_NONREPARENTING=1
EOF
chown "$SIGNAGE_USER:$SIGNAGE_USER" "$SIGNAGE_PROFILE"
chmod 600 "$SIGNAGE_PROFILE" # User read/write only
chmod 600 "$SIGNAGE_PROFILE"
echo -e "${GRN}$SIGNAGE_PROFILE configured.${DEF}"
echo "-------------------------------------"
# 10. Configure Sway
echo "[Step 9/13] Configuring Sway..."
echo -e "${BLU}[Step 9/13] Configuring Sway...${DEF}"
SIGNAGE_CONFIG_DIR="$SIGNAGE_HOME/.config"
SIGNAGE_SWAY_CONFIG_DIR="$SIGNAGE_CONFIG_DIR/sway"
SIGNAGE_SWAY_CONFIG_FILE="$SIGNAGE_SWAY_CONFIG_DIR/config"
echo "Creating Sway configuration directories..."
echo -e "${BLU}Creating Sway configuration directories...${DEF}"
mkdir -p "$SIGNAGE_SWAY_CONFIG_DIR"
chown -R "$SIGNAGE_USER:$SIGNAGE_USER" "$SIGNAGE_CONFIG_DIR" || true
chmod 700 "$SIGNAGE_CONFIG_DIR" # Restrict access
chmod 700 "$SIGNAGE_CONFIG_DIR"
chmod 700 "$SIGNAGE_SWAY_CONFIG_DIR"
echo "Creating $SIGNAGE_SWAY_CONFIG_FILE..."
echo -e "${BLU}Creating $SIGNAGE_SWAY_CONFIG_FILE...${DEF}"
cat > "$SIGNAGE_SWAY_CONFIG_FILE" << EOF
# Sway configuration for Alpine Signage Kiosk
@ -293,11 +300,12 @@ focus_follows_mouse no
mouse_warping output
EOF
chown "$SIGNAGE_USER:$SIGNAGE_USER" "$SIGNAGE_SWAY_CONFIG_FILE"
chmod 600 "$SIGNAGE_SWAY_CONFIG_FILE" # User read/write only
chmod 600 "$SIGNAGE_SWAY_CONFIG_FILE"
echo -e "${GRN}Sway configuration file written to $SIGNAGE_SWAY_CONFIG_FILE.${DEF}"
echo "-------------------------------------"
# 11. Configure greetd for Autologin and Sway Session
echo "[Step 10/13] Configuring greetd..."
echo -e "${BLU}[Step 10/13] Configuring greetd...${DEF}"
GREETD_CONFIG_DIR="/etc/greetd"
GREETD_CONFIG_FILE="$GREETD_CONFIG_DIR/config.toml"
@ -319,38 +327,39 @@ command = "/usr/bin/dbus-run-session /usr/bin/sway -V -d 2> $SWAY_LOG_PATH_IN_GR
# command = "/usr/bin/dbus-run-session /usr/bin/sway"
EOF
chmod 644 "$GREETD_CONFIG_FILE"
echo "greetd config written to $GREETD_CONFIG_FILE"
echo "Ensure $SIGNAGE_USER can write to $SWAY_LOG_PATH_IN_GREETD."
echo -e "${GRN}greetd config written to $GREETD_CONFIG_FILE.${DEF}"
echo -e "${BLU}Ensure $SIGNAGE_USER can write to $SWAY_LOG_PATH_IN_GREETD.${DEF}"
echo "-------------------------------------"
# 12. Configure inittab to start greetd
echo "[Step 11/13] Configuring autologin via greetd in /etc/inittab..."
echo -e "${BLU}[Step 11/13] Configuring autologin via greetd in /etc/inittab...${DEF}"
if [ -f "/etc/inittab" ]; then
if [ ! -f "/etc/inittab.bak.signage" ]; then # Create backup only once
if [ ! -f "/etc/inittab.bak.signage" ]; then
cp /etc/inittab /etc/inittab.bak.signage
echo "Backed up /etc/inittab to /etc/inittab.bak.signage"
echo -e "${GRN}Backed up /etc/inittab to /etc/inittab.bak.signage${DEF}"
fi
echo "Commenting out ttys 2-6 in /etc/inittab..."
echo -e "${BLU}Commenting out ttys 2-6 in /etc/inittab...${DEF}"
sed -i -e '/^tty[2-6]:/s/^/#/' /etc/inittab
echo "Modifying tty1 entry in /etc/inittab to start greetd..."
echo -e "${BLU}Modifying tty1 entry in /etc/inittab to start greetd...${DEF}"
GREETD_INITTAB_LINE="tty1::respawn:/usr/sbin/greetd"
if grep -q "^tty1::respawn:" /etc/inittab && ! grep -Fxq "$GREETD_INITTAB_LINE" /etc/inittab; then
sed -i "s|^tty1::respawn:.*|$GREETD_INITTAB_LINE|" /etc/inittab
echo -e "${GRN}tty1 entry modified for greetd.${DEF}"
elif ! grep -Fxq "$GREETD_INITTAB_LINE" /etc/inittab; then
echo "$GREETD_INITTAB_LINE" >> /etc/inittab
echo "Added greetd line to /etc/inittab (fallback)."
echo -e "${GRN}Added greetd line to /etc/inittab (fallback).${DEF}"
else
echo "greetd line already seems to be present in /etc/inittab."
echo -e "${GRN}greetd line already seems to be present in /etc/inittab.${DEF}"
fi
else
echo "Warning: /etc/inittab not found. Cannot configure greetd startup for sysvinit."
echo -e "${RED}Warning: /etc/inittab not found. Cannot configure greetd startup for sysvinit.${DEF}"
fi
echo "-------------------------------------"
# 13. Attempt to Enable elogind PAM module for session management
echo "[Step 12/13] Attempting to configure PAM for elogind session..."
echo -e "${BLU}[Step 12/13] Attempting to configure PAM for elogind session...${DEF}"
PAM_GREETD_FILE="/etc/pam.d/greetd"
PAM_SYSTEM_LOGIN="/etc/pam.d/system-login"
PAM_SYSTEM_AUTH="/etc/pam.d/system-auth"
@ -366,77 +375,76 @@ elif [ -f "$PAM_SYSTEM_AUTH" ]; then
fi
if [ -n "$PAM_TARGET_FILE" ]; then
echo "Using $PAM_TARGET_FILE for PAM configuration."
echo -e "${BLU}Using $PAM_TARGET_FILE for PAM configuration.${DEF}"
if ! grep -q "$PAM_MODULE" "$PAM_TARGET_FILE"; then
echo "Adding '$PAM_MODULE' to $PAM_TARGET_FILE..."
echo -e "${BLU}Adding '$PAM_MODULE' to $PAM_TARGET_FILE...${DEF}"
if [ ! -f "$PAM_TARGET_FILE.bak.signage" ]; then
cp "$PAM_TARGET_FILE" "$PAM_TARGET_FILE.bak.signage"
echo "Backed up $PAM_TARGET_FILE to $PAM_TARGET_FILE.bak.signage"
echo -e "${GRN}Backed up $PAM_TARGET_FILE to $PAM_TARGET_FILE.bak.signage${DEF}"
fi
# Add pam_elogind.so after the first 'session' line, or as the first session line if none exist
if grep -q "^session" "$PAM_TARGET_FILE"; then
awk '/^session/{if(!p++) print; print "session optional pam_elogind.so"; next} 1' "$PAM_TARGET_FILE" > "$PAM_TARGET_FILE.tmp" && mv "$PAM_TARGET_FILE.tmp" "$PAM_TARGET_FILE"
else
echo "session optional pam_elogind.so" >> "$PAM_TARGET_FILE" # Fallback if no session lines
echo "session optional pam_elogind.so" >> "$PAM_TARGET_FILE"
fi
echo "PAM module added."
echo -e "${GRN}PAM module added.${DEF}"
else
echo "'$PAM_MODULE' already present in $PAM_TARGET_FILE."
echo -e "${GRN}'$PAM_MODULE' already present in $PAM_TARGET_FILE.${DEF}"
fi
else
echo "Warning: Could not find suitable PAM file (greetd, system-login, system-auth) to modify."
echo " System relies on default PAM includes for elogind session setup."
echo -e "${RED}Warning: Could not find suitable PAM file (greetd, system-login, system-auth) to modify.${DEF}"
echo -e "${YLW} System relies on default PAM includes for elogind session setup.${DEF}"
fi
echo "-------------------------------------"
echo "[Step 13/13] Final checks and information."
echo "-----------------------------------------------------"
echo " Alpine Linux Signage Setup Script Finished!"
echo "-----------------------------------------------------"
echo " SUMMARY:"
echo " * Packages installed (Sway, Chromium, Greetd, WayVNC, open-vm-tools etc.)."
echo " * User '$SIGNAGE_USER' created/configured with shell /bin/sh and added to 'video' and 'input' groups."
echo " * Sway configured in $SIGNAGE_SWAY_CONFIG_FILE."
echo " -> Output explicitly enabled, power state set to ON."
echo " -> Chromium will start with --disable-gpu. Edit this file to change."
echo " -> Mouse cursor configured to hide after 1s inactivity."
echo " * WayVNC configured to launch via Sway, listening on $WAYVNC_LISTEN_ADDRESS:$WAYVNC_PORT."
echo " * IMPORTANT: WayVNC password MUST be set in $SIGNAGE_PROFILE for security."
echo " * Autologin configured via greetd ($GREETD_CONFIG_FILE)."
echo " * /etc/inittab modified to launch greetd on tty1."
echo " * Attempted to configure PAM for elogind."
echo " * open-vm-tools service enabled (if applicable, open-vm-tools-desktop was NOT installed)."
echo -e "${BLU}[Step 13/13] Final checks and information.${DEF}"
echo -e "${GRN}-----------------------------------------------------${DEF}"
echo -e "${GRN} Alpine Linux Signage Setup Script Finished! ${DEF}"
echo -e "${GRN}-----------------------------------------------------${DEF}"
echo -e "${BLU} SUMMARY:${DEF}"
echo -e " ${GRN}* Packages installed (Sway, Chromium, Greetd, WayVNC, open-vm-tools etc.).${DEF}"
echo -e " ${GRN}* User '$SIGNAGE_USER' created/configured with shell /bin/sh and added to 'video' and 'input' groups.${DEF}"
echo -e " ${GRN}* Sway configured in $SIGNAGE_SWAY_CONFIG_FILE.${DEF}"
echo -e " ${BLU}-> Output explicitly enabled, power state set to ON.${DEF}"
echo -e " ${BLU}-> Chromium will start with --disable-gpu. Edit this file to change.${DEF}"
echo -e " ${BLU}-> Mouse cursor configured to hide after 1s inactivity.${DEF}"
echo -e " ${GRN}* WayVNC configured to launch via Sway, listening on $WAYVNC_LISTEN_ADDRESS:$WAYVNC_PORT.${DEF}"
echo -e " ${YLW}* IMPORTANT: WayVNC password MUST be set in $SIGNAGE_PROFILE for security.${DEF}"
echo -e " ${GRN}* Autologin configured via greetd ($GREETD_CONFIG_FILE).${DEF}"
echo -e " ${GRN}* /etc/inittab modified to launch greetd on tty1.${DEF}"
echo -e " ${GRN}* Attempted to configure PAM for elogind.${DEF}"
echo -e " ${GRN}* open-vm-tools service enabled (if applicable, open-vm-tools-desktop was NOT installed).${DEF}"
echo ""
echo " !!! IMPORTANT !!!"
echo " * If you saw a WARNING about 'nomodeset' earlier, the graphical kiosk"
echo " WILL NOT WORK until you remove 'nomodeset' from your bootloader config and reboot."
echo " * For WayVNC to be secure, you MUST set a strong WAYVNC_PASSWORD"
echo " in $SIGNAGE_HOME/.profile for the user $SIGNAGE_USER."
echo " Example: echo 'export WAYVNC_PASSWORD=\"your_secure_password\"' >> $SIGNAGE_HOME/.profile"
echo " * Chromium is launched with --disable-gpu. If you have working 3D acceleration"
echo " (especially on bare metal or with robust VM drivers), you can try removing"
echo " this flag from $SIGNAGE_SWAY_CONFIG_FILE for better performance."
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo -e "${RED} !!! IMPORTANT !!!${DEF}"
echo -e " ${RED}* If you saw a WARNING about 'nomodeset' earlier, the graphical kiosk${DEF}"
echo -e " ${RED}WILL NOT WORK until you remove 'nomodeset' from your bootloader config and reboot.${DEF}"
echo -e " ${RED}* For WayVNC to be secure, you MUST set a strong WAYVNC_PASSWORD${DEF}"
echo -e " ${RED}in $SIGNAGE_HOME/.profile for the user $SIGNAGE_USER.${DEF}"
echo -e " ${YLW}Example: echo 'export WAYVNC_PASSWORD=\"your_secure_password\"' >> $SIGNAGE_HOME/.profile${DEF}"
echo -e " ${YLW}* Chromium is launched with --disable-gpu. If you have working 3D acceleration${DEF}"
echo -e " ${YLW}(especially on bare metal or with robust VM drivers), you can try removing${DEF}"
echo -e " ${YLW}this flag from $SIGNAGE_SWAY_CONFIG_FILE for better performance.${DEF}"
echo -e "${RED}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!${DEF}"
echo ""
echo " Please REBOOT the system for changes to take effect."
echo " Command: reboot"
echo -e "${GRN} Please REBOOT the system for changes to take effect.${DEF}"
echo -e "${GRN} Command: ${YLW}reboot${DEF}"
echo ""
echo " TROUBLESHOOTING AFTER REBOOT (if it doesn't work):"
echo " 1. Log in as root on TTY2 (Alt+F2) or SSH."
echo " 2. Check greetd logs: grep greetd /var/log/messages | tail -n 20"
echo " 3. Check Sway log: cat $SWAY_LOG_PATH_IN_GREETD"
echo " 4. Check Sway config syntax (as root, or as user if paths adjusted):"
echo " su - $SIGNAGE_USER -c \"export XDG_RUNTIME_DIR=/run/user/\$(id -u $SIGNAGE_USER) && sway -C -c $SIGNAGE_SWAY_CONFIG_FILE\""
echo " 5. Check XDG_RUNTIME_DIR: ls -ld /run/user/\$(id -u $SIGNAGE_USER)"
echo " 6. Check services: rc-service elogind status && rc-service dbus status && rc-service open-vm-tools status"
echo " 7. Check inittab: grep ^tty1 /etc/inittab"
echo " 8. Check dmesg: dmesg | tail -n 50"
echo " 9. Verify Chromium flags in: cat $SIGNAGE_SWAY_CONFIG_FILE"
echo "10. Check WayVNC: ps aux | grep wayvnc ; netstat -tulnp | grep :$WAYVNC_PORT"
echo " Ensure WAYVNC_PASSWORD is set in $SIGNAGE_PROFILE"
echo "11. Manually test Sway as $SIGNAGE_USER on TTY2 (stop greetd first: rc-service greetd stop):"
echo " su - $SIGNAGE_USER -c \"dbus-run-session sway -d\""
echo "12. Check user groups: groups $SIGNAGE_USER (should include 'video' and 'input')"
echo "-----------------------------------------------------"
echo -e "${BLU} TROUBLESHOOTING AFTER REBOOT (if it doesn't work):${DEF}"
echo -e " ${BLU}1. Log in as root on TTY2 (Alt+F2) or SSH.${DEF}"
echo -e " ${BLU}2. Check greetd logs: ${GRN}grep greetd /var/log/messages | tail -n 20${DEF}"
echo -e " ${BLU}3. Check Sway log: ${GRN}cat $SWAY_LOG_PATH_IN_GREETD${DEF}"
echo -e " ${BLU}4. Check Sway config syntax (as root, or as user if paths adjusted):${DEF}"
echo -e " ${GRN}su - $SIGNAGE_USER -c \"export XDG_RUNTIME_DIR=/run/user/\$(id -u $SIGNAGE_USER) && sway -C -c $SIGNAGE_SWAY_CONFIG_FILE\"${DEF}"
echo -e " ${BLU}5. Check XDG_RUNTIME_DIR: ${GRN}ls -ld /run/user/\$(id -u $SIGNAGE_USER)${DEF}"
echo -e " ${BLU}6. Check services: ${GRN}rc-service elogind status && rc-service dbus status && rc-service open-vm-tools status${DEF}"
echo -e " ${BLU}7. Check inittab: ${GRN}grep ^tty1 /etc/inittab${DEF}"
echo -e " ${BLU}8. Check dmesg: ${GRN}dmesg | tail -n 50${DEF}"
echo -e " ${BLU}9. Verify Chromium flags in: ${GRN}cat $SIGNAGE_SWAY_CONFIG_FILE${DEF}"
echo -e " ${BLU}10. Check WayVNC: ${GRN}ps aux | grep wayvnc ; netstat -tulnp | grep :$WAYVNC_PORT${DEF}"
echo -e " ${YLW}Ensure WAYVNC_PASSWORD is set in $SIGNAGE_PROFILE${DEF}"
echo -e " ${BLU}11. Manually test Sway as $SIGNAGE_USER on TTY2 (stop greetd first: rc-service greetd stop):${DEF}"
echo -e " ${GRN}su - $SIGNAGE_USER -c \"dbus-run-session sway -d\"${DEF}"
echo -e " ${BLU}12. Check user groups: ${GRN}groups $SIGNAGE_USER${YLW} (should include 'video' and 'input')${DEF}"
echo -e "${GRN}-----------------------------------------------------${DEF}"
exit 0