#!/bin/sh # #@(#)SAXupgrade - Copyright (c)2000 Soliton Associates # September 2000 Ruth Uschold # # SAXupgrade: UNIX Upgrade script for SAX, SHARP APL for UNIX # Version 6.0.0 # # This script does the following: # 1. Verify system platform # 2. Verify root userid, and proper umask setting # 3. Shutdown and remove the old SVP # 4. Check status of $SAXLCL tree # 5. Selectively preserve files, and potentially previous version # 6. Stop the B-task scheduler # 7. Stop NSVP # 8. Restore Distribution Files # 9. Copy forward unchanged custom code back to production # 10. Install and start the SVP # # The installer must then perform a number of manual steps. # #******************************************************************************* # Function Definition: Validation # Validation () { trap 'echo "`basename $0`: SAX Upgrade script disconnected - SIGNAL 1" 1>&2; ExitRoute' 1 trap 'echo "`basename $0`: SAX Upgrade script interrupted - SIGNAL 2" 1>&2; ExitRoute' 2 trap 'echo "`basename $0`: SAX Upgrade script terminated - SIGNAL 15" 1>&2; ExitRoute' 15 # # Initialize portable echo parameters # case "`echo 'x\c'`" in 'x\c') n="-n" c=" " #BSD ;; x) c="\c" n=" " #Sys V ;; *) echo "$0 quitting: Can't set up echo." 1>&2 exit 1 ;; esac # PlatformDiff # # Ensure root uid & proper umask # USERNAME=`id | awk -F\( '{print $2 }' | awk -F\) '{ print $1 }'` case $USERNAME in root) UMASK=`umask` case $UMASK in 022) ;; 0022) ;; *) echo "" echo "Your umask setting is "$UMASK"" echo "This is not the recommended setting for SAX upgrade." echo "" echo $n "Do you wish to continue (Y/N) ? [N] " $c read yn if [ -z "$yn" ] then yn="N" fi case $yn in Y|y|yes|YES|Yes) ;; *) echo "" echo "Exiting upgrade procedure....change root uid's" echo "umask setting to 022, and begin again." echo "" exit 1 ;; esac ;; esac ;; *) echo "" echo "You must be logged on as root to run this upgrade." echo "Exiting upgrade procedure.......logon to root uid, and begin again." echo "" exit 1 ;; esac echo "" CDROMdeclaration case $OS in Linux*) Disclaimer ;; *) ;; esac return 0 } #****************************************************************************** # # Function definition: Initialize the CP and RM variables # CPRMinit () { # # find the cp program # if [ -f /usr/bin/cp ] then CP="/usr/bin/cp -prf" elif [ -f /bin/cp ] then CP="/bin/cp -prf" else echo "Cannot locate the cp program" exit 1 fi # # find the rm program # if [ -f /usr/bin/rm ] then RM="/usr/bin/rm" elif [ -f /bin/rm ] then RM="/bin/rm" else echo "Cannot locate the rm program" exit 1 fi } #************************************************************************* # Function Definition: Verify system platform # PlatformDiff () { # # Operating System (e.g. SunOS or AIX) # OS=`uname -s` case $OS in SunOS*) SYSTEM=SUN ID=`uname -r` case $ID in 5.6) PLATFORM="solaris_6" ;; 5.7) PLATFORM="solaris_7" ;; 5.8) PLATFORM="solaris_8" ;; *) echo "" echo " Solaris release number is $ID." echo " This is not supported." exit 1 ;; esac ;; AIX*) SYSTEM=IBM ID=`uname -v` case `uname -r` in 2) PLATFORM="aix_42" ;; 3) PLATFORM="aix_43" ;; *) echo "" echo " AIX release number is `uname -r`" echo " This is not supported." exit 1 ;; esac HOSTNAM=`hostname` if [ -z "$HOSTNAM" ] then echo "This machine has no hostname specified" echo "this will cause its hostid to default to zero," echo "causing problems using files in the future." echo "" echo $n "Do you wish to continue (Y/N) ? [N]" $c read yn if [ -z "$yn" ] then yn="N" fi case $yn in N|n|no) exit 1 ;; Y|y|yes|YES|Yes) ;; *) echo "" echo "You have entered an invalid response. Please try again." echo "" ;; esac fi ;; Linux*) SYSTEM=LINUX ID=`uname -r` PLATFORM="linux" ;; *) echo "SHARP APL for UNIX is currently unsupported on "$OS$ID"" echo "Contact Soliton support before proceeding." exit 1 ;; esac echo "This is the upgrade procedure for Version 6.0 of SHARP APL for UNIX" echo "on "$OS$ID"" echo "" echo $n "Do you wish to continue (Y/N) ? [Y]" $c read yn if [ -z "$yn" ] then yn="Y" fi case $yn in Y|y|yes|YES|Yes) ;; N|n|no) exit 1 ;; *) echo "" echo "You have entered an invalid response. Please try again." echo "" PlatformDiff ;; esac export SYSTEM export PLATFORM export OS return 0 } #******************************************************************************* # Function Definition: Display Disclaimer and request approval. # Called by PlatformDiff # Disclaimer () { awk '{print}' $SRCDIR/disclaimer|more echo "" echo $n "Do you agree to the terms of the disclaimer (Y/N)? [N] " $c read yn if [ -z "$yn" ] then yn="N" fi case $yn in Y|y|yes|YES|Yes) : ;; *) echo "Exiting upgrade procedure" exit 1 ;; esac return 0 } #******************************************************************************* # Function Definition: Identify location of CD-ROM. # Called by Validation # CDROMdeclaration () { echo "" echo $n "Are your source files located on a cdrom (Y/N) ? [Y] " $c read yn if [ -z "$yn" ] then yn="Y" fi case $yn in Y|y|yes|YES|Yes) echo "Enter the name of the mounted cdrom, e.g. '/cdrom'." read CDDIR SRCDIR="/"$CDDIR"/"$PLATFORM"" ;; N|n|no) echo "Enter the directory path containing the source files." # # Note - if entering a source file location other than "cdrom", # you must enter the directory that is one level up from "bin" # and "lib", etc. # read SRCDIR ;; *) echo "" echo "Please respond yes or no." CDROMdeclaration ;; esac if [ ! -d "$SRCDIR" ] then echo "" echo "Cannot find the specified location." echo "Check that CD-ROM is mounted or that directory name is" echo "correct, and try again." echo "" CDROMdeclaration fi # # Check existence of some distributed file # if [ ! -d "$SRCDIR/lib/wss32" ] then echo "" echo "The source files do not exist in the specified directory." echo "" CDROMdeclaration fi export SRCDIR return 0 } #******************************************************************************* # Function Definition: Initialization # Initialization () { # # Identify previously used saxdir # echo "" echo "Enter the entire pathname of the previously installed version of SAX, " echo " or hit enter to use the default directory /usr/sax/rel." read OLDSAX # if [ -z "$OLDSAX" ] then OLDSAX=/usr/sax/rel fi # if [ -d "$OLDSAX" ] then if [ ! -d "$OLDSAX/bin" ] then echo "" echo "Cannot find the previously installed version of SAX as specified" echo "Verify the pathname and try again." echo "" Initialization else if [ ! -d "$OLDSAX/etc" ] then echo "" echo "Cannot find the previously installed version of SAX" echo " as specified. Verify the pathname and try again." echo "" Initialization fi fi else echo "" echo "Cannot find the directory as specified" echo "Verify the pathname and try again." echo "" Initialization fi SAXDIR=$OLDSAX export OLDSAX SAXDIR return 0 } #****************************************************************************** # # Function definition: shutdown and remove the old SVP - # called by Main Routine # SVPremove () { $SAXDIR/etc/conf/svp.stop $SAXDIR/etc/conf/svp.remove return 0 } #****************************************************************************** # Function Definition: determine user's preference for location of new # SAX files - called by Main Routine # Usersrel () { r=0 while [ "$r" -eq 0 ] do echo "" echo "Would you like to install the new version in the default (usr/sax/rel)" echo $n "directory (Y/N) ? [Y] " $c read yn if [ -z "$yn" ] then yn="Y" fi case $yn in Y|y|yes|YES|Yes) r=1 echo "" echo "Your files will be installed in the directory /usr/sax/rel" echo "" USERRELDIR=/usr/sax/rel export USERRELDIR Mkdircheck ;; N|n|no) r=1 echo "" echo "Enter the pathname for the release library files." read USERRELDIR export USERRELDIR Mkdircheck ;; *) echo "" echo "You have entered an invalid response.....try again" ;; esac done return 0 } #***************************************************************************** # Function Definition : create directory structure for trace files # Tracedir () { echo " " cd $USERRELDIR if [ ! -d trc ] then if [ -f trc ] then ${RM} trc fi mkdir trc case $? in 0) ;; *) echo "" echo "Cannot create the trc directory." echo "check file permissioning in "$USERRELDIR" and try again." echo "" exit 1 ;; esac fi cd trc if ls "$USERRELDIR/etc/" | grep ctl > /dev/null then ${CP} -pr $USERRELDIR/etc/*ctl . else echo "" echo "No *ctl files exist in $USERRELDIR/etc. Cannot copy files to trc directory." fi return 0 } #***************************************************************************** # Function Definition: Check the existence of the new production library, # then create it if necessary. Called by Usersrel # Mkdircheck () { if [ ! -d "$USERRELDIR" ] then mkdir $USERRELDIR case $? in 0) ;; *) echo "" echo "Cannot create the install path requested. " echo "Check file permissioning within the parent directory, and try again." echo "" echo "Exiting upgrade procedure now." exit 1 ;; esac else r1=0 while [ "$r1" -eq 0 ] do echo"" echo ""$USERRELDIR" already exists" echo "" echo $n "Do you wish to overwrite it (Y/N) ? [N]" $c read yn if [ -z "$yn" ] then yn="N" fi case $yn in Y|y|yes|YES|Yes) r1=1 ;; N|n|no) r1=1 echo "" echo "Exiting upgrade procedure now." exit 1 ;; *) echo "" echo "You have entered an invalid response..." echo "" ;; esac done fi return 0 } #******************************************************************************* # Function Definition: Identify location for custom code. # Called by Main Routine # LCLdeclaration () { LCLset=0 while [ "$LCLset" -eq 0 ] do echo "" echo " The default backup location for the custom code files is /usr/sax/local." echo $n "Would you like to use the default location (Y/N) ? [Y] " $c read yn if [ -z "$yn" ] then yn="Y" fi case $yn in Y|y|yes|YES|Yes) LCLset=1 LCLSAX=/usr/sax/local export LCLSAX ;; N|n|no) LCLset=1 echo "" echo "Enter the path of the backup location of the custom code files" echo "" read LCLSAX export LCLSAX ;; *) echo "" echo "You have entered an invalid response......try again." echo "" ;; esac done if [ ! -d "$LCLSAX" ] then mkdir $LCLSAX case $? in 0) ;; *) echo "" echo "Cannot create the path requested. " echo "Check file permissioning within the parent directory, and try again." echo "" LCLdeclaration ;; esac else LCLwr=0 while [ "$LCLwr" -eq 0 ] do echo "" echo ""$LCLSAX" already exists." echo "" echo $n "Do you wish to overwrite it (Y/N)? [N] " $c read yn if [ -z "$yn" ] then yn="N" fi case $yn in Y|y|yes|YES|Yes) LCLwr=1 ;; N|n|no) LCLwr=1 echo "" echo "choose overwrite or another location." echo "" LCLdeclaration ;; *) echo "" echo "You have entered an invalid response." echo "" ;; esac done fi echo "" echo "Your custom code files will be saved in "$LCLSAX"." echo "" export LCLSAX return 0 } #**************************************************************** # Function Definition: shutdown BTASK Scheduler # BTASKhandler () { echo $n "Are you currently running the btask scheduler (Y/N) ? [N] " $c read yn if [ -z "$yn" ] then yn="N" fi case $yn in N|n|no) ;; Y|y|yes|YES|Yes) echo "" echo "The btask scheduler must not be running." echo "Ensuring the btask scheduler is down." echo "" $SAXDIR/etc/btask.scheduler stop sleep 5 ;; *) echo "" echo "You have entered an invalid response. Please try again." echo "" BTASKhandler ;; esac return 0 } #**************************************************************** # Function Definition: shutdown NSVP # NSVPhandler () { echo "" echo "ensuring NSVP is down" echo "" PID=`ps -ea | grep nsvpd | awk '{ print$1}'` if [ -n "$PID" ] then cd $SAXDIR/etc echo "" echo "NSVP is running - shutting it down now...." ./nsvp.script stop echo "" fi sleep 5 return 0 } #***************************************************************************** # Function Definition: Check local directory tree # # CheckLocalTree () { echo "" echo "Creating custom code repositories as necessary within $LCLSAX " if [ ! -d $LCLSAX/etc ] then mkdir -p $LCLSAX/etc fi if [ ! -d $LCLSAX/lib/term ] then mkdir -p $LCLSAX/lib/term fi if [ ! -d $LCLSAX/etc/conf ] then mkdir -p $LCLSAX/etc/conf fi if [ ! -d $LCLSAX/lib/wss6 ] then mkdir -p $LCLSAX/lib/wss6 fi if [ ! -d $LCLSAX/lib/btask ] then mkdir -p $LCLSAX/lib/btask fi # echo "" echo "Copying custom code from current production library to $LCLSAX " echo "" ${CP} -p $SAXDIR/etc/nsvp.hosts $LCLSAX/etc/ ${CP} -p $SAXDIR/etc/nsvp.shells $LCLSAX/etc/ ${CP} -p $SAXDIR/etc/site.nsvp $LCLSAX/etc/ ${CP} -p $SAXDIR/etc/site.svp $LCLSAX/etc/ ${CP} -p $SAXDIR/etc/apd.tab $LCLSAX/etc/ ${CP} -p $SAXDIR/etc/apd_t.tab $LCLSAX/etc/ ${CP} -p $SAXDIR/etc/apd_nsvp.tab $LCLSAX/etc/ # uncomment the following line in versions after 6.0.0 # ${CP} -p $SAXDIR/etc/saxfs.cnf $LCLSAX/etc ${CP} -p $SAXDIR/etc/.saxif $LCLSAX/etc/ ${CP} -p $SAXDIR/etc/conf/rc_local.sax $LCLSAX/etc/conf/ if [ -f $SAXDIR/lib/wss6/NsvpX.sf ] then ${CP} -p $SAXDIR/lib/wss6/NsvpX.sf $LCLSAX/lib/wss6/ fi ${CP} -p $SAXDIR/etc/site.btask $LCLSAX/etc/ ${CP} -p $SAXDIR/lib/btask/btasks.sf $LCLSAX/lib/btask/ ${CP} -p $SAXDIR/lib/btask/blog.sf $LCLSAX/lib/btask/ return 0 } #***************************************************************** # # Function Definition: BackupAsk BackupAsk () { echo "" echo "Do you wish to backup the entire SAX library " echo $n "prior to this installation (Y/N) ? [Y] " $c read yn if [ -z "$yn" ] then yn="Y" fi case $yn in Y|y|yes|YES|Yes) Backuprel ;; N|n|no) ;; *) echo "" echo "You have entered an invalid response" BackupAsk ;; esac return 0 } #***************************************************************************** # Function Definition: Create backup library for existing release # Backuprel () { echo "" echo "Enter the entire pathname for your backup directory." read BKUPNAME if [ ! -d "$BKUPNAME" ] then mkdir $BKUPNAME case $? in 0) Copyrel ;; *) echo "" echo "Cannot create backup pathname. Check file permissionings and space within the parent directory, and try again" Backuprel ;; esac else echo "" echo ""$BKUPNAME" already exists" echo "" echo $n "Do you wish to overwrite it (Y/N) ? [N]" $c read yn if [ -z "$yn" ] then yn="N" fi case $yn in Y|y|yes|YES|Yes) Copyrel ;; N|n|no) echo "Choose overwrite or another location." echo "" Backuprel ;; *) echo "" echo "You have entered an invalid response...." echo "" Backuprel ;; esac fi return 0 } #**************************************************************************** # Function Definition: Copy entire existing release library # Called by BackupRel # Copyrel () { case $OS in SunOS*) DFCHK=`df -k $BKUPNAME | grep "dev" | awk '{print$4}'` if [ "$DFCHK" -gt 10000 ] then echo "" echo "copying previous release library - Patience Please" cd $SAXDIR find . -depth -print | cpio -pdmu $BKUPNAME case $? in 0) echo "" echo "A copy of the previous release library has been stored within "$BKUPNAME"" ;; *) echo "" echo "Backup of previous release did not complete successfully." exit 1 ;; esac else echo "There is not enough space within the parent directory" echo "to backup "$SAXDIR" within "$BKUPNAME"" echo "" echo "Please choose another backup library" #rm -r $BKUPNAME Backuprel fi ;; Linux*) DFCHK=`df -k $BKUPNAME | grep "dev" | awk '{print$4}'` if [ "$DFCHK" -gt 10000 ] then echo "" echo "Copying previous release library - Patience Please" cd $SAXDIR find . -depth -print | cpio -pdmu $BKUPNAME case $? in 0) echo "" echo "A copy of the previous release library has been stored within "$BKUPNAME"" ;; *) echo "" echo "Backup of previous release did not complete successfully." exit 1 ;; esac else echo "There is not enough space within the parent directory" echo "to backup "$SAXDIR" within "$BKUPNAME"" echo "" echo "Please choose another backup library" Backuprel fi ;; AIX*) DFCHK=`df -k $BKUPNAME | grep "dev" | awk '{print$3}'` if [ "$DFCHK" -gt 10000 ] then echo "" echo "Copying previous release library - Patience Please" cd $SAXDIR find . -depth -print | cpio -pdmu $BKUPNAME case $? in 0) echo "" echo "A copy of the previous release library has been stored within "$BKUPNAME"" ;; *) echo "" echo "Backup of previous release did not complete successfully." exit 1 ;; esac else echo "There is not enough space within the parent directory" echo "to backup "$SAXDIR" within "$BKUPNAME"" echo "" echo "Please choose another backup library" #rm -r $BKUPNAME Backuprel fi ;; esac return 0 } #***************************************************************************** # # Function Definition: Process source files # ProcessFiles () { cd $USERRELDIR echo "" echo "Copying the source files to the release directory........" echo "" cd $USERRELDIR ${CP} $SRCDIR/* . case $? in 0) echo "" echo "If installing from a CD-ROM, remember to " echo "unmount and remove it when completed....." ;; *) echo "" echo "Problem restoring SHARP APL distribution files." exit 1 ;; esac return 0 } #**************************************************************************** # Function Definition: Copy forward custom modules unchanged in new version # CopyForward () { echo "" echo "Copying forward unchanged custom code from previous library to production" echo "" ${CP} -p $LCLSAX/etc/nsvp.hosts $USERRELDIR/etc/ ${CP} -p $LCLSAX/etc/site.nsvp $USERRELDIR/etc ${CP} -p $LCLSAX/etc/site.svp $USERRELDIR/etc/ # remove comment on following line in versions after 6.0.0: # ${CP} -p $LCLSAX/etc/saxfs.cnf $USERRELDIR/etc if [ -f $LCLSAX/lib/wss6/NsvpX.sf ] then ${CP} -p $LCLSAX/lib/wss6/NsvpX.sf $USERRELDIR/lib/wss6/ fi ${CP} -p $LCLSAX/etc/site.btask $USERRELDIR/etc/ ${CP} -p $LCLSAX/lib/btask/btasks.sf $USERRELDIR/lib/btask/ ${CP} -p $LCLSAX/lib/btask/blog.sf $USERRELDIR/lib/btask/ echo "" return 0 } #**************************************************************************** # Function Definition: Install and start the SVP # SVPsetup () { SAXDIR=$USERRELDIR export SAXDIR $USERRELDIR/etc/conf/svp.install $USERRELDIR/etc/conf/rc_local.sax start return 0 } #**************************************************************************** # Function Definition: Exit Route # ExitRoute () { echo "" echo "Exiting script now..." exit } #******************************************************************************* # Main Logic Routine, function calls # Validation CPRMinit Initialization SVPremove BackupAsk Usersrel LCLdeclaration BTASKhandler NSVPhandler CheckLocalTree case $SYSTEM in SUN) ProcessFiles ;; IBM) ProcessFiles ;; LINUX) ProcessFiles ;; *) echo " " echo "SHARP APL for UNIX is currently unsupported on " echo ""$SYSTEM" systems." exit 1 ;; esac CopyForward Tracedir SVPsetup ExitRoute