#!/bin/csh -f # # This script will copy a new release of Alex into /usr/alexsrvr. # # If there is an existing "/alex" mounted then this should # be run as "alexsrvr", if not it should be run as "root" # so that we can first mount alex. # echo "args = $0 $1" set ALEXSRVR = alexsrvr set ALEXSRVRHOME = ~$ALEXSRVR set Result = 0 set RELEASEDIR = /alex/edu/cmu/cs/sp/alex/src set EFFUSER = `whoami` if (($EFFUSER != $ALEXSRVR) && ($EFFUSER != root) && ($EFFUSER != rootl)) then echo "This script needs to be run as either: alexsrvr, root, or rootl" set Result = -1 goto theend else echo "Looks like we are running with right user id" endif echo "Checking that /alex is mounted someplace" if (! -d /alex/edu) then if (($EFFUSER != root) && ($EFFUSER != rootl)) then echo "ERROR: /alex is not working and I need to be run as root to fix that" set Result = -1 goto theend else mkdir /alex if (-f /usr/misc/.nfs/etc/mount) then set MOUNT = /usr/misc/.nfs/etc/mount else if (-f /etc/mount) then set MOUNT = /etc/mount else set MOUNT = mount endif endif $MOUNT -o timeo=30,retrans=300,rsize=1000,soft,intr alex.sp.cs.cmu.edu:/ /alex if (! -d /alex/edu) then $MOUNT -o timeo=30,retrans=300,rsize=1000,soft,intr furmint.nectar.cs.cmu.edu:/ /alex if (! -d /alex/edu) then $MOUNT alex.sp.cs.cmu.edu:/ /alex if (! -d /alex/edu) then echo "ERROR Could not mount alex" set Result = -1 goto theend endif endif endif endif endif echo "Forcing update of directory information" cat $RELEASEDIR/.alex.update >& /dev/null set MASTERGR = $RELEASEDIR/getalex if (($EFFUSER == root) || ($EFFUSER == rootl)) then echo "Now that /alex exists we are going to run as alexsrvr" su alexsrvr $MASTERGR $1 if ($status != 0) then echo "Seems had a problem while alexsrvr was running script" set Result = -1 goto theend else echo "Finished with su" endif ps -aux | grep -v grep | grep alex.nanny if ($status != 0) then echo "Starting Alex - which does a mountalex" /usr/alexsrvr/bin/start.alex & echo "Going to wait for 60 seconds" sleep 60 Result = 0 goto theend else echo "Think Alex is running" set Result = 0 goto mountalex endif endif echo "Checking to see if this is the current version of getalex" if (-f $MASTERGR) then diff $0 $MASTERGR > /dev/null if (($status != 0) && ($0 != $MASTERGR)) then echo "We have an old version - use the new one" csh $MASTERGR $1 goto mountalex else echo "We are running the current version of getalex" endif endif # special release or just the default? if (.$1. == ..) then set ALEXRELEASE = $RELEASEDIR/alex.tar.Z else set ALEXRELEASE = $RELEASEDIR/$1 endif # In case we are using out own alexd we first copy the release then replace old cd $ALEXSRVRHOME mv alexsrvr alexsrvr.`/bin/date | awk '{print $2_$3_$4}'` zcat $ALEXRELEASE | tar xvf - if ($status != 0) then echo "Tar seems to have had trouble - we are exiting" set Result = -1 goto theend endif echo "Finished the TAR" set RELSIZE = `du alexsrvr | tail -1 | awk '{print $1}'` echo "Release size is $RELSIZE" if ($RELSIZE < 1000) then echo "Don't believe that the alex release is this small $RELSIZE KB" set Result = -1 goto theend endif set OLDDIR = old.`/bin/date | awk '{print $2_$3_$4}'` mkdir $OLDDIR mv -f man src doc usr.man usr.src usr.bin usr.lib $OLDDIR echo "Have moved the old directories off to $OLDDIR" set N = alexsrvr mv -f $N/man $N/src $N/doc $N/usr.man $N/usr.src $N/usr.bin $N/usr.lib . echo "Have moved the new directories in" if (! -d lib) then echo "Looks like there is no old lib so bringing in new" mv -f $N/lib . endif if (! -d etc) then echo "Looks like there is no old etc so bringing in new" mv -f $N/etc . endif # see if he has done this before if (-f $OLDDIR/src/config.h) then # He has done this before - see if his old config file is same as new mv src/config.h src/config.h.new cp $OLDDIR/src/config.h src/config.h diff src/config.h src/config.h.new if ($status != 0) then echo "Your old file < src/config.h is a bit different from the new > src/config.h.new" echo -n "Should I just use your old one < (o) or just the new > (n) or exit (x)? [o] " set INPUT = $< if ($INPUT == x) then echo "OK I will exit. After fixing up config.h run make install." set Result = -1 goto theend endif if ($INPUT == n) then mv src/config.h src/config.old mv src/config.h.new src/config.h endif else echo "Looks like you did not modify config.h" endif # other INPUTs just fall through diff $OLDDIR/src/Makefile src/Makefile if ($status != 0) then echo "Your old makefile < is different from the new one > ." echo -n "Should I just use your old < (o) one or the new one > (n) or exit (x)? [n]" set INPUT = $< if ($INPUT == x) then echo "OK I will exit. After fixing up config.h run make install." set Result = -1 goto theend endif if ($INPUT == o) then mv src/Makefile src/Makefile.new cp $OLDDIR/src/Makefile src/Makefile endif else echo "Looks like you did not modify the Makefile" endif else echo "Looks like you have not installed this before so I'll try" endif # Lets compile and run if ($EFFUSER == alexsrvr) then tail -1 $ALEXSRVRHOME/src/alex.h echo "Going to run make" if (! -d $ALEXSRVRHOME/bin) mkdir $ALEXSRVRHOME/bin echo "Going to run make but without rpcgen" (cd $ALEXSRVRHOME/src; make norpcgen; make install) if ($status == 0) goto lookinggood echo "Looks like make had trouble with the full release - let me just try the basics" (cd $ALEXSRVRHOME/src; make norpcgen; make installbasic) if ($status == 0) goto lookinggood echo "Seems we can not compile even the basics without your help ..." echo "It is all in your hands now. Good luck." set Result = -1 goto theend lookinggood: echo "Think we compiled things ok" echo "Going to kill alexd if it is running so alex.nanny starts up new alexd" $ALEXSRVRHOME/bin/grepnkill alexd goto theend endif mountalex: if (($EFFUSER == root) || ($EFFUSER == rootl)) then echo "Going to stop and restart Alex to be sure we are using all new code" $ALEXSRVRHOME/bin/start.alex endif theend: echo "I will start an ls /alex in the background" echo " " /bin/ls /alex & echo " " echo "Your current directory has become " pwd if ($Result == 0) then echo "Run $ALEXSRVRHOME/bin/mountalex on other machines to mount Alex on them." endif exit $Result