Changes

Jump to navigation Jump to search
Next, we can start inserting the command instructions that will allow us to manage the new service. The following block binds the command needed to start a VNC server, and feedback that it is being started, to the command keyword start.
case "$1" in
startvncstart)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
The next block creates the command keyword stop, which will immediately kill an existing VNC server instance.
stopvncstop)
log_action_begin_msg "Stopping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
The final block is for the command keyword restart, which is simply the two previous commands (stop and start) combined into one command.
restartvncrestart) $0 stopvncstop $0 startvncstart
;;
esac
Now try using the service and command to start a new VNC server instance:
sudo service vncserver startvncstart
===Connect to VNC server===

Navigation menu