VNC: Configuration

General support questions
Post Reply
jmacdougca
Posts: 103
Joined: 2017/12/09 00:49:14
Location: West Vancouver, BC
Contact:

VNC: Configuration

Post by jmacdougca » 2021/11/11 22:24:49

Trying to get VNC server going for the first time.

Code: Select all

[root@orcacomputers conf]# systemctl daemon-reload
[root@orcacomputers conf]# systemctl start vncserver@:1
Failed to start vncserver@:1.service: Unit is not loaded properly: Invalid argument.
See system logs and 'systemctl status vncserver@:1.service' for details.
Status

Code: Select all

[root@orcacomputers conf]# systemctl status vncserver@:1.service -l
● vncserver@:1.service - Remote desktop service (VNC)
   Loaded: error (Reason: Invalid argument)
   Active: inactive (dead)

Nov 10 18:34:25 orcacomputers systemd[1]: vncserver@:1.service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.
So I inspect the configuration file

Code: Select all

vim /etc/systemd/system/vncserver@\:1.service

Code: Select all

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=simple

# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[b]ExecStart=/usr/bin/vncserver_wrapper netizen %i[/b]
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[b]ExecStart=/sbin/runuser -l netizen -c "/usr/bin/vncserver %i -geometry 1280x1024"[/b]
PIDFile=/home/netizen/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target
So I see the error is:

Code: Select all

 [b]ExecStart=/sbin/runuser -l netizen -c "/usr/bin/vncserver %i -geometry 1280x1024"[/b]
and the configuration files has two entries. Just not sure what to do next. I would be speculating and experience has taught me less is more =)

ExecStart=/usr/bin/vncserver_wrapper netizen %i
ExecStart=/sbin/runuser -l netizen -c "/usr/bin/vncserver %i -geometry 1280x1024"

I tried commenting each of them out but was not the solution I am looking for. Thought it a good time to ask for help.

I have

Code: Select all

services: vnc-server
and ports 5900 and 5901 open permanently in firewalld

I then edited

Code: Select all

[Neptune@orcacomputers ~]$ cat /usr/bin/vncserver_wrapper

Code: Select all

So that $USER was replaced with netizen. Reloaded and tried to start. Still the same error. Here is what I have now:

#!/bin/sh

USER="$1"
INSTANCE="$2"

die() {
    echo "FATAL: ${@:-}" >&2
    exit 2
}

cleanup() {
    [ -n "$VNCPID" ] || return
    if kill -0 $VNCPID 2>/dev/null; then
        kill $VNCPID
    fi
}

trap cleanup TERM INT HUP

[ -n "netizen" -a -n "$INSTANCE" ] || die "Invalid usage!"

/usr/sbin/runuser -l "netizen" -c "/usr/bin/vncserver ${INSTANCE}"
[ $? -eq 0 ] || die "'runuser -l $USER' failed!"

# Wait up to 5 seconds for vncserver to be up
for tries in $(seq 1 50); do
    [ -e "~netizen/.vnc/$(hostname)${INSTANCE}.pid" ] && break
    sleep 0.1
done

eval HOME=~netizen

VNCPID=$(cat "$HOME/.vnc/$(hostname)${INSTANCE}.pid" 2>/dev/null || true)
[ -n "$VNCPID" ] || die "'vncserver ${INSTANCE}' failed to start after 5 seconds!"

echo "'vncserver ${INSTANCE}' has PID $VNCPID, waiting until it exits ..."

while kill -0 $VNCPID 2>/dev/null; do
    sleep 5
done

echo "PID $VNCPID exited, exiting ..."
Last edited by jmacdougca on 2021/11/20 23:13:35, edited 2 times in total.
Start less finish more

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: VNC: Invalid Argument

Post by TrevorH » 2021/11/12 00:47:33

You seem to have two repeated sets of lines in there, did you paste it twice by mistake?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

jmacdougca
Posts: 103
Joined: 2017/12/09 00:49:14
Location: West Vancouver, BC
Contact:

Re: VNC: Invalid Argument

Post by jmacdougca » 2021/11/12 00:56:43

TrevorH wrote:
2021/11/12 00:47:33
You seem to have two repeated sets of lines in there, did you paste it twice by mistake?
Undeterminable. I tried commenting out each of the lines on separate occasions and

Code: Select all

systemctl daemon-reload

Code: Select all

systemctl start vncserver@:1.service -l

Code: Select all

:57:15 orcacomputers systemd[1]: Failed to start Remote desktop service (VNC).
-- Subject: Unit vncserver@:1.service has failed
I also changed

Code: Select all

 /etc/systemd/system/vncserver@.service
<USER> with netizen, reloaded daemon, tried to start. Not sure if I was supposed to do that or not. but

Code: Select all

vim /etc/systemd/system/vncserver@\:1.service
 said 

Code: Select all

