#!//usr/bin/csh -f #+ #NAME # osirisStartVncServers - start required VNC servers for observing # #PURPOSE # determine the users vnc server based upon the username # then start the viewer # #USAGE # osirisStartVncServers # for now, run by SA, in future, generally will be run from pull-down # #ARGUMENTS # [-restart] force a restart of the servers (not yet implemented) # #OUTPUT # None # #RESTRICTIONS # Must be run as osiris numbered account # Requires script osirisCleanVncDir # #EXIT VALUES # 0 = normal completion # 1 = wrong number of arguments # 2 = not run as numbered account # 3 = not run on default computer (napili) # #EXAMPLES # 1) Start the vncviewer in interactive mode: # osirisStartVncServers # #- # Modification history: # 2006 Mar 10 jlyke Original - adapted from osiris_vncviewer # 2006 Apr 25 jlyke 1st working version # 2006 May 04 jlyke Paradigm shift to let vncserver handle # the port number assignment # 2006 Jun 07 jlyke Added -IdleTimeout 0 option so that viewers # are not cut off after 1 hour inactivity # #----------------------------------------------------------------------- # define initial values... set buf = $0 set cmd = $buf:t set usage = "Usage: $cmd [-restart]" # alias echo so we can ring the bell alias echo /usr/bin/echo # define defaults set pid = $$ set computer = "napili" set logdir = "~/.vnc" set viewonly = "" set depth = 24 echo "" set user = `whoami` set control_name = "OSIRIS Control ($user)" set drp_name = "OSIRIS DRP ($user)" set remote_name = "OSIRIS 8-bit display ($user)" set control_string = "Control" set drp_string = "DRP" set remote_string = "8-bit" # make sure an osiris numbered account is running this script set userbase = `whoami | cut -c 1-6` set num = `whoami | cut -c 7-` if ( $userbase != "osiris" ) then echo "" echo "\aWarning: $cmd must be run as an osiris numbered account" echo "" exit 2 else if ( $num == "" || $num == "eng" ) then echo "" echo "\aWarning: $cmd must be run as an osiris numbered account" echo "" exit 2 endif # make sure we're running on napili set mycomp = `hostname` if ( $mycomp != $computer ) then echo "" echo "\aWarning: $cmd must be run from $computer" echo "" exit 3 endif # Parse arguments. while ($#argv > 0) switch ($1) case "-viewonly": set viewonly = "-viewonly" breaksw case "-restart": set restart default: cat < 0 ) then set skip = 1 # grab the last field on that line while ( $#run > 0 ) set viewer = $run[1] shift run end endif # if not running, start the VNC server and write output to a file if ( $skip == 0 ) then echo "" echo "Starting VNC server: $server" vncserver -name "$name" -depth $depth -IdleTimeout 0 >& $logdir"/"$pid".info" # rename the file and display it set line = `grep "New" $logdir"/"$pid".info"` while ( $#line > 0 ) set file = $line[1] shift line end mv $logdir"/"$pid".info" $logdir"/"$file".info" cat $logdir"/"$file".info" else echo "" echo "$name is already running as $viewer" endif end # reset echo unalias echo exit 0