aboutsummaryrefslogtreecommitdiff
path: root/installer.sh
diff options
context:
space:
mode:
Diffstat (limited to 'installer.sh')
-rw-r--r--installer.sh43
1 files 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 <<EOF
#!/bin/bash
-/usr/bin/chromium --no-first-run --disable-translate --no-default-browser-check --disable-cache --kiosk $2
+/usr/bin/chromium --no-first-run --disable-translate --no-default-browser-check --disable-cache --kiosk $website
EOF
chmod a+x /home/kiosk/start.sh
}
@@ -119,16 +125,16 @@ EOF
# Helper function to configure start.sh for multiple tabs
configure_tabs() {
local scaling_factor=$1
- shift # Remove the first argument (scaling factor) to loop over URLs
+ local vnc_password=$2
+ shift 2 # Remove the first two arguments (scaling factor and VNC password) to get URLs
local tab_urls=""
for url in "$@"; do
tab_urls+="'$url' " # Ensure URLs are properly quoted
done
- VNC_PASSWORD=$(dialog --title "VNC Password" --inputbox "Please enter the VNC password:" 8 50 "" 3>&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 <distro> <scaling_factor> <url1> [<url2> ... <urlN>]]"
+ echo "Usage: $0 [--auto <distro> <scaling_factor> <vnc_password> <url1> [<url2> ... <urlN>]]"
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