#!/bin/csh # # Interactive patch cluster installation script # Jason Kraftcheck - University of Wisconsin # if ( ! -f patch_order ) then echo "Could not find patch_order file in current directory." exit 1 endif if ( ! $?PAGER ) then set PAGER = more endif unset install_all set current = 0 set patch_count = `wc -l < patch_order` set prompt = " (i)nstall (r)eadme (s)kip (a)ll install (q)uit" foreach patch ( `cat patch_order` ) @ current++ unset have_package # split patch into number and revision set patch_name = `echo $patch | cut -c 1-6` set patch_rev = `echo $patch | cut -c 8-9` # Get the revision of the patch currently installed. # # Showrev lists all revisions of all installed patches. # Grep for the lines for this patch, sort them resulting in # the latest revision being last, and use tail to grab just # that line. set installed = `showrev -p | grep "^Patch: $patch_name" | sort | tail -1` if ( "$installed" != "" ) then set install_rev = `echo $installed | cut -f2 -d ' ' | cut -f2 -d- -s` set have_package else set install_rev = 0 # If there is no version of the patch already installed # check to make sure at least one of the packages the # patch patches is installed on the system unset have_package foreach package ( $patch/* ) if ( ! -d $package ) then continue endif pkginfo `basename $package` >& /dev/null if ( $status == 0 ) then set have_package endif end endif # Construct line to output for patch set version_line = "$current/$patch_count patch: $patch_name" if ( ! $?have_package ) then set version_line = "$version_line -- package(s) not installed --" else set version_line = "$version_line new version: $patch_rev installed:" if ( $install_rev != 0 ) then set version_line = "$version_line $install_rev" else set version_line = "$version_line none" endif endif # If installing this patch isn't an option, just output # the line constructed above and go on to the next patch if ( ! $?have_package || $install_rev >= $patch_rev ) then echo "$version_line" continue; endif # Construct a description line from fields of the # patch README file set description_line = "" set readme = "$patch/README.$patch" if ( -f $readme ) then set description = `grep "^Synopsis: " $readme | cut -d: -f 2-` set date = `grep "^Date: " $readme | cut -d: -f 2-` set description_line = " $date $description" endif # If install all without prompting, then set # install appropriately and print out the # description lines before installing unset install if ( $?install_all ) then set install='y' echo "$version_line" echo "$description_line" endif # Prompt for what to do. Loop until the user decides # either to or not to install the patch. while ( ! $?install ) echo "$version_line" echo "$description_line" echo "$prompt" echo -n "> " set choice = $< switch ( $choice ) case "i": # install set install='y' breaksw case "s": # skip set install='n' breaksw case "a": # install all set install_all set install='y' breaksw case "q": # quit exit case "r": # readme $PAGER $readme breaksw default: # bad input echo "$choice?" breaksw endsw end # while ( ! $?install ) # finally, install the damn patch if ( "$install" == "y" ) then patchadd $patch endif end # foreach patch