#!/usr/bin/env perl # ---------------------------------------------------------------------- # This is the base startup script for SOFTWARE -- all versions, # all platforms. It sets some variables, figures out which version to # run, and invokes the startup script for that version. # # Variables Used Globally # $version Software Version Number (e.g. 6.07) # @args Command line args without athena additions # @not_available List of Platforms on which SOFTWARE # doesn't run # $sys (optional) value of $ATHENA_SYS # $swtoolsDir pointer to swtools locker in AFS # $msg_dir # $isathena is the machine an Athena machine # ---------------------------------------------------------------------- $software = "gccgo"; $version = "4.50"; @not_available = (""); $base_locker = "/mit/${software}"; if (-s "/etc/athena/reactivate") { $isathena = "1"; } else { $isathena = "0"; $vermsg=`fs sysname`; chomp($vermsg); $q1=index($vermsg, "'"); $q2=index($vermsg,"'",$q1+1); $athenasys=substr($vermsg,$q1+1,$q2-$q1-1); $ENV{"ATHENA_SYS"} = $athenasys; $ENV{"PATH"} = "${base_locker}" . "/arch/" . "${athenasys}" . "/bin:" . $ENV{"PATH"}; } # added by alexp 4/12/06 written by zacheiss # to not wait for message send on backgrounded launch when zephyr not used $SIG{'TTOU'} = 'IGNORE'; $SIG{'TTIN'} = 'IGNORE'; &initialize ($base_locker); &process_local_args; # set @args, possibly $version $sw_version = "${software}_v${version}"; $version_locker = "/mit/${sw_version}"; $cookie = ""; $message = "$msg_dir/"; #&send_message ($cookie, $message); #sleep 2; &exec_version ($version_locker, $sw_version, $version, $software); # ---------------------------------------------------------------------- # initialize # # Use this routine do any sort of initialization. Code is included # for setting a reasonable value for $ATHENA_SYS if that is needed. # # Globals Set # $sys - ATHENA_SYS environment variable # $msg_dir - Location of magic cookie files # $swtoolsDir - Location of the swtools locker # $redirection - Controls visibility of stdout from attach # # ---------------------------------------------------------------------- sub initialize { local ($base) = @_; # Uncomment this if you need to use $ATHENA_SYS # if (! defined ($sys = $ENV{"ATHENA_SYS"})) { # open (MACH, "machtype -S|"); # chop ($sys = ); # if (length ($sys) == 0) { # $sys = "\@sys"; # } # close MACH; # } $redirection = "> /dev/null"; # For messages launched from base locker $msg_dir = "${base}/Athena/messages"; $swtoolsDir="/afs/athena/software/swtools"; } # ---------------------------------------------------------------------- # process_local_args # # Process the command line arguments. We do this to search # for Athena-specific options, currently limited to a version # specification. # # Globals Referenced # @ARGV # # Globals Set # @args - Command line arguments without athena-specifc ones # # ---------------------------------------------------------------------- sub process_local_args { local ($arg, $verflag); # alexp 9/19/05 fixed to not stop prematurely if a command-line arg is "" $verflag = 0; foreach $argnum (0 .. $#ARGV) { ARGS: { $arg = $ARGV[$argnum]; if ($arg =~ /^-ver[ s|si|sio|sion]?/) { $version = $ARGV[$argnum+1]; $verflag = 1; last ARGS; } if ($arg eq "-show_stdout") { $redirection = ""; last ARGS; } if ($verflag) { $verflag = 0; last ARGS; } push (@args, $arg); } } } # ---------------------------------------------------------------------- # exec_version # # This routine attaches the version-specific locker and execs # that startup script. # # ---------------------------------------------------------------------- sub exec_version { local ($version_locker, $sw_version, $version, $software) = @_; local ($pos, $program, $bindir); $pos = rindex ($0, "/") + 1; $program = substr ($0, $pos); if ($isathena) { system ("attach $sw_version") if ! (-e "$version_locker"); if (! -d "$version_locker") { print <); close BINDIR; $executable = "$bindir/$program"; if ( -e $executable) { exec ($executable, @args); # Should not get here exit 0; } else { print <