From 7a8f438593fcf7a7c1c6c678877d45be95ba0d2f Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 3 Nov 2024 13:51:44 +0200 Subject: [PATCH] VNC support for not user pi Fixes #571 --- .../etc/systemd/system/x11vnc.service | 6 +++--- src/modules/fullpageos/start_chroot_script | 21 +++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/modules/fullpageos/filesystem/root_init/etc/systemd/system/x11vnc.service b/src/modules/fullpageos/filesystem/root_init/etc/systemd/system/x11vnc.service index fef207c..3b7fd67 100644 --- a/src/modules/fullpageos/filesystem/root_init/etc/systemd/system/x11vnc.service +++ b/src/modules/fullpageos/filesystem/root_init/etc/systemd/system/x11vnc.service @@ -1,13 +1,13 @@ [Unit] Description=VNC Server for X11 -ConditionPathExists=/home/pi/.vnc/passwd +ConditionPathExists=/opt/custompios/vnc/passwd Requires=display-manager.service [Service] -ExecStart=/usr/bin/x11vnc -display :0 -auth guess -many -noxdamage -rfbauth /home/pi/.vnc/passwd -rfbport 5900 -shared +ExecStart=/usr/bin/x11vnc -display :0 -auth guess -many -noxdamage -rfbauth /opt/custompios/vnc/passwd -rfbport 5900 -shared ExecStop=/usr/bin/x11vnc -R stop Restart=on-failure RestartSec=2 [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target diff --git a/src/modules/fullpageos/start_chroot_script b/src/modules/fullpageos/start_chroot_script index 871e72b..b192f6a 100755 --- a/src/modules/fullpageos/start_chroot_script +++ b/src/modules/fullpageos/start_chroot_script @@ -123,17 +123,20 @@ if [ "$FULLPAGEOS_INCLUDE_X11VNC" == "yes" ] then apt-get install -y --force-yes x11vnc + mkdir -p /opt/custompios/vnc + chown "${BASE_USER}":"${BASE_USER}" + # Set x11vnc password if [ "$FULLPAGEOS_OVERRIDE_PASSWORD" != "default" ] then sudo -u pi /opt/custompios/scripts/setX11vncPass "$FULLPAGEOS_OVERRIDE_PASSWORD" sync - if [ ! -f /home/pi/.vnc/passwd ] || [ ! -s /home/pi/.vnc/passwd ]; then - echo "/home/pi/.vnc/passwd was not created. Trying again." + if [ ! -f /opt/custompios/vnc/passwd ] || [ ! -s /opt/custompios/vnc/passwd ]; then + echo "/opt/custompios/vnc/passwd was not created. Trying again." sudo -u pi /opt/custompios/scripts/setX11vncPass "$FULLPAGEOS_OVERRIDE_PASSWORD" sync - if [ ! -f /home/pi/.vnc/passwd ] || [ ! -s /home/pi/.vnc/passwd ]; then - echo "/home/pi/.vnc/passwd was not created again. Giving up." + if [ ! -f /opt/custompios/vnc/passwd ] || [ ! -s /opt/custompios/vnc/passwd ]; then + echo "/opt/custompios/vnc/passwd was not created again. Giving up." echo "Failed to set a VNC password. Aborting build." exit 1 fi @@ -141,18 +144,18 @@ then else sudo -u pi /opt/custompios/scripts/setX11vncPass raspberry sync - if [ ! -f /home/pi/.vnc/passwd ] || [ ! -s /home/pi/.vnc/passwd ]; then - echo "/home/pi/.vnc/passwd was not created. Trying again." + if [ ! -f /opt/custompios/vnc/passwd ] || [ ! -s /opt/custompios/vnc/passwd ]; then + echo "/opt/custompios/vnc/passwd was not created. Trying again." sudo -u pi /opt/custompios/scripts/setX11vncPass raspberry sync - if [ ! -f /home/pi/.vnc/passwd ] || [ ! -s /home/pi/.vnc/passwd ]; then - echo "/home/pi/.vnc/passwd was not created again. Giving up." + if [ ! -f /opt/custompios/vnc/passwd ] || [ ! -s /opt/custompios/vnc/passwd ]; then + echo "/opt/custompios/vnc/passwd was not created again. Giving up." echo "Failed to set a VNC password. Aborting build." exit 1 fi fi fi - ls -l /home/pi/.vnc/passwd + ls -l /opt/custompios/vnc/passwd #Enable x11vnc service systemctl enable x11vnc.service