2010-08-04 12:43:28 +00:00
|
|
|
#!/bin/sh
|
2010-07-23 18:27:29 +00:00
|
|
|
# IBM(c) 2010 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
#=head1 ospkgs
|
|
|
|
#=head2 Used on Linux only. It installs/updates the rpms thta are from OS distro.
|
|
|
|
# The environment variable OSPKGS contains the rpms to be installed/updated.
|
|
|
|
# On MN, You need to:
|
|
|
|
# 1. update the rpms under /install/os/arch/... directory where 'os' and 'arch'
|
|
|
|
# can be found in the nodetype table.
|
|
|
|
# 2. put new package names to /install/custom/netboot(install)/platform or
|
|
|
|
# /opt/xcat/share/xcat/netboot(install)/platform
|
|
|
|
# directory. The file name is one of the following:
|
|
|
|
# profile.os.arch.pkglist
|
|
|
|
# profile.os.pkglist
|
|
|
|
# profile.arch.pkglist
|
|
|
|
# profile.pkglist
|
|
|
|
# You can run the following commands to install/update the rpms from os distro.
|
|
|
|
# updatenode noderange ospkgs
|
|
|
|
# updatenode noderange -S (this one intslls/updates rpms from os distro as well as otherpkgs)
|
|
|
|
#
|
|
|
|
#=cut
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
debug=0
|
|
|
|
|
2010-07-23 18:59:22 +00:00
|
|
|
if [[ $OSTYPE != linux* ]]; then
|
|
|
|
#not supported on AIX
|
|
|
|
echo "ospkgs script only runs on Linux."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2010-07-23 18:27:29 +00:00
|
|
|
# This command only runs by updatenode command
|
|
|
|
if [[ $UPDATENODE -ne 1 ]]; then
|
|
|
|
echo " Did not install any extra rpms."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$OSPKGS" ]]; then
|
|
|
|
echo "$0: no extra rpms to install"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$NFSSERVER" ]]; then
|
|
|
|
NFSSERVER=$MASTER
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$INSTALLDIR" ]]; then
|
|
|
|
INSTALLDIR="/install"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#check if /install is mounted on the server, we may need to add code to conver NFSSERVER to ip
|
|
|
|
mounted=0;
|
|
|
|
result=`mount |grep /install |grep $NFSSERVER`
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
NFSSERVER=$INSTALLDIR
|
|
|
|
mounted=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$OSPKGDIR" ]]; then
|
|
|
|
OSPKGDIR="$NFSSERVER/$OSVER/$ARCH"
|
|
|
|
if [[ $OSVER = sles* ]]; then
|
|
|
|
OSPKGDIR="$OSPKGDIR/1"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $mounted -eq 0 ]; then
|
|
|
|
OSPKGDIR=${OSPKGDIR/#$INSTALLDIR/$NFSSERVER/}
|
|
|
|
fi
|
|
|
|
|
|
|
|
logger -t xcat "NFSSERVER=$NFSSERVER"
|
|
|
|
logger -t xcat "OSPKGDIR=$OSPKGDIR"
|
|
|
|
logger -t xcat "OSPKGS=$OSPKGS"
|
|
|
|
|
|
|
|
if [ $debug -ne 0 ]; then
|
|
|
|
echo NFSSERVER=$NFSSERVER
|
|
|
|
echo OSPKGDIR=$OSPKGDIR
|
|
|
|
echo OSPKGS = $OSPKGS
|
|
|
|
fi
|
|
|
|
|
2010-07-30 20:20:51 +00:00
|
|
|
pkgs='' #packages
|
|
|
|
groups='' #groups
|
|
|
|
pkgs_d='' #packages to remove
|
2010-08-04 12:43:28 +00:00
|
|
|
|
|
|
|
OIFS=$IFS
|
|
|
|
IFS=$'\n'
|
2010-07-30 20:20:51 +00:00
|
|
|
for x in `echo "$OSPKGS" | tr "," "\n"`
|
|
|
|
do
|
2010-08-04 12:43:28 +00:00
|
|
|
#remove leading and trailing spaces
|
|
|
|
x=`echo $x |sed 's/^ *//;s/ *$//'`
|
|
|
|
#echo "x=$x"
|
|
|
|
pos=`expr index "$x" -`
|
2010-07-30 20:20:51 +00:00
|
|
|
if [ $pos -eq 1 ]; then
|
|
|
|
pkgs_d="$pkgs_d ${x#-}"
|
|
|
|
else
|
2010-08-04 12:43:28 +00:00
|
|
|
pos=`expr index "$x" @`
|
2010-07-30 20:20:51 +00:00
|
|
|
if [ $pos -eq 1 ]; then
|
2010-08-04 12:43:28 +00:00
|
|
|
#remove leading @
|
|
|
|
tmp=${x#@}
|
|
|
|
#remove leading and trailing spaces
|
|
|
|
tmp=`echo $tmp |sed 's/^ *//;s/ *$//'`
|
|
|
|
#if there are spaces in the middle of the name, quote it
|
|
|
|
pos=`expr index "$tmp" "\ "`
|
|
|
|
if [ $pos -gt 0 ]; then
|
|
|
|
groups="$groups \"$tmp\""
|
|
|
|
else
|
|
|
|
groups="$groups $tmp"
|
|
|
|
fi
|
2010-07-30 20:20:51 +00:00
|
|
|
else
|
|
|
|
pkgs="$pkgs $x"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2010-08-04 12:43:28 +00:00
|
|
|
IFS=$OIFS
|
|
|
|
|
|
|
|
if [ $debug -ne 0 ]; then
|
|
|
|
echo "pkgs=$pkgs"
|
|
|
|
echo "groups=$groups"
|
|
|
|
echo "remove pkgs=$pkgs_d"
|
|
|
|
fi
|
2010-07-23 18:27:29 +00:00
|
|
|
|
|
|
|
if [[ $OSVER = sles10* ]]; then
|
2010-07-30 20:20:51 +00:00
|
|
|
#check if rug is installed
|
|
|
|
result=`rpm -q rug`
|
2010-07-23 18:27:29 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-07-30 20:20:51 +00:00
|
|
|
echo "Please install rug on $NODE."
|
2010-07-23 18:27:29 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#remove old repo
|
2010-07-30 20:20:51 +00:00
|
|
|
old_repo=`rug sl |grep -e "^[0-9]" | cut -f2 -d '|'`
|
2010-07-23 18:27:29 +00:00
|
|
|
for x in $old_repo
|
|
|
|
do
|
2010-07-30 20:20:51 +00:00
|
|
|
result=`rug sd $x`
|
2010-07-23 18:27:29 +00:00
|
|
|
done
|
2010-07-30 20:20:51 +00:00
|
|
|
result=`rug refresh 2>&1`
|
2010-07-23 18:27:29 +00:00
|
|
|
if [ $debug -ne 0 ]; then
|
2010-07-30 20:20:51 +00:00
|
|
|
echo "rug refresh"
|
2010-07-23 18:27:29 +00:00
|
|
|
echo $result
|
|
|
|
fi
|
|
|
|
|
|
|
|
#add new repo
|
|
|
|
if [ $mounted -eq 0 ]; then
|
|
|
|
path="ftp://$OSPKGDIR"
|
|
|
|
else
|
2010-07-30 20:20:51 +00:00
|
|
|
path="dir://$OSPKGDIR"
|
2010-07-23 18:27:29 +00:00
|
|
|
fi
|
2010-07-30 20:20:51 +00:00
|
|
|
result=`rug sa $path $OSVER`
|
2010-07-23 18:27:29 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-07-30 20:20:51 +00:00
|
|
|
logger -t xcat "ospkgs: rug sa $path $OSVER\n $result"
|
|
|
|
echo "ospkgs: rug sa $path $OSVER\n $result"
|
2010-07-23 18:27:29 +00:00
|
|
|
fi
|
2010-07-30 20:20:51 +00:00
|
|
|
result=`rug sub $OSVER`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
logger -t xcat "ospkgs: rug sub $OSVER\n $result"
|
|
|
|
echo "ospkgs: rug sub $OSVER\n $result"
|
|
|
|
fi
|
|
|
|
result=`rug refresh 2>&1`
|
2010-07-23 18:27:29 +00:00
|
|
|
if [ $debug -ne 0 ]; then
|
2010-07-30 20:20:51 +00:00
|
|
|
echo "rug refresh"
|
2010-07-23 18:27:29 +00:00
|
|
|
echo $result
|
|
|
|
fi
|
|
|
|
|
2010-07-30 20:20:51 +00:00
|
|
|
result=`rug update -y --agree-to-third-party-licences`
|
2010-07-23 18:27:29 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-07-30 20:20:51 +00:00
|
|
|
logger -t xcat "rug update -y --agree-to-third-party-licences\n $result"
|
|
|
|
echo "ospkgs: rug update -y --agree-to-third-party-licences\n $result"
|
2010-07-23 18:27:29 +00:00
|
|
|
else
|
|
|
|
if [ $debug -ne 0 ]; then
|
2010-07-30 20:20:51 +00:00
|
|
|
echo "rug update -y --agree-to-third-party-licences"
|
|
|
|
echo $result
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#install the new patterns if any
|
|
|
|
if [ -n "$groups" ]; then
|
|
|
|
cmd="rug install -y --agree-to-third-party-licences -t pattern $groups"
|
|
|
|
result=`$cmd 2>&1`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
logger -t xcat "ospkgs: $cmd\n $result"
|
|
|
|
echo "ospkgs: $cmd"
|
2010-07-23 18:27:29 +00:00
|
|
|
echo $result
|
2010-07-30 20:20:51 +00:00
|
|
|
else
|
|
|
|
if [ $debug -ne 0 ]; then
|
|
|
|
echo "ospkgs: $cmd"
|
|
|
|
echo $result
|
|
|
|
fi
|
2010-07-23 18:27:29 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#install new rpms if any
|
2010-07-30 20:20:51 +00:00
|
|
|
if [ -n "$pkgs" ]; then
|
|
|
|
cmd="rug install -y --agree-to-third-party-licences $pkgs"
|
|
|
|
result=`$cmd 2>&1`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
logger -t xcat "ospkgs: $cmd\n $result"
|
|
|
|
echo "ospkgs: $cmd"
|
2010-07-23 18:27:29 +00:00
|
|
|
echo $result
|
2010-07-30 20:20:51 +00:00
|
|
|
else
|
|
|
|
if [ $debug -ne 0 ]; then
|
|
|
|
echo "ospkgs: $cmd"
|
|
|
|
echo $result
|
|
|
|
fi
|
2010-07-23 18:27:29 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-07-30 20:20:51 +00:00
|
|
|
#remove some packages if specified
|
|
|
|
if [ -n "$pkgs_d" ]; then
|
|
|
|
cmd="rug remove -y $pkgs_d"
|
|
|
|
result=`$cmd 2>&1`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
logger -t xcat "ospkgs: $cmd\n $result"
|
|
|
|
echo "ospkgs: $cmd"
|
|
|
|
echo $result
|
|
|
|
else
|
|
|
|
if [ $debug -ne 0 ]; then
|
|
|
|
echo "ospkgs: $cmd"
|
|
|
|
echo $result
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2010-07-23 18:27:29 +00:00
|
|
|
elif [[ $OSVER = sles11* ]]; then
|
|
|
|
#check if zypper is installed
|
|
|
|
result=`rpm -q zypper`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Please install zypper on $NODE."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
old_repo=`zypper lr |grep -e "^[0-9]" | cut -f2 -d '|'`
|
|
|
|
for x in $old_repo
|
|
|
|
do
|
|
|
|
result=`zypper rr $x`
|
|
|
|
done
|
|
|
|
result=`zypper --non-interactive refresh 2>&1`
|
|
|
|
if [ $debug -ne 0 ]; then
|
|
|
|
echo "zypper --non-interactive refresh"
|
|
|
|
echo $result
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $mounted -eq 0 ]; then
|
|
|
|
path="ftp://$OSPKGDIR"
|
|
|
|
else
|
|
|
|
path="file://$OSPKGDIR"
|
|
|
|
fi
|
|
|
|
result=`zypper ar $path $OSVER`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
logger -t xcat "ospkgs: zypper ar $path $OSVER\n $result"
|
|
|
|
echo "ospkgs: zypper ar $path $OSVER\n $result"
|
|
|
|
fi
|
|
|
|
|
|
|
|
result=`zypper --non-interactive refresh 2>&1`
|
|
|
|
if [ $debug -ne 0 ]; then
|
|
|
|
echo "zypper --non-interactive refresh"
|
|
|
|
echo $result
|
|
|
|
fi
|
|
|
|
|
|
|
|
#upgrade the all existing rpms
|
|
|
|
result=`zypper --non-interactive update --auto-agree-with-licenses`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
logger -t xcat "ospkgs: zypper --non-interactive update --auto-agree-with-licenses\n $result"
|
|
|
|
echo "ospkgs: zypper --non-interactive update --auto-agree-with-licenses\n $result"
|
|
|
|
else
|
|
|
|
if [ $debug -ne 0 ]; then
|
2010-07-30 20:20:51 +00:00
|
|
|
echo "ospkgs: zypper --non-interactive update --auto-agree-with-licenses"
|
|
|
|
echo $result
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#install the new patterns if any
|
|
|
|
if [ -n "$groups" ]; then
|
|
|
|
cmd="zypper install -y --auto-agree-with-licenses -t pattern $groups"
|
|
|
|
result=`$cmd 2>&1`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
logger -t xcat "ospkgs: $cmd\n $result"
|
|
|
|
echo "ospkgs: $cmd"
|
2010-07-23 18:27:29 +00:00
|
|
|
echo $result
|
2010-07-30 20:20:51 +00:00
|
|
|
else
|
|
|
|
if [ $debug -ne 0 ]; then
|
|
|
|
echo "ospkgs: $cmd"
|
|
|
|
echo $result
|
|
|
|
fi
|
2010-07-23 18:27:29 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#install new rpms if any
|
2010-07-30 20:20:51 +00:00
|
|
|
if [ -n "$pkgs" ]; then
|
|
|
|
cmd="zypper install -y --auto-agree-with-licenses $pkgs"
|
|
|
|
result=`$cmd 2>&1`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
logger -t xcat "ospkgs: $cmd $result"
|
|
|
|
echo "ospkgs: $cmd"
|
|
|
|
echo $result
|
|
|
|
else
|
|
|
|
if [ $debug -ne 0 ]; then
|
|
|
|
echo "ospkgs: $cmd"
|
|
|
|
echo $result
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#remove some packages if specified
|
|
|
|
if [ -n "$pkgs_d" ]; then
|
|
|
|
cmd="zypper remove -y $pkgs_d"
|
|
|
|
result=`$cmd 2>&1`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
logger -t xcat "ospkgs: $cmd $result"
|
|
|
|
echo "ospkgs: $cmd"
|
2010-07-23 18:27:29 +00:00
|
|
|
echo $result
|
2010-07-30 20:20:51 +00:00
|
|
|
else
|
|
|
|
if [ $debug -ne 0 ]; then
|
|
|
|
echo "ospkgs: $cmd"
|
|
|
|
echo $result
|
|
|
|
fi
|
2010-07-23 18:27:29 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
#check if yum is installed
|
|
|
|
result=`rpm -q yum`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Please install yum on $NODE."
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
#remove old repo
|
|
|
|
mkdir -p /etc/yum.repos.d
|
|
|
|
result=`rm /etc/yum.repos.d/*.repo 2>&1`
|
|
|
|
result=`yum clean all`
|
|
|
|
|
|
|
|
#create new repo file
|
|
|
|
REPOFILE="/etc/yum.repos.d/$OSVER.repo"
|
|
|
|
echo "[$OSVER]" > $REPOFILE
|
|
|
|
echo "name=$OSVER" >> $REPOFILE
|
|
|
|
if [ $mounted -eq 0 ]; then
|
|
|
|
echo "baseurl=ftp://$OSPKGDIR" >> $REPOFILE
|
|
|
|
else
|
|
|
|
echo "baseurl=file://$OSPKGDIR" >> $REPOFILE
|
|
|
|
fi
|
|
|
|
echo "enabled=1" >> $REPOFILE
|
|
|
|
echo "gpgcheck=0" >> $REPOFILE
|
|
|
|
|
|
|
|
#import the release key?
|
|
|
|
#my $key = "$installDIR/$os/$arch/RPM-GPG-KEY-redhat-release";
|
|
|
|
#my $tmp = "/tmp/RPM-GPG-KEY-redhat-release";
|
|
|
|
#my $tgt = "root@" . $node;
|
|
|
|
#$out = `scp $key $tgt:$tmp`;
|
|
|
|
#$out = `ssh $node "rpm --import $tmp"`;
|
|
|
|
|
|
|
|
|
|
|
|
#upgrade the existing rpms
|
|
|
|
result=`yum -y upgrade 2>&1`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
logger -t xcat "ospkgs: yum -y upgrade\n $result"
|
|
|
|
echo "ospkgs: yum -y upgrade\n $result"
|
|
|
|
else
|
|
|
|
if [ $debug -ne 0 ]; then
|
2010-08-04 12:43:28 +00:00
|
|
|
echo "ospkgs: yum -y upgrade"
|
2010-07-23 18:27:29 +00:00
|
|
|
echo $result
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-07-30 20:20:51 +00:00
|
|
|
#install new groups if any
|
|
|
|
if [ -n "$groups" ]; then
|
2010-08-04 12:43:28 +00:00
|
|
|
cmd="echo $groups| xargs yum -y groupinstall"
|
|
|
|
result=`echo $groups | xargs yum -y groupinstall 2>&1`
|
2010-07-30 20:20:51 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
logger -t xcat "ospkgs: $cmd\n $result"
|
|
|
|
echo "ospkgs: $cmd"
|
|
|
|
echo $result
|
|
|
|
else
|
|
|
|
if [ $debug -ne 0 ]; then
|
|
|
|
echo "ospkgs: $cmd"
|
|
|
|
echo $result
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-07-23 18:27:29 +00:00
|
|
|
#install new rpms if any
|
2010-07-30 20:20:51 +00:00
|
|
|
if [ -n "$pkgs" ]; then
|
|
|
|
cmd="yum -y install $pkgs"
|
|
|
|
result=`$cmd 2>&1`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
logger -t xcat "ospkgs: $cmd\n $result"
|
|
|
|
echo "ospkgs: $cmd"
|
|
|
|
echo $result
|
|
|
|
else
|
|
|
|
if [ $debug -ne 0 ]; then
|
|
|
|
echo "ospkgs: $cmd"
|
|
|
|
echo $result
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#remove some rpms if specified
|
|
|
|
if [ -n "$pkgs_d" ]; then
|
|
|
|
cmd="yum -y remove $pkgs_d"
|
|
|
|
result=`$cmd 2>&1`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
logger -t xcat "ospkgs: $cmd\n $result"
|
|
|
|
echo "ospkgs: $cmd"
|
2010-07-23 18:27:29 +00:00
|
|
|
echo $result
|
2010-07-30 20:20:51 +00:00
|
|
|
else
|
|
|
|
if [ $debug -ne 0 ]; then
|
|
|
|
echo "ospkgs: $cmd"
|
|
|
|
echo $result
|
|
|
|
fi
|
2010-07-23 18:27:29 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
|