Refactor setup script to implement step logging for better clarity during execution
This commit is contained in:
parent
b94f80eee7
commit
684b51d7c2
1 changed files with 30 additions and 17 deletions
|
@ -20,14 +20,21 @@ KIOSK_URL="https://example.com"
|
||||||
SIGNAGE_USER="signage"
|
SIGNAGE_USER="signage"
|
||||||
|
|
||||||
# WayVNC Configuration
|
# WayVNC Configuration
|
||||||
# The script will create a ~/.profile for the SIGNAGE_USER
|
|
||||||
# where this variable can be set.
|
|
||||||
# For better security, leave it blank here and edit ~/.profile manually after setup.
|
|
||||||
WAYVNC_PASSWORD_TO_SET="" # Example: "your_secure_password"
|
WAYVNC_PASSWORD_TO_SET="" # Example: "your_secure_password"
|
||||||
WAYVNC_LISTEN_ADDRESS="0.0.0.0" # Listen on all interfaces
|
WAYVNC_LISTEN_ADDRESS="0.0.0.0" # Listen on all interfaces
|
||||||
WAYVNC_PORT="5900" # Default VNC port
|
WAYVNC_PORT="5900" # Default VNC port
|
||||||
# --- End Configuration ---
|
# --- End Configuration ---
|
||||||
|
|
||||||
|
# --- Step Counter ---
|
||||||
|
TOTAL_STEPS=13 # Adjust this if you add/remove major steps
|
||||||
|
CURRENT_STEP=0
|
||||||
|
|
||||||
|
log_step_message() {
|
||||||
|
CURRENT_STEP=$((CURRENT_STEP + 1))
|
||||||
|
echo -e "${BLU}[Step $CURRENT_STEP/$TOTAL_STEPS] $1...${DEF}"
|
||||||
|
}
|
||||||
|
# --- End Step Counter ---
|
||||||
|
|
||||||
echo -e "${BLU}Starting Alpine Linux Signage Setup (Using Sway, greetd, WayVNC)...${DEF}"
|
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}Target URL: ${GRN}$KIOSK_URL${DEF}"
|
||||||
echo -e "${BLU}Signage User: ${GRN}$SIGNAGE_USER${DEF}"
|
echo -e "${BLU}Signage User: ${GRN}$SIGNAGE_USER${DEF}"
|
||||||
|
@ -43,7 +50,7 @@ fi
|
||||||
# 2. Check for 'nomodeset' kernel parameter (early check)
|
# 2. Check for 'nomodeset' kernel parameter (early check)
|
||||||
set +e # Temporarily disable exit-on-error
|
set +e # Temporarily disable exit-on-error
|
||||||
KERNEL_CMDLINE=$(cat /proc/cmdline)
|
KERNEL_CMDLINE=$(cat /proc/cmdline)
|
||||||
echo -e "${BLU}[Step 1/13] Checking kernel command line for 'nomodeset'...${DEF}"
|
log_step_message "Checking kernel command line for 'nomodeset'"
|
||||||
echo "Command line: $KERNEL_CMDLINE"
|
echo "Command line: $KERNEL_CMDLINE"
|
||||||
if echo "$KERNEL_CMDLINE" | grep -q -w 'nomodeset'; then
|
if echo "$KERNEL_CMDLINE" | grep -q -w 'nomodeset'; then
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -62,19 +69,19 @@ set -e # Re-enable exit-on-error
|
||||||
echo "-------------------------------------"
|
echo "-------------------------------------"
|
||||||
|
|
||||||
# 3. Update repositories
|
# 3. Update repositories
|
||||||
echo -e "${BLU}[Step 2/13] Updating package repositories...${DEF}"
|
log_step_message "Updating package repositories"
|
||||||
apk update
|
apk update
|
||||||
echo "-------------------------------------"
|
echo "-------------------------------------"
|
||||||
|
|
||||||
# 4. Setup base Wayland environment (includes enabling community repo)
|
# 4. Setup base Wayland environment (includes enabling community repo)
|
||||||
echo -e "${BLU}[Step 3/13] Setting up base Wayland environment (elogind, eudev)...${DEF}"
|
log_step_message "Setting up base Wayland environment (elogind, eudev)"
|
||||||
apk add --no-cache alpine-conf
|
apk add --no-cache alpine-conf
|
||||||
setup-wayland-base # This enables community repository
|
setup-wayland-base # This enables community repository
|
||||||
echo -e "${GRN}Base Wayland environment setup complete.${DEF}"
|
echo -e "${GRN}Base Wayland environment setup complete.${DEF}"
|
||||||
echo "-------------------------------------"
|
echo "-------------------------------------"
|
||||||
|
|
||||||
# 5. Install necessary packages
|
# 5. Install necessary packages
|
||||||
echo -e "${BLU}[Step 4/13] Installing Sway, Chromium, Mesa, D-Bus, Fonts, Firmware, Greetd, WayVNC, swaybg, open-vm-tools...${DEF}"
|
log_step_message "Installing Sway, Chromium, Mesa, D-Bus, Fonts, Firmware, Greetd, WayVNC, swaybg, open-vm-tools"
|
||||||
apk add \
|
apk add \
|
||||||
sway \
|
sway \
|
||||||
swayidle \
|
swayidle \
|
||||||
|
@ -98,7 +105,7 @@ echo -e "${GRN}Required packages installed.${DEF}"
|
||||||
echo "-------------------------------------"
|
echo "-------------------------------------"
|
||||||
|
|
||||||
# 6. Enable & Start D-Bus service
|
# 6. Enable & Start D-Bus service
|
||||||
echo -e "${BLU}[Step 5/13] Enabling and starting D-Bus service...${DEF}"
|
log_step_message "Enabling and starting D-Bus service"
|
||||||
if ! rc-service dbus status > /dev/null 2>&1; then
|
if ! rc-service dbus status > /dev/null 2>&1; then
|
||||||
rc-update add dbus default
|
rc-update add dbus default
|
||||||
rc-service dbus start
|
rc-service dbus start
|
||||||
|
@ -109,7 +116,7 @@ fi
|
||||||
echo "-------------------------------------"
|
echo "-------------------------------------"
|
||||||
|
|
||||||
# 7. Enable & Start open-vm-tools service (if installed)
|
# 7. Enable & Start open-vm-tools service (if installed)
|
||||||
echo -e "${BLU}[Step 6/13] Enabling and starting open-vm-tools service...${DEF}"
|
log_step_message "Enabling and starting open-vm-tools service"
|
||||||
if apk info --installed open-vm-tools > /dev/null 2>&1; then
|
if apk info --installed open-vm-tools > /dev/null 2>&1; then
|
||||||
if ! rc-service open-vm-tools status > /dev/null 2>&1; then
|
if ! rc-service open-vm-tools status > /dev/null 2>&1; then
|
||||||
echo -e "${BLU}Enabling open-vm-tools service...${DEF}"
|
echo -e "${BLU}Enabling open-vm-tools service...${DEF}"
|
||||||
|
@ -126,10 +133,10 @@ fi
|
||||||
echo "-------------------------------------"
|
echo "-------------------------------------"
|
||||||
|
|
||||||
# 8. Create the signage user and add to necessary groups
|
# 8. Create the signage user and add to necessary groups
|
||||||
echo -e "${BLU}[Step 7/13] Creating signage user '$SIGNAGE_USER' and configuring groups...${DEF}"
|
log_step_message "Creating signage user '$SIGNAGE_USER' and configuring groups"
|
||||||
if ! id -u "$SIGNAGE_USER" >/dev/null 2>&1; then
|
if ! id -u "$SIGNAGE_USER" >/dev/null 2>&1; then
|
||||||
echo -e "${BLU}Creating group '$SIGNAGE_USER' (for primary group)...${DEF}"
|
echo -e "${BLU}Creating group '$SIGNAGE_USER' (for primary group)...${DEF}"
|
||||||
addgroup "$SIGNAGE_USER" # Ensure primary group exists
|
addgroup "$SIGNAGE_USER"
|
||||||
echo -e "${BLU}Creating user '$SIGNAGE_USER' with shell /bin/sh...${DEF}"
|
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"
|
adduser -D -G "$SIGNAGE_USER" -s /bin/sh -h "/home/$SIGNAGE_USER" "$SIGNAGE_USER"
|
||||||
|
|
||||||
|
@ -184,8 +191,9 @@ echo -e "${GRN}User home directory and local share directory configured.${DEF}"
|
||||||
echo "-------------------------------------"
|
echo "-------------------------------------"
|
||||||
|
|
||||||
# 9. Configure user's .profile for WayVNC password and other environment variables
|
# 9. Configure user's .profile for WayVNC password and other environment variables
|
||||||
echo -e "${BLU}[Step 8/13] Configuring $SIGNAGE_HOME/.profile for $SIGNAGE_USER...${DEF}"
|
log_step_message "Configuring $SIGNAGE_HOME/.profile for $SIGNAGE_USER"
|
||||||
SIGNAGE_PROFILE="$SIGNAGE_HOME/.profile"
|
SIGNAGE_PROFILE="$SIGNAGE_HOME/.profile"
|
||||||
|
|
||||||
cat > "$SIGNAGE_PROFILE" << EOF
|
cat > "$SIGNAGE_PROFILE" << EOF
|
||||||
# Profile for $SIGNAGE_USER executed by /bin/sh on login
|
# Profile for $SIGNAGE_USER executed by /bin/sh on login
|
||||||
|
|
||||||
|
@ -213,6 +221,7 @@ cat >> "$SIGNAGE_PROFILE" << EOF
|
||||||
# export SDL_VIDEODRIVER=wayland
|
# export SDL_VIDEODRIVER=wayland
|
||||||
# export _JAVA_AWT_WM_NONREPARENTING=1
|
# export _JAVA_AWT_WM_NONREPARENTING=1
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chown "$SIGNAGE_USER:$SIGNAGE_USER" "$SIGNAGE_PROFILE"
|
chown "$SIGNAGE_USER:$SIGNAGE_USER" "$SIGNAGE_PROFILE"
|
||||||
chmod 600 "$SIGNAGE_PROFILE"
|
chmod 600 "$SIGNAGE_PROFILE"
|
||||||
echo -e "${GRN}$SIGNAGE_PROFILE configured.${DEF}"
|
echo -e "${GRN}$SIGNAGE_PROFILE configured.${DEF}"
|
||||||
|
@ -220,7 +229,7 @@ echo "-------------------------------------"
|
||||||
|
|
||||||
|
|
||||||
# 10. Configure Sway
|
# 10. Configure Sway
|
||||||
echo -e "${BLU}[Step 9/13] Configuring Sway...${DEF}"
|
log_step_message "Configuring Sway"
|
||||||
SIGNAGE_CONFIG_DIR="$SIGNAGE_HOME/.config"
|
SIGNAGE_CONFIG_DIR="$SIGNAGE_HOME/.config"
|
||||||
SIGNAGE_SWAY_CONFIG_DIR="$SIGNAGE_CONFIG_DIR/sway"
|
SIGNAGE_SWAY_CONFIG_DIR="$SIGNAGE_CONFIG_DIR/sway"
|
||||||
SIGNAGE_SWAY_CONFIG_FILE="$SIGNAGE_SWAY_CONFIG_DIR/config"
|
SIGNAGE_SWAY_CONFIG_FILE="$SIGNAGE_SWAY_CONFIG_DIR/config"
|
||||||
|
@ -232,6 +241,7 @@ chmod 700 "$SIGNAGE_CONFIG_DIR"
|
||||||
chmod 700 "$SIGNAGE_SWAY_CONFIG_DIR"
|
chmod 700 "$SIGNAGE_SWAY_CONFIG_DIR"
|
||||||
|
|
||||||
echo -e "${BLU}Creating $SIGNAGE_SWAY_CONFIG_FILE...${DEF}"
|
echo -e "${BLU}Creating $SIGNAGE_SWAY_CONFIG_FILE...${DEF}"
|
||||||
|
|
||||||
cat > "$SIGNAGE_SWAY_CONFIG_FILE" << EOF
|
cat > "$SIGNAGE_SWAY_CONFIG_FILE" << EOF
|
||||||
# Sway configuration for Alpine Signage Kiosk
|
# Sway configuration for Alpine Signage Kiosk
|
||||||
|
|
||||||
|
@ -299,19 +309,21 @@ bindsym \$mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut.
|
||||||
focus_follows_mouse no
|
focus_follows_mouse no
|
||||||
mouse_warping output
|
mouse_warping output
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chown "$SIGNAGE_USER:$SIGNAGE_USER" "$SIGNAGE_SWAY_CONFIG_FILE"
|
chown "$SIGNAGE_USER:$SIGNAGE_USER" "$SIGNAGE_SWAY_CONFIG_FILE"
|
||||||
chmod 600 "$SIGNAGE_SWAY_CONFIG_FILE"
|
chmod 600 "$SIGNAGE_SWAY_CONFIG_FILE"
|
||||||
echo -e "${GRN}Sway configuration file written to $SIGNAGE_SWAY_CONFIG_FILE.${DEF}"
|
echo -e "${GRN}Sway configuration file written to $SIGNAGE_SWAY_CONFIG_FILE.${DEF}"
|
||||||
echo "-------------------------------------"
|
echo "-------------------------------------"
|
||||||
|
|
||||||
# 11. Configure greetd for Autologin and Sway Session
|
# 11. Configure greetd for Autologin and Sway Session
|
||||||
echo -e "${BLU}[Step 10/13] Configuring greetd...${DEF}"
|
log_step_message "Configuring greetd"
|
||||||
GREETD_CONFIG_DIR="/etc/greetd"
|
GREETD_CONFIG_DIR="/etc/greetd"
|
||||||
GREETD_CONFIG_FILE="$GREETD_CONFIG_DIR/config.toml"
|
GREETD_CONFIG_FILE="$GREETD_CONFIG_DIR/config.toml"
|
||||||
|
|
||||||
mkdir -p "$GREETD_CONFIG_DIR"
|
mkdir -p "$GREETD_CONFIG_DIR"
|
||||||
|
|
||||||
SWAY_LOG_PATH_IN_GREETD="$SIGNAGE_LOCAL_SHARE/sway/sway-greetd.log"
|
SWAY_LOG_PATH_IN_GREETD="$SIGNAGE_LOCAL_SHARE/sway/sway-greetd.log"
|
||||||
|
|
||||||
cat > "$GREETD_CONFIG_FILE" << EOF
|
cat > "$GREETD_CONFIG_FILE" << EOF
|
||||||
# Greetd configuration for signage kiosk with Sway
|
# Greetd configuration for signage kiosk with Sway
|
||||||
|
|
||||||
|
@ -326,13 +338,14 @@ command = "/usr/bin/dbus-run-session /usr/bin/sway -V -d 2> $SWAY_LOG_PATH_IN_GR
|
||||||
# Simpler alternative if log redirection is problematic (logs go to greetd's output):
|
# Simpler alternative if log redirection is problematic (logs go to greetd's output):
|
||||||
# command = "/usr/bin/dbus-run-session /usr/bin/sway"
|
# command = "/usr/bin/dbus-run-session /usr/bin/sway"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod 644 "$GREETD_CONFIG_FILE"
|
chmod 644 "$GREETD_CONFIG_FILE"
|
||||||
echo -e "${GRN}greetd config written to $GREETD_CONFIG_FILE.${DEF}"
|
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 -e "${BLU}Ensure $SIGNAGE_USER can write to $SWAY_LOG_PATH_IN_GREETD.${DEF}"
|
||||||
echo "-------------------------------------"
|
echo "-------------------------------------"
|
||||||
|
|
||||||
# 12. Configure inittab to start greetd
|
# 12. Configure inittab to start greetd
|
||||||
echo -e "${BLU}[Step 11/13] Configuring autologin via greetd in /etc/inittab...${DEF}"
|
log_step_message "Configuring autologin via greetd in /etc/inittab"
|
||||||
if [ -f "/etc/inittab" ]; then
|
if [ -f "/etc/inittab" ]; then
|
||||||
if [ ! -f "/etc/inittab.bak.signage" ]; then
|
if [ ! -f "/etc/inittab.bak.signage" ]; then
|
||||||
cp /etc/inittab /etc/inittab.bak.signage
|
cp /etc/inittab /etc/inittab.bak.signage
|
||||||
|
@ -359,7 +372,7 @@ fi
|
||||||
echo "-------------------------------------"
|
echo "-------------------------------------"
|
||||||
|
|
||||||
# 13. Attempt to Enable elogind PAM module for session management
|
# 13. Attempt to Enable elogind PAM module for session management
|
||||||
echo -e "${BLU}[Step 12/13] Attempting to configure PAM for elogind session...${DEF}"
|
log_step_message "Attempting to configure PAM for elogind session"
|
||||||
PAM_GREETD_FILE="/etc/pam.d/greetd"
|
PAM_GREETD_FILE="/etc/pam.d/greetd"
|
||||||
PAM_SYSTEM_LOGIN="/etc/pam.d/system-login"
|
PAM_SYSTEM_LOGIN="/etc/pam.d/system-login"
|
||||||
PAM_SYSTEM_AUTH="/etc/pam.d/system-auth"
|
PAM_SYSTEM_AUTH="/etc/pam.d/system-auth"
|
||||||
|
@ -397,7 +410,7 @@ else
|
||||||
fi
|
fi
|
||||||
echo "-------------------------------------"
|
echo "-------------------------------------"
|
||||||
|
|
||||||
echo -e "${BLU}[Step 13/13] Final checks and information.${DEF}"
|
log_step_message "Final checks and information"
|
||||||
echo -e "${GRN}-----------------------------------------------------${DEF}"
|
echo -e "${GRN}-----------------------------------------------------${DEF}"
|
||||||
echo -e "${GRN} Alpine Linux Signage Setup Script Finished! ${DEF}"
|
echo -e "${GRN} Alpine Linux Signage Setup Script Finished! ${DEF}"
|
||||||
echo -e "${GRN}-----------------------------------------------------${DEF}"
|
echo -e "${GRN}-----------------------------------------------------${DEF}"
|
||||||
|
|
Loading…
Reference in a new issue