#!/bin/sh # sunos/solaris rc script to run userbased vnc server # written by: Shay Hugi, systemunix@mpthrill.com # writing style: [i]nteractive shellscript # tested on platform environment: Sun/OS 5.7 # proccess name: vncserver # # Source function library. . /etc/rc.d/init.d/functions RETVAL=0 # See how we were called. case "$1" in start) echo -n "Starting VNC services for user shay: " # Just in case a lock file was left behind, # remove it now. /bin/rm /tmp/.X1-lock su -l -c "/usr/local/bin/vncserver -name mpthrill.com_solaris_vnc -cc 3 -geometry 1024x768 :1 " shay RETVAL=$? ;; stop) echo -n "Shutting down VNC services: " su -l -c "/usr/local/bin/vncserver -kill :1 " shay RETVAL=$? ;; restart) $0 stop $0 start RETVAL=$? ;; status) #status commands echo "check status by user? [y/n]:" read csbu if [ $csbu = y -o $csbu = Y ]; then echo "who is the user?:" read witu ps -ef | grep Xvnc | grep $witu else ps -ef | grep Xvnc fi ;; help) $0 readhelp | more ;; readhelp) echo " general" echo " " echo " a user based vnc rc script for the sunos/solaris. echo " " echo " install" echo " " echo " make two symbolic links to this file :" echo " /etc/rc.d/rc.5/S92vnc -> /etc/rc.d/init.d/vnc" echo " and /etc/rc.d/rc.5/K36vnc -> /etc/rc.d/init.d/vnc" echo " K36vnc stops the vnc service at shutdown or reboot" echo " and S92vnc will start the vnc server when entering runlevel 5." echo " " echo " commands help" echo " " echo " stop: will only stop the main system's vnc proccess" echo " " echo " start: will start a vnc desktop for the user who ran the shell" echo " " echo " stopid: will interactively stop the vnc service by :desktop number" echo " per each user who ran the script" echo " " echo " status: will interactively show the the current status of vnc" echo " you can choose between specific user or all users" echo " provides: pid and desktop number" echo " " echo " help: this help guide dahhh" echo " " echo " " echo " ***final notes***" echo " you may want to set your path and the begining of the script" echo " and the name of the desktop the script creates" echo " also to enable debugging and view on each desktop while running" echo " the script, delete the [2>&1] at the end of each [>dev/null]" echo " " echo " for more help: http://www.uk.research.att.com/vnc" echo " or email me: systemunix@mpthrill.com " echo " " ;; *) echo "Usage: $0 [ start | status | stop | restart | help ]" exit 1 ;; esac exit $RETVAL