Listing 2: PatchDist
#!/bin/ksh
# PatchDist
PATH=/bin:/usr/bin:/sbin ; export PATH
HOSTNAME=`/bin/hostname`
ID=`/usr/ucb/whoami`
############ CONFIG 1 ###########
PATCH_HOST="this server"
SCRIPT_HOME="/opt/patches"
INSTALL_PATCH_LOCATION="/tmp"
SERVERS="$SCRIPT_HOME/.SERVERS"
REPOSITORY="$SCRIPT_HOME/repository" # Top directory to OS patch directories
OS1="2.5"
OS2="2.6"
#################################
if [ $HOSTNAME != $PATCH_HOST ]
then
print "You must be on $PATCH_HOST to run this script"
exit
fi
if [ $ID != root ]
then
print "You must be root to run this script"
exit
fi
if [ ! -d $REPOSITORY/$OS1 ]
then
print "You need to create an OS $OS1 specific directory containing patches"
fi
if [ ! -d $REPOSITORY/$OS2 ]
then
print "You need to create an OS $OS2 specific directory containing patches"
fi
clear
print ' '
print " AUTO PATCH INSTALLER"
print ' '; print ' '
print "Enter base version of Solaris (2.5 or 2.6): \c"
read VERSION
print ' '
stty -echo
print "Password for distribution: \c"
read WPASSWORD
stty echo
print ' '; print ' '
ls $REPOSITORY/$VERSION
print ' '
print "Patch Name: \c"
read PATCH_NAME
print ' '
print "Patch Number (Ex. 104553-04): \c"
read PNUMBER
clear
print ' ';print ' '
print "Enter Machine Name(s) Separated By A Space"
print ' '
print "Machine Name(s): \c"
read PN
echo $PN > $SERVERS
############ CONFIG 2 ###########
GET_PATCHED=$(< $SERVERS )
UNTAR_NAME=`echo $PATCH_NAME | sed -e "s/.tar/ /g"`
UC_NAME=`echo $PATCH_NAME | sed -e "s/.Z/ /g"`
RELEASE="$VERSION"
INITIAL_PATCH_LOCATION="$REPOSITORY/$RELEASE/"
##################################
for list in $GET_PATCHED ; do
cd $INITIAL_PATCH_LOCATION
ftp -n $list <<ENDFTP
user root $WPASSWORD
binary
cd $INSTALL_PATCH_LOCATION
hash
put $PATCH_NAME
ENDFTP
done
for distribution in $GET_PATCHED ; do
rsh -n $distribution "uncompress $INSTALL_PATCH_LOCATION/$PATCH_NAME"
rsh -n $distribution "cd $INSTALL_PATCH_LOCATION ; tar -xvf $UC_NAME"
rsh -n $distribution "rm -f $INSTALL_PATCH_LOCATION/$UC_NAME"
done
for distribution in $GET_PATCHED ; do
rsh -n $distribution "cd $INSTALL_PATCH_LOCATION/$PNUMBER ; chmod 750 install_cluster"
rsh -n $distribution "cd $INSTALL_PATCH_LOCATION/$PNUMBER ; ./installpatch . -q"&
rsh -n $distribution "cd $INSTALL_PATCH_LOCATION/$PNUMBER ; ./install_cluster . -q"&
done
# End of File
|