Replace <USER> with the actual user name and edit vncserver
#    parameters in the wrapper script located in /usr/bin/vncserver_wrapper
so I replaced

Code: Select all

 $USER
with netizen

Code: Select all

systemctl status vncserver@:1.service

Code: Select all

systemd[1]: Failed to start Remote desktop service (VNC).
orcacomputers systemd[1]: Unit vncserver@:1.service entered failed state.
orcacomputers systemd[1]: vncserver@:1.service failed.
Start less finish more

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: VNC: Invalid Argument

Post by TrevorH » 2021/11/12 02:16:55

Undeterminable. I tried commenting out each of the lines on separate occasions and
No, it's clearly visible. You have a block of lines like this

Code: Select all

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=simple

# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[b]ExecStart=/usr/bin/vncserver_wrapper netizen %i[/b]
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target
and then the exact same set of lines after them so you have two [Unit], two [Service] and two [Install] stanzas. That's wrong, there should be only one of each.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

jmacdougca
Posts: 103
Joined: 2017/12/09 00:49:14
Location: West Vancouver, BC
Contact:

Re: VNC: Invalid Argument

Post by jmacdougca » 2021/11/12 03:14:46

oh wow, blocks. My baseball bad :?

I removed the block. Now have

Code: Select all

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=simple

# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver_wrapper netizen %i
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target
The instructions say

Code: Select all

Replace <USER> with the actual user name and edit vncserver
#    parameters in the wrapper script located in /usr/bin/vncserver_wrapper
so I did that:

Code: Select all

#!/bin/sh

USER="$1"
INSTANCE="$2"

die() {
        echo "FATAL: ${@:-}" >&2
        exit 2
}

cleanup() {
        [ -n "$VNCPID" ] || return
        if kill -0 $VNCPID 2>/dev/null; then
                kill $VNCPID
        fi
}

trap cleanup TERM INT HUP

[ -n "netizen" -a -n "$INSTANCE" ] || die "Invalid usage!"

/usr/sbin/runuser -l "netizen" -c "/usr/bin/vncserver ${INSTANCE}"
[ $? -eq 0 ] || die "'runuser -l netizen' failed!"

# Wait up to 5 seconds for vncserver to be up
for tries in $(seq 1 50); do
        [ -e "~$USER/.vnc/$(hostname)${INSTANCE}.pid" ] && break
        sleep 0.1
done

eval HOME=~netizen

VNCPID=$(cat "$HOME/.vnc/$(hostname)${INSTANCE}.pid" 2>/dev/null || true)
[ -n "$VNCPID" ] || die "'vncserver ${INSTANCE}' failed to start after 5 seconds!"

echo "'vncserver ${INSTANCE}' has PID $VNCPID, waiting until it exits ..."

while kill -0 $VNCPID 2>/dev/null; do
        sleep 5
done

echo "PID $VNCPID exited, exiting ..."
~                                       
and now reload daemon and start is what I expect but says there is a version as :1 running already and runuser -l netizen failed

Code: Select all

Neptune@orcacomputers ~]$ systemctl daemon-reload
[Neptune@orcacomputers ~]$ systemctl reload vncserver@:1.service
Error: No space left on device
Failed to reload vncserver@:1.service: Job type reload is not applicable for unit vncserver@:1.service.
See system logs and 'systemctl status vncserver@:1.service' for details.
[Neptune@orcacomputers ~]$ systemctl status vncserver@:1.service
● vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2021-11-11 18:54:47 PST; 14min ago
 Main PID: 27560 (code=exited, status=2)

Nov 11 18:54:47 orcacomputers systemd[1]: Starting Remote desktop service (VNC)...
Nov 11 18:54:47 orcacomputers systemd[1]: Started Remote desktop service (VNC).
Nov 11 18:54:47 orcacomputers vncserver_wrapper[27560]: A VNC server is already running as :1
Nov 11 18:54:47 orcacomputers vncserver_wrapper[27560]: FATAL: 'runuser -l netizen' failed!
Nov 11 18:54:47 orcacomputers systemd[1]: vncserver@:1.service: main process exited, code=exited, ...MENT
Nov 11 18:54:47 orcacomputers systemd[1]: Unit vncserver@:1.service entered failed state.
Nov 11 18:54:47 orcacomputers systemd[1]: vncserver@:1.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
So this code is the root of the error

Code: Select all

/usr/sbin/runuser -l "netizen" -c "/usr/bin/vncserver ${INSTANCE}"
What am I not seeing?
Start less finish more

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: VNC: Invalid Argument

Post by TrevorH » 2021/11/12 04:09:11

Nov 11 18:54:47 orcacomputers vncserver_wrapper[27560]: A VNC server is already running as :1
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

jmacdougca
Posts: 103
Joined: 2017/12/09 00:49:14
Location: West Vancouver, BC
Contact:

Re: VNC: Invalid Argument

