Autostart vnc server

I’m trying to get the aml-vnc server to auto start as a service. I’m running on an Vero4K+. I can start aml-vnc from the command line, but I can’t get it to start as a service.
Any corrections to this would be appreciated.

I copied this from this example link: How to Install and Configure VNC on Debian 10 | DigitalOcean
and the example service file:

        • start of example
          /etc/systemd/system/vncserver@.service

[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target

[Service]
Type=forking
User=sammy
Group=sammy
WorkingDirectory=/home/sammy

PIDFile=/home/sammy/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

      • ** * End of example

Here’s my service file saved as /etc/systemd/system/aml-vnc@.service,

[Unit]
Description=Start aml-vnc server at startup
After=syslog.target network.target

[Service]
Type=forking
User=osmc
Group=osmc
WorkingDirectory=/home/osmc

PIDFile=/home/osmc/.vnc/%H:%i.pid
#ExecStartPre=-/usr/bin/aml-vnc -kill :%i > /dev/null 2>&1

ExecStart=/usr/bin/aml-vnc -depth 24 -geometry 1280x800 :%i

ExecStart=/usr/bin/aml-vnc :%i
ExecStop=+/usr/bin/aml-vnc -kill :%i

[Install]
WantedBy=multi-user.target

And here are the error log entries from journalctl -xe :

Nov 16 16:24:19 osmc sudo[24151]: osmc : TTY=pts/1 ; PWD=/home/osmc ; USER=root ; COMMAND=/
Nov 16 16:24:19 osmc sudo[24151]: pam_unix(sudo:session): session opened for user root by osmc(
Nov 16 16:24:33 osmc sudo[24151]: pam_unix(sudo:session): session closed for user root
There is no – Subject: A start job for unit aml-vnc@1.service has failed option (press RETURN-- Support: Debian -- User Support

– An ExecStart= process belonging to unit aml-vnc@1.service has exited.

– The process’ exit code is ‘killed’ and its exit status is 15.
Nov 16 16:23:41 osmc systemd[1]: aml-vnc@1.service: Failed with result ‘timeout’.
– Subject: Unit failed
– Defined-By: systemd
– Support: Debian -- User Support

– The unit aml-vnc@1.service has entered the ‘failed’ state with result ‘timeout’.
Nov 16 16:23:41 osmc systemd[1]: Failed to start Start aml-vnc server at startup.
– Subject: A start job for unit aml-vnc@1.service has failed
– Defined-By: systemd
– Support: Debian -- User Support

– A start job for unit aml-vnc@1.service has finished with a failure.

– The job identifier is 1091 and the job result is failed.
Nov 16 16:23:41 osmc sudo[23975]: pam_unix(sudo:session): session closed for user root
Nov 16 16:24:19 osmc sudo[24151]: osmc : TTY=pts/1 ; PWD=/home/osmc ; USER=root ; COMMAND=/
Nov 16 16:24:19 osmc sudo[24151]: pam_unix(sudo:session): session opened for user root by osmc(
Nov 16 16:24:33 osmc sudo[24151]: pam_unix(sudo:session): session closed for user root
Log file is already in use (press RETURN)

My solution was a bit different, but working.

sudo apt-get install screen
sudo cp aml-vnc /usr/bin
mkdir scripts
cd scripts
nano vncstarter.sh

#!/bin/bash
screen -dmS Vnc-server /usr/bin/aml-vnc
exit

nano vncstopper.sh

#!/bin/bash
screen -S Vnc-server -X eval 'stuff ^C'
exit

nano vnc-server.service

[Unit]
Description = Vnc-server
After = remote-fs.target network-online.target
[Service]
Type=oneshot
RemainAfterExit=yes
User=osmc
ExecStart = /home/osmc/scripts/vncstarter.sh
ExecStop = /home/osmc/scripts/vncstopper.sh
TimeoutStopSec=20

[Install]
WantedBy = multi-user.target

Hope you fix the rest yourself, holler if you need more help.

1 Like