2010-03-29 20:40:57 +00:00
|
|
|
#!/bin/sh
|
2008-09-08 18:54:30 +00:00
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
2008-09-09 21:08:48 +00:00
|
|
|
#=head1 otherpkgs
|
2008-09-08 18:54:30 +00:00
|
|
|
#=head2 It gets the extra rpms and install/update them.
|
2008-09-09 21:08:48 +00:00
|
|
|
# The environment variable OTHERPKGS contains the rpms to be installed/updated.
|
2008-09-08 18:54:30 +00:00
|
|
|
# On MN, You need to:
|
2008-09-09 21:08:48 +00:00
|
|
|
# 1. put rpms under /install/post/otherpkgs/os/arch directory where 'os' and 'arch'
|
2008-09-08 18:54:30 +00:00
|
|
|
# can be found in the nodetype table.
|
|
|
|
# 2. put the name of the packages to /opt/xcat/share/xcat/netboot(install)/platform
|
|
|
|
# directory. The file name is one of the following:
|
2008-09-09 21:08:48 +00:00
|
|
|
# profile.os.arch.otherpkgs.pkglist
|
|
|
|
# profile.os.otherpkgs.pkglist
|
|
|
|
# profile.arch.otherpkgs.pkglist
|
|
|
|
# profile.otherpkgs.pkglist
|
2008-09-08 18:54:30 +00:00
|
|
|
# The install/deployment process will pick up the rpms and install them on the nodes.
|
|
|
|
# However, if the nodes have already installed and up and running, you can run the following
|
|
|
|
# command to have the extra rpms installed:
|
2008-09-09 21:08:48 +00:00
|
|
|
# updatenode noderange otherpkgs
|
2008-09-08 18:54:30 +00:00
|
|
|
#
|
|
|
|
#=cut
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2009-07-29 21:25:59 +00:00
|
|
|
# do nothing for diskless deployment case because it is done in the image already
|
|
|
|
if [[ $UPDATENODE -ne 1 ]]; then
|
2009-10-06 16:43:05 +00:00
|
|
|
if [ "$NODESETSTATE" = "netboot" -o \
|
2010-04-08 10:06:55 +00:00
|
|
|
"$NODESETSTATE" = "statelite" -o \
|
2009-10-06 16:43:05 +00:00
|
|
|
"$NODESETSTATE" = "diskless" -o \
|
|
|
|
"$NODESETSTATE" = "dataless" ]
|
2009-07-29 21:25:59 +00:00
|
|
|
then
|
2010-04-08 10:06:55 +00:00
|
|
|
echo " Did not install any extra rpms."
|
2009-07-29 21:25:59 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2008-09-09 21:08:48 +00:00
|
|
|
#echo "OTHERPKGS=$OTHERPKGS"
|
|
|
|
if [[ -z "$OTHERPKGS" ]]; then
|
2008-09-08 18:54:30 +00:00
|
|
|
echo "$0: no extra rpms to install"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2009-07-02 15:48:28 +00:00
|
|
|
if [[ -z "$NFSSERVER" ]]; then
|
2009-03-12 19:44:45 +00:00
|
|
|
NFSSERVER=$MASTER
|
2009-07-02 15:48:28 +00:00
|
|
|
fi
|
2008-09-11 04:43:33 +00:00
|
|
|
|
2009-10-02 18:55:54 +00:00
|
|
|
if [[ -z "$INSTALLDIR" ]]; then
|
|
|
|
INSTALLDIR="/install"
|
|
|
|
fi
|
2009-07-02 15:48:28 +00:00
|
|
|
|
|
|
|
#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
|
2009-10-02 18:55:54 +00:00
|
|
|
NFSSERVER=$INSTALLDIR
|
2009-07-02 15:48:28 +00:00
|
|
|
mounted=1
|
|
|
|
fi
|
2008-09-11 04:43:33 +00:00
|
|
|
|
2009-10-02 18:55:54 +00:00
|
|
|
if [[ -z "$OTHERPKGDIR" ]]; then
|
|
|
|
OTHERPKGDIR="$NFSSERVER/post/otherpkgs/$OSVER/$ARCH"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $mounted -eq 0 ]; then
|
|
|
|
OTHERPKGDIR=${OTHERPKGDIR/#$INSTALLDIR/$NFSSERVER/}
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo NFSSERVER=$NFSSERVER
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "NFSSERVER=$NFSSERVER"
|
2009-10-02 18:55:54 +00:00
|
|
|
echo OTHERPKGDIR=$OTHERPKGDIR
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "OTHERPKGDIR=$OTHERPKGDIR"
|
2009-07-02 15:48:28 +00:00
|
|
|
|
|
|
|
#check if the node has yum or zypper installed, it will try yum first, then zypper and last rpm
|
|
|
|
hasyum=0
|
|
|
|
haszypper=0;
|
|
|
|
result=`rpm -q yum`
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
hasyum=1
|
|
|
|
mkdir -p /etc/yum.repos.d
|
|
|
|
result=`rm /etc/yum.repos.d/xCAT-otherpkgs*.repo 2>&1`
|
|
|
|
result=`yum clean all`
|
|
|
|
repo_base="/etc/yum.repos.d"
|
|
|
|
else
|
2009-04-21 21:20:30 +00:00
|
|
|
result=`rpm -q zypper`
|
|
|
|
if [ "$?" = "0" ]; then
|
2009-07-02 15:48:28 +00:00
|
|
|
haszypper=1
|
|
|
|
#remove old repo
|
2009-07-02 19:53:03 +00:00
|
|
|
old_repo=`zypper sl |grep xcat-otherpkgs | cut -f2 -d '|'`
|
2009-07-02 15:48:28 +00:00
|
|
|
for x in $old_repo
|
|
|
|
do
|
|
|
|
result=`zypper sd $x`
|
|
|
|
done
|
2010-03-29 20:40:57 +00:00
|
|
|
zypper --non-interactive refresh
|
2009-07-02 15:48:28 +00:00
|
|
|
repo_base="/tmp"
|
2009-02-12 10:14:58 +00:00
|
|
|
fi
|
2009-07-02 15:48:28 +00:00
|
|
|
fi
|
|
|
|
|
2010-03-29 20:40:57 +00:00
|
|
|
dhcpcd -n eth0
|
|
|
|
|
2009-07-02 15:48:28 +00:00
|
|
|
|
|
|
|
repo_path=()
|
|
|
|
repo_pkgs=""
|
2009-10-07 19:27:19 +00:00
|
|
|
repo_pkgs_preremove=""
|
|
|
|
repo_pkgs_postremove=""
|
2009-07-02 15:48:28 +00:00
|
|
|
plain_pkgs=""
|
2009-10-07 19:27:19 +00:00
|
|
|
plain_pkgs_preremove=""
|
|
|
|
plain_pkgs_postremove=""
|
2009-07-02 17:03:17 +00:00
|
|
|
handled_path=()
|
2009-07-02 15:48:28 +00:00
|
|
|
for x in `echo "$OTHERPKGS" | tr "," "\n"`
|
|
|
|
do
|
2009-10-07 19:27:19 +00:00
|
|
|
#check if the file name starts with -- or -.
|
|
|
|
#If it is start with -, then the rpm must be removed before installing other packages
|
|
|
|
#If it is start with --, then the rpm will be removed after installing other packages
|
|
|
|
string_type=0; #nornmal rpm
|
|
|
|
pos=`expr index $x -`
|
|
|
|
if [ $pos -eq 1 ]; then
|
|
|
|
x=`echo ${x#-}`
|
|
|
|
pos=`expr index $x -`
|
|
|
|
if [ $pos -eq 1 ]; then
|
|
|
|
x=`echo ${x#-}`
|
|
|
|
string_type=1 #start with --
|
|
|
|
else
|
|
|
|
string_type=-1 #start with -
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2009-07-02 15:48:28 +00:00
|
|
|
if [ $hasyum -eq 0 ] && [ $haszypper -eq 0 ]; then
|
2009-10-07 19:27:19 +00:00
|
|
|
if [ $string_type -eq -1 ]; then
|
|
|
|
plain_pkgs_preremove="$plain_pkgs_preremove $x"
|
|
|
|
elif [ $string_type -eq 1 ]; then
|
|
|
|
plain_pkgs_postremove="$plain_pkgs_postremove $x"
|
|
|
|
else
|
|
|
|
plain_pkgs="$plain_pkgs $x-*"
|
|
|
|
fi
|
2009-07-02 15:48:28 +00:00
|
|
|
continue
|
|
|
|
fi
|
2009-10-07 19:27:19 +00:00
|
|
|
|
|
|
|
if [ $string_type -eq -1 ]; then
|
|
|
|
repo_pkgs_preremove="$repo_pkgs_preremove $x"
|
|
|
|
elif [ $string_type -eq 1 ]; then
|
|
|
|
repo_pkgs_postremove="$repo_pkgs_postremove $x"
|
|
|
|
else
|
|
|
|
fn=`basename $x`
|
|
|
|
path=`dirname $x`
|
|
|
|
whole_path=$OTHERPKGDIR/$path
|
|
|
|
|
|
|
|
#find out if this path has already handled
|
|
|
|
try_repo=1
|
|
|
|
rc=1
|
|
|
|
i=0
|
|
|
|
while [ $i -lt ${#handled_path[*]} ]; do
|
|
|
|
if [ ${handled_path[$i]} = $path ]; then
|
|
|
|
try_repo=0
|
|
|
|
j=0
|
|
|
|
while [ $j -lt ${#repo_path[*]} ]; do
|
|
|
|
if [ ${repo_path[$j]} = $path ]; then
|
|
|
|
rc=0
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
let j++
|
|
|
|
done
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
let i++
|
|
|
|
done
|
|
|
|
|
2009-07-02 15:48:28 +00:00
|
|
|
|
2009-10-07 19:27:19 +00:00
|
|
|
#try to add the path to the repo
|
|
|
|
if [ $try_repo -eq 1 ]; then
|
|
|
|
index=${#repo_path[*]}
|
|
|
|
REPOFILE="$repo_base/xCAT-otherpkgs$index.repo"
|
|
|
|
echo "[xcat-otherpkgs$index]" > $REPOFILE
|
|
|
|
echo "name=xcat-otherpkgs$index" >> $REPOFILE
|
|
|
|
if [ $mounted -eq 0 ]; then
|
|
|
|
echo "baseurl=ftp://$whole_path" >> $REPOFILE
|
|
|
|
else
|
|
|
|
echo "baseurl=file://$whole_path" >> $REPOFILE
|
|
|
|
fi
|
|
|
|
echo "enabled=1" >> $REPOFILE
|
|
|
|
echo "gpgcheck=0" >> $REPOFILE
|
|
|
|
|
|
|
|
if [ $hasyum -eq 1 ]; then
|
|
|
|
#use yum
|
|
|
|
result=`yum list $fn 2>&1`
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
rc=0
|
|
|
|
repo_path[${#repo_path[*]}]=$path
|
|
|
|
else
|
|
|
|
rm $REPOFILE
|
|
|
|
fi
|
|
|
|
elif [ $haszypper -eq 1 ]; then
|
|
|
|
#use zypper
|
2010-01-13 09:46:15 +00:00
|
|
|
if [[ "$OSVER" = sles11* ]]; then
|
2009-10-07 19:27:19 +00:00
|
|
|
result=`zypper ar -c $REPOFILE`
|
|
|
|
else
|
|
|
|
result=`zypper sa -c $REPOFILE`
|
|
|
|
fi
|
|
|
|
|
2010-03-29 20:40:57 +00:00
|
|
|
result=`zypper --non-interactive refresh xcat-otherpkgs$index 2>&1`
|
2009-10-07 19:27:19 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
rc=0
|
|
|
|
repo_path[${#repo_path[*]}]=$path
|
|
|
|
else
|
|
|
|
result=`zypper sd xcat-otherpkgs$index`
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $rc -eq 0 ]; then
|
|
|
|
repo_pkgs="$repo_pkgs $fn"
|
|
|
|
else
|
|
|
|
#now no hope we have to use rpm command
|
|
|
|
plain_pkgs="$plain_pkgs $x-*"
|
|
|
|
fi
|
|
|
|
handled_path[${#handled_path[*]}]=$path
|
|
|
|
fi
|
2009-07-02 15:48:28 +00:00
|
|
|
done
|
|
|
|
|
2009-10-07 19:27:19 +00:00
|
|
|
#echo "repo_pkgs=$repo_pkgs,\nrepo_pkgs_preremove=$repo_pkgs_preremove,\nrepo_pkgs_postremove=$repo_pkgs_postremove"
|
|
|
|
#echo "plain_pkgs=$plain_pkgs,\nplain_pkgs_preremove=$plain_pkgs_preremove,\nplain_pkgs_postremove=$plain_pkgs_postremove"
|
|
|
|
|
|
|
|
|
|
|
|
#Now we have parse the input, let's remove rpms if is specified with -
|
|
|
|
if [ "$repo_pkgs_preremove" != "" ]; then
|
|
|
|
if [ $hasyum -eq 1 ]; then
|
2010-03-01 20:30:38 +00:00
|
|
|
echo "yum -y remove $repo_pkgs_preremove"
|
2009-10-07 19:27:19 +00:00
|
|
|
result=`yum -y remove $repo_pkgs_preremove 2>&1`
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "$result"
|
2009-10-07 19:27:19 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "otherpkgs: $result"
|
2009-10-07 19:27:19 +00:00
|
|
|
fi
|
2010-03-01 20:30:38 +00:00
|
|
|
echo "$result"
|
2009-10-07 19:27:19 +00:00
|
|
|
elif [ $haszypper -eq 1 ]; then
|
|
|
|
echo "zypper remove -y $repo_pkgs_preremove"
|
|
|
|
result=`zypper remove -y $repo_pkgs_preremove 2>&1`
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "$result"
|
2009-10-07 19:27:19 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "otherpkgs: $result"
|
2009-10-07 19:27:19 +00:00
|
|
|
fi
|
2010-03-01 20:30:38 +00:00
|
|
|
echo "$result"
|
2009-10-07 19:27:19 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$plain_pkgs_preremove" != "" ]; then
|
|
|
|
echo "rpm -ev $plain_pkgs_preremove"
|
|
|
|
result=`rpm -ev $plain_pkgs_preremove 2>&1`
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "$result"
|
2009-10-07 19:27:19 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "otherpkgs $result"
|
2009-10-07 19:27:19 +00:00
|
|
|
fi
|
2010-03-01 20:30:38 +00:00
|
|
|
echo "$result"
|
2009-10-07 19:27:19 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#installation using yum or zypper
|
2009-07-02 15:48:28 +00:00
|
|
|
if [ "$repo_pkgs" != "" ]; then
|
|
|
|
if [ $hasyum -eq 1 ]; then
|
|
|
|
echo "yum -y install $repo_pkgs"
|
|
|
|
result=`yum -y install $repo_pkgs 2>&1`
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "$result"
|
2009-07-02 15:48:28 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "otherpkgs: $result"
|
2009-07-02 15:48:28 +00:00
|
|
|
fi
|
2010-03-01 20:30:38 +00:00
|
|
|
echo "$result"
|
2009-07-02 15:48:28 +00:00
|
|
|
elif [ $haszypper -eq 1 ]; then
|
|
|
|
echo "zypper install -y $repo_pkgs"
|
|
|
|
result=`zypper install -y $repo_pkgs 2>&1`
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "$result"
|
2009-07-02 15:48:28 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "otherpkgs: $result"
|
2009-07-02 15:48:28 +00:00
|
|
|
fi
|
2010-03-01 20:30:38 +00:00
|
|
|
echo "$result"
|
2009-07-02 15:48:28 +00:00
|
|
|
#remove the repos
|
2009-10-07 19:27:19 +00:00
|
|
|
#old_repo=`zypper lr -u |grep xcat-otherpkgs | cut -f2 -d '|'`
|
|
|
|
#for x in $old_repo
|
|
|
|
#do
|
|
|
|
# result=`zypper sd $x`
|
|
|
|
#done
|
2009-07-02 15:48:28 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#Handle the rest with rpm
|
|
|
|
if [ "$plain_pkgs" != "" ]; then
|
|
|
|
if [ $mounted -eq 0 ]; then
|
2009-10-02 18:55:54 +00:00
|
|
|
dir_no_ftproot=${OTHERPKGDIR#$INSTALLDIR/}
|
|
|
|
mkdir -p /xcatpost/$dir_no_ftproot
|
|
|
|
rm -f -R /xcatpost/$dir_no_ftproot/*
|
2009-07-02 15:48:28 +00:00
|
|
|
mkdir -p /tmp/postage/
|
|
|
|
rm -f -R /tmp/postage/*
|
|
|
|
cd /tmp/postage
|
|
|
|
|
|
|
|
for x in `echo "$plain_pkgs" | tr " " "\n"`
|
|
|
|
do
|
2009-10-02 18:55:54 +00:00
|
|
|
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$OTHERPKGDIR/$x 2> /tmp/wget.log
|
2009-07-02 15:48:28 +00:00
|
|
|
done
|
|
|
|
|
2009-10-02 18:55:54 +00:00
|
|
|
mv $dir_no_ftproot/* /xcatpost/$dir_no_ftproot;
|
2009-07-02 15:48:28 +00:00
|
|
|
rm -rf $NFSSERVER
|
2009-10-02 18:55:54 +00:00
|
|
|
cd /xcatpost/$dir_no_ftproot
|
2009-04-21 21:20:30 +00:00
|
|
|
else
|
2009-10-02 18:55:54 +00:00
|
|
|
cd $OTHERPKGDIR
|
2009-04-21 21:20:30 +00:00
|
|
|
fi
|
|
|
|
|
2009-07-02 15:48:28 +00:00
|
|
|
echo "rpm -Uvh --replacepkgs $plain_pkgs"
|
|
|
|
result=`rpm -Uvh --replacepkgs $plain_pkgs 2>&1`
|
|
|
|
#result=`rpm -Fvh $plain_pkgs 2>&1`
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "$result"
|
2009-07-02 15:48:28 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "otherpkgs $result"
|
2009-04-21 21:20:30 +00:00
|
|
|
fi
|
2010-03-01 20:30:38 +00:00
|
|
|
echo "$result"
|
2009-07-02 15:48:28 +00:00
|
|
|
|
|
|
|
if [ $mounted -eq 0 ]; then
|
2009-10-02 18:55:54 +00:00
|
|
|
cd /xcatpost
|
|
|
|
dir_no_ftproot=${OTHERPKGDIR#$INSTALLDIR/}
|
|
|
|
rm -f -R $dir_no_ftproot
|
2009-07-02 15:48:28 +00:00
|
|
|
fi
|
|
|
|
fi
|
2008-09-08 18:54:30 +00:00
|
|
|
|
2009-10-07 19:27:19 +00:00
|
|
|
#remove more rpms if specified with --
|
|
|
|
if [ "$repo_pkgs_postremove" != "" ]; then
|
|
|
|
if [ $hasyum -eq 1 ]; then
|
|
|
|
echo "yum -y removel $repo_pkgs_postremove"
|
|
|
|
result=`yum -y remove $repo_pkgs_postremove 2>&1`
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "$result"
|
2009-10-07 19:27:19 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "otherpkgs: $result"
|
2009-10-07 19:27:19 +00:00
|
|
|
fi
|
2010-03-01 20:30:38 +00:00
|
|
|
echo "$result"
|
2009-10-07 19:27:19 +00:00
|
|
|
elif [ $haszypper -eq 1 ]; then
|
|
|
|
echo "zypper remove -y $repo_pkgs_postremove"
|
|
|
|
result=`zypper remove -y $repo_pkgs_postremove 2>&1`
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "$result"
|
2009-10-07 19:27:19 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "otherpkgs: $result"
|
2009-10-07 19:27:19 +00:00
|
|
|
fi
|
2010-03-01 20:30:38 +00:00
|
|
|
echo "$result"
|
2009-10-07 19:27:19 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$plain_pkgs_postremove" != "" ]; then
|
|
|
|
echo "rpm -ev $plain_pkgs_postremove"
|
|
|
|
result=`rpm -ev $plain_pkgs_postremove 2>&1`
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "$result"
|
2009-10-07 19:27:19 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "otherpkgs $result"
|
2009-10-07 19:27:19 +00:00
|
|
|
fi
|
2010-03-01 20:30:38 +00:00
|
|
|
echo "$result"
|
2009-10-07 19:27:19 +00:00
|
|
|
fi
|
|
|
|
|
2008-09-08 18:54:30 +00:00
|
|
|
exit 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|