Changes

Jump to navigation Jump to search
#!/bin/bash
PATH="$PATH:/usr/bin/"
export USER="usermcnair"
DISPLAY="1"
DEPTH="16"
GEOMETRY="1024x7681920x1080"
OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY} -localhost"
. /lib/lsb/init-functions
 
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
start)
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.
stop)
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.
restart)
$0 stop
$0 start
;;
esac
exit 0
 
Made this service script executable:
sudo chmod +x /etc/init.d/vncserver
 
Now try using the service and command to start a new VNC server instance:
sudo service vncserver start
==User management==

Navigation menu