From 6173adc152c70ce26de07a12d2ec177c127fd3ae Mon Sep 17 00:00:00 2001 From: Kablersalat Date: Mon, 24 Feb 2025 19:18:18 +0100 Subject: attempt at fixing auto installer --- installer.sh | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/installer.sh b/installer.sh index 3c89be3..6c416be 100644 --- a/installer.sh +++ b/installer.sh @@ -71,9 +71,9 @@ EOF" # Function to configure start.sh with dynamic scaling factor for interactive or automated mode configure_start_sh() { - SCALE_FACTOR=$(dialog --title "Display Scaling Factor" --inputbox "Enter the display scaling factor (e.g., 1 for 1080p, 2 for 4K):" 8 50 "1" 3>&1 1>&2 2>&3 3>&-) - if [[ $# -eq 0 ]]; then # If no arguments, it's interactive mode + SCALE_FACTOR=$(dialog --title "Display Scaling Factor" --inputbox "Enter the display scaling factor (e.g., 1 for 1080p, 2 for 4K):" 8 50 "1" 3>&1 1>&2 2>&3 3>&-) + DIALOG_RESULT=$(dialog --title "start.sh Configuration" --menu "Choose the script example:" 15 50 2 \ 1 "Simple website script" \ 2 "Two or more tabs alternating every 30 seconds" \ @@ -92,26 +92,32 @@ configure_start_sh() { configure_tabs $SCALE_FACTOR "${tab_urls[@]}" fi else # Automated mode with URLs as arguments + local scaling_factor=$1 + local vnc_password=$2 + shift 2 # Remove the first two arguments (scaling factor and VNC password) for URLs if [ $# -eq 1 ]; then # Single website - set_start_script_single $SCALE_FACTOR $1 + set_start_script_single $scaling_factor $1 $vnc_password else # Multiple tabs - configure_tabs $SCALE_FACTOR "$@" + configure_tabs $scaling_factor $vnc_password "$@" fi fi } # Helper function to configure start.sh for a single website set_start_script_single() { - VNC_PASSWORD=$(dialog --title "VNC Password" --inputbox "Please enter the VNC password:" 8 50 "" 3>&1 1>&2 2>&3 3>&-) + local scaling_factor=$1 + local website=$2 + local vnc_password=$3 + mkdir -p /home/kiosk/.vnc rm -f /home/kiosk/.vnc/passwd # Remove existing password file if it exists - echo "$VNC_PASSWORD" | vncpasswd -f > /home/kiosk/.vnc/passwd + echo "$vnc_password" | vncpasswd -f > /home/kiosk/.vnc/passwd chmod 600 /home/kiosk/.vnc/passwd # Write the script with properly formatted commands cat > /home/kiosk/start.sh <&1 1>&2 2>&3 3>&-) mkdir -p /home/kiosk/.vnc rm -f /home/kiosk/.vnc/passwd # Remove existing password file if it exists - echo "$VNC_PASSWORD" | vncpasswd -f > /home/kiosk/.vnc/passwd + echo "$vnc_password" | vncpasswd -f > /home/kiosk/.vnc/passwd chmod 600 /home/kiosk/.vnc/passwd # Write the script with properly formatted commands @@ -171,30 +177,31 @@ edit_bashrc() { # Check for help option if [[ "$1" == "-h" || "$1" == "--help" ]]; then - echo "Usage: $0 [--auto [ ... ]]" + echo "Usage: $0 [--auto [ ... ]]" echo "Options:" echo " --auto Run the script in automatic mode with no user interaction." echo " Requires specifying the distribution ('debian' or 'raspberry')," - echo " scaling factor (e.g., '1' for 1080p, '2' for 4K), and at least one URL." - echo " Additional URLs are optional and will open in new tabs." + echo " scaling factor (e.g., '1' for 1080p, '2' for 4K), VNC password," + echo " and at least one URL. Additional URLs are optional and will open in new tabs." echo " -h, --help Display this help and exit." echo "" echo "Example:" - echo " $0 --auto debian 1 \"https://www.example.com\"" - echo " $0 --auto raspberry 2 \"https://www.example1.com\" \"https://www.example2.com\"" + echo " $0 --auto debian 1 myvncpassword \"https://www.example.com\"" + echo " $0 --auto raspberry 2 myvncpassword \"https://www.example1.com\" \"https://www.example2.com\"" exit 0 fi # Automated or interactive mode check if [[ $1 == "--auto" ]]; then distro=$2 - shift 2 # Remove the first two arguments (script name and distro) for URLs and scaling factor + shift 2 # Remove the first two arguments (script name and distro) for URLs, scaling factor, and VNC password scaling_factor=$1 - shift # Remove the scaling factor to get URLs + vnc_password=$2 + shift 2 # Remove the scaling factor and VNC password to get URLs [[ $distro == "debian" ]] && install_packages_debian [[ $distro == "raspberry" ]] && install_packages_raspberry configure_xinitrc - configure_start_sh "$@" + configure_start_sh $scaling_factor $vnc_password "$@" configure_autologin edit_bashrc else -- cgit v1.2.3-70-g09d2