Kablersalat 9 hónapja
szülő
commit
aea6164bc8
1 módosított fájl, 49 hozzáadás és 2 törlés
  1. 49 2
      kiosk.sh

+ 49 - 2
kiosk.sh

@@ -94,7 +94,7 @@ configure_start_sh() {
       configure_tabs $SCALE_FACTOR "${tab_urls[@]}"
     fi
   else  # Automated mode with URLs as arguments
-    if [ $# -eq 1]; then  # Single website
+    if [ $# -eq 1 ]; then  # Single website
       set_start_script_single $SCALE_FACTOR $1
     else  # Multiple tabs
       configure_tabs $SCALE_FACTOR "$@"
@@ -106,15 +106,38 @@ configure_start_sh() {
 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>&-)
   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
   chmod 600 /home/kiosk/.vnc/passwd
 
+  # Remove existing VNC server configuration if it exists
+  sudo systemctl stop x11vnc.service
+  sudo rm -f /etc/systemd/system/x11vnc.service
+
   cat > /home/kiosk/start.sh <<EOF
 #!/bin/bash
 /usr/bin/chromium --no-first-run --disable-translate --no-default-browser-check --disable-cache --kiosk $2 &
 x11vnc -display :0 -auth guess -forever -rfbport 5901 -passwdfile /home/kiosk/.vnc/passwd &
 EOF
   sudo chmod a+x /home/kiosk/start.sh
+
+  # Create a new VNC server configuration
+  sudo bash -c "cat > /etc/systemd/system/x11vnc.service << 'EOF'
+[Unit]
+Description=Start x11vnc at startup.
+After=multi-user.target
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/x11vnc -display :0 -auth guess -forever -rfbport 5901 -passwdfile /home/kiosk/.vnc/passwd
+
+[Install]
+WantedBy=multi-user.target
+EOF"
+
+  sudo systemctl daemon-reload
+  sudo systemctl enable x11vnc.service
+  sudo systemctl start x11vnc.service
 }
 
 # Helper function to configure start.sh for multiple tabs
@@ -127,9 +150,15 @@ configure_tabs() {
   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
   chmod 600 /home/kiosk/.vnc/passwd
 
+  # Remove existing VNC server configuration if it exists
+  sudo systemctl stop x11vnc.service
+  sudo rm -f /etc/systemd/system/x11vnc.service
+
   # Write the script with properly formatted commands
   cat > /home/kiosk/start.sh <<EOF
 #!/bin/bash
@@ -160,9 +189,27 @@ while true; do
     fi
 done
 
-x11vnc -display :0 -auth guess -forever -rfbport 5901 -passwd $VNC_PASSWORD &
+x11vnc -display :0 -auth guess -forever -rfbport 5901 -passwdfile /home/kiosk/.vnc/passwd &
 EOF
   chmod a+x /home/kiosk/start.sh
+
+  # Create a new VNC server configuration
+  sudo bash -c "cat > /etc/systemd/system/x11vnc.service << 'EOF'
+[Unit]
+Description=Start x11vnc at startup.
+After=multi-user.target
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/x11vnc -display :0 -auth guess -forever -rfbport 5901 -passwdfile /home/kiosk/.vnc/passwd
+
+[Install]
+WantedBy=multi-user.target
+EOF"
+
+  sudo systemctl daemon-reload
+  sudo systemctl enable x11vnc.service
+  sudo systemctl start x11vnc.service
 }
 
 # Function to edit .bashrc for automatic start of X session