Skip to content

Instantly share code, notes, and snippets.

@dodolboks
Forked from ParkNoBreak/ini.txt
Last active November 2, 2018 07:14
Show Gist options
  • Save dodolboks/3cc02a73057ec762277d31b0572f408d to your computer and use it in GitHub Desktop.
Save dodolboks/3cc02a73057ec762277d31b0572f408d to your computer and use it in GitHub Desktop.
vncserver daemon
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 3 4 5
# Default-Stop: 0 6
### END INIT INFO
PATH="$PATH:/usr/X11R6/bin/"
# The Username:Group that will run VNC
export USER="usermudewe"
#${RUNAS}
# The display that VNC will use
DISPLAY="1"
# Color depth (between 8 and 32)
DEPTH="16"
# The Desktop geometry to use.
#GEOMETRY="<WIDTH>x<HEIGHT>"
#GEOMETRY="800x600"
GEOMETRY="1024x768"
#GEOMETRY="1280x1024"
# The name that the VNC Desktop will have.
NAME="my-vnc-server"
PORTMU="6066"
OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} -rfbport ${PORTMU}"
. /lib/lsb/init-functions
case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;
stop)
log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;
restart)
$0 stop
$0 start
;;
esac
exit 0
@dodolboks
Copy link
Author

sudo chmod +x /etc/init.d/vncserver && sudo update-rc.d vncserver defaults && sudo /etc/init.d/vncserver start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment