[tightvnc] Start vncserver on boot on systemd

Post Reply
User avatar
hiccup
Site Admin
Posts: 21
Joined: Sat Aug 01, 2015 8:44 pm

[tightvnc] Start vncserver on boot on systemd

Post by hiccup » Sat Oct 05, 2019 4:10 pm

/root/boot.sh

Code: sh Select all

#!/usr/bin/env bash
USER=root
HOME=/root
export USER HOME
su -c "vncserver" root
/etc/systemd/system/customboot

Code: sh Select all

[Service]
ExecStart=/root/boot.sh
[Install]
WantedBy=default.target

Code: sh Select all

chmod +x /root/boot.sh
systemctl enable customboot
do the above at once:

Code: sh Select all

bootscript=/root/boot.sh
servicename=customboot

cat > $bootscript <<EOF
#!/usr/bin/env bash
USER=root
HOME=/root
export USER HOME
su -c "vncserver" root
EOF

chmod +x $bootscript

cat > /etc/systemd/system/$servicename.service <<EOF
[Service]
ExecStart=$bootscript
[Install]
WantedBy=default.target
EOF
systemctl enable $servicename

Post Reply