Post by jmacdougca » 2021/11/12 16:07:16

I see.

Code: Select all

[b]Neptune  21070     1  0 Nov10 ?        00:00:01 /usr/bin/Xvnc :1 -auth /home/Neptune/.xauthkxhwbT -desktop orcacomputers:1 (Neptune) -fp catalogue:/etc/X11/fontpath.d -geometry 1024x768 -httpd /usr/share/vnc/classes -pn -rfbauth /home/Neptune/.vnc/passwd -rfbport 5901 -rfbwait 30000
I changed user to Neptune

Code: Select all

/etc/systemd/system/vncserver@\:1.service
and changed

Code: Select all

/usr/bin/vncserver_wrapper
back to

Code: Select all

$USER
. Not sure if I am supposed to be changing this file or it is the file that picks up all vnc settings for all users.
Start less finish more

jmacdougca
Posts: 103
Joined: 2017/12/09 00:49:14
Location: West Vancouver, BC
Contact:

Re: VNC: Invalid Argument

Post by jmacdougca » 2021/11/20 22:50:45

Things making more sense now :D

Getting lost in the weeds here. 5905 shows VNC extension running

Code: Select all

cat $HOME/.vnc/orcacomputers:5.log

Code: Select all

Xvnc TigerVNC 1.8.0 - built Nov 16 2020 16:47:50
Copyright (C) 1999-2017 TigerVNC Team and many others (see README.txt)
See http://www.tigervnc.org for information on TigerVNC.
Underlying X server release 12004000, The X.Org Foundation


Sat Nov 20 09:54:02 2021
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on all interface(s), port 5905
 vncext:      Listening for HTTP connections on all interface(s), port 5805
 vncext:      created VNC server for screen 0

Sat Nov 20 09:54:06 2021
 ComparingUpdateTracker: 0 pixels in / 0 pixels out
 ComparingUpdateTracker: (1:-nan ratio)
When I look at sessions running I see 5 is running.

Code: Select all

vncserver -list

TigerVNC server sessions:

X DISPLAY #	PROCESS ID
:1		12634
:3		14456
:4		15699
:5		8386
I reload and enable successfully but status showing failed when I expect active

Code: Select all

[Neptune@orcacomputers ~]$ systemctl  daemon-reload
[Neptune@orcacomputers ~]$ systemctl enable 24.109.184.150:5.service

[Neptune@orcacomputers system]$ systemctl status 24.109.184.150:5.service -l
● 24.109.184.150:5.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/24.109.184.150:5.service; enabled; vendor preset: disabled)
   Active: [b][u]failed[/u][/b] (Result: exit-code) since Sat 2021-11-20 12:32:47 PST; 2h 22min ago
 Main PID: 16827 (code=exited, status=2)

Nov 20 12:32:47 orcacomputers systemd[1]: Starting Remote desktop service (VNC)...
Nov 20 12:32:47 orcacomputers systemd[1]: Started Remote desktop service (VNC).
Nov 20 12:32:47 orcacomputers vncserver_wrapper[16827]: FATAL: Invalid usage!
Nov 20 12:32:47 orcacomputers systemd[1]: 24.109.184.150:5.service: main process exited, code=exited, status=2/INVALIDARGUMENT
Nov 20 12:32:47 orcacomputers systemd[1]: Unit 24.109.184.150:5.service entered failed state.
Nov 20 12:32:47 orcacomputers systemd[1]: 24.109.184.150:5.service failed.
So must be one of the <USER> variables

So I check

Code: Select all

/etc/systemd/system/24.109.184.150:5.service


and see <USER> Neptune added as per https://access.redhat.com/documentation ... VNC Server.

This looks good to me upto this point

Code: Select all

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=simple

# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver_wrapper [b][u]Neptune[/u][/b] %i
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
This completes
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/vncserver@.service
# 2. Replace <USER> with the actual user name


Crossroads with
and edit vncserver
# parameters in the wrapper script located in /usr/bin/vncserver_wrapper

[/code]

...Parameters...

I changed line 22 of only

Code: Select all

[codvim /usr/bin/vncserver_wrapper
.

Not sure what else if anything I should be changing here.

Code: Select all

21  [ -n "$USER" -a -n "$INSTANCE" ] || die "Invalid usage!"
22 /usr/sbin/runuser -l "Neptune" -c "/usr/bin/vncserver ${INSTANCE}"
23 [ $? -eq 0 ] || die "'runuser -l $USER' failed!"
27 [ -e "~$USER/.vnc/$(hostname)${INSTANCE}.pid" ] && break
28 eval HOME=~$USER
34 [ -n "$VNCPID" ] || die "'vncserver ${INSTANCE}' failed to start after 5 seconds!"

:ugeek:

I'm eery though because Documentation I'm following maybe incomplete? I dunno... :cry:
So let's check CentOS docs on VNC Server if any ...
Start less finish more

Post Reply