#!/bin/sh # beos startup script to run customized vnc server # written by: Shay Hugi, systemunix@mpthrill.com # writing style: [i]nteractive shellscript # tested on platform environment: BeOS R5.0.1 # proccess name: vncserver PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin export PATH case "$1" in start) #starting commands echo " starting the vnc service" vncserver -name mpthrill.com_freebsdbox_vnc >/dev/null 2>&1 ;; status) #status commands ps | grep Xvnc ;; stop) #stop commands echo "$0 stopping the service" [ -f /.vnc/*:*.pid ] && kill `cat /.vnc/*:*.pid` rm -f /.vnc/*:*.pid ;; stopid) #stop by pid commands echo "what desktop wanna die?" read deskill vncserver -kill :$deskill ;; reloadfirst) #reloads the first vnc service per user echo "stopping first $USER's vnc daemon" if [ $USER = root ]; then [ -f /root/.vnc/*:1.pid ] && kill `cat /root/.vnc/*:1.pid` rm -f /root/.vnc/*:1.pid echo "restarting vnc service..." vncserver >/dev/null 2>&1 else [ -f /home/$USER/.vnc/*:1.pid ] && kill `cat /home/$USER/.vnc/*:1.pid` rm -f /home/$USER/.vnc/*:1.pid echo "restarting vnc service..." vncserver >/dev/null 2>&1 fi ;; reloadall) #reloads all vnc services echo "stopping ALL $USER's vnc daemons" if [ $USER = root ]; then [ -f /root/.vnc/*:*.pid ] && kill `cat /root/.vnc/*:*:pid` rm -f /root/.vnc/*:*.pid echo "reloading vncserver daemon for $USER" vncserver >dev/null 2>&1 else [ -f /home/$USER/.vnc/*:*.pid ] && kill `cat /home/$USER/.vnc/*:*.pid` rm -f /home/$USER/.vnc/*:*.pid vncserver >dev/null 2>&1 fi ;; help) #help redirection $0 readhelp | more ;; readhelp) #help document echo " general" echo " " echo " this is an interactive startup script for the vncserver binary" echo " used in the BeOS platform" echo " because the vncserver is a multi-running daemon [meaning: it could" echo " be run more than one time by one or other more on a system]" echo " the script is written a bit diffrently for customization purposes." echo " for example: pid file is not being written to: /var/run" echo " " echo " install" echo " " echo " cp the file in your /boot/home/config/boot/ direcory and name it" echo " or cat >> it, to file 'UserBootscript'" echo " when the system first loads the script will be running on system's" echo " / directory writing the pid into /.vnc/hostname:desktop.pid" echo " only root can stop the main system's proccess, unless overriding" echo " permissions. " echo " running the syntax ./vnc.sh stop, will stop this proccess" echo " and from now on each and every vnc proccess that will be started " echo " will start customized per user [meaning: every user has the" echo " ability to run the vncserver with his own password and permissions" 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 " reloadfirst: will allow a user to reload his first [any maybe his" echo " only] proccess of the vnc service." echo " " echo " reloadall: will stop all vnc services per a user including root" echo " and will start a new vnc service for him and only him" echo " even if it's being ran by root" 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 "****************************************************************" echo " syntax: " echo " $0 [ start | status | stop | stopid | reloadall " echo " reloadfirst | help ] " echo "****************************************************************" exit 1 ;; esac