2012-07-26 08:23:38 +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)
|
2012-05-02 19:17:31 +00:00
|
|
|
# updatenode noderange -P "ospkgs --keeprepo" (this one will preserve the original repositories when installing/updating the rpms. )
|
|
|
|
#
|
2010-07-23 18:27:29 +00:00
|
|
|
#
|
|
|
|
#=cut
|
|
|
|
#-------------------------------------------------------------------------------
|
2011-09-26 13:42:37 +00:00
|
|
|
|
|
|
|
# pmatch determines if 1st argument string is matched by 2nd argument pattern
|
|
|
|
|
|
|
|
pmatch ()
|
|
|
|
{
|
|
|
|
case $1 in
|
|
|
|
$2) return 0;; # zero return code means string matched by pattern
|
|
|
|
esac
|
|
|
|
|
|
|
|
return 1 # non-zero return code means string not matched by pattern
|
|
|
|
}
|
|
|
|
|
2012-07-26 08:23:38 +00:00
|
|
|
##
|
|
|
|
## The following routines implement the notion of an array.
|
|
|
|
## The POSIX shell does not support arrays.
|
|
|
|
## With these routines, an array conceptually called "my_array" is implmented using the following series
|
|
|
|
## of variables:
|
|
|
|
##
|
|
|
|
## my_array__ARRAY_HIGH_INDEX - holds the highest index used in the array
|
|
|
|
## my_array__0 - value for element 0 of my_array: my_array[0] in standard array notation
|
|
|
|
## my_array__1 - value for element 1 of my_array: my_array[1] in standard array notation
|
|
|
|
## . .
|
|
|
|
## . .
|
|
|
|
## . .
|
|
|
|
##
|
|
|
|
|
|
|
|
#
|
|
|
|
# array_empty - make the array whose name is given by $1 empty (with no elements).
|
|
|
|
#
|
|
|
|
# sample call: array_empty my_array
|
|
|
|
#
|
|
|
|
|
|
|
|
array_empty ()
|
|
|
|
{
|
|
|
|
local array_name="$1"
|
|
|
|
local high_ndx_varname="${array_name}__ARRAY_HIGH_INDEX"
|
|
|
|
local elem_varname
|
|
|
|
local high_ndx
|
|
|
|
local ndx
|
|
|
|
|
|
|
|
# Determine current element count
|
|
|
|
|
|
|
|
eval "high_ndx=\$${high_ndx_varname}"
|
|
|
|
|
|
|
|
if [ -z "$high_ndx" ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Unset all previously defined element variables and the high index variable
|
|
|
|
|
|
|
|
ndx=0
|
|
|
|
|
|
|
|
while [ $ndx -le $high_ndx ]; do
|
|
|
|
elem_varname="${array_name}__${ndx}"
|
|
|
|
|
|
|
|
eval "unset ${elem_varname}"
|
|
|
|
|
|
|
|
ndx=$(expr $ndx + 1)
|
|
|
|
done
|
|
|
|
|
|
|
|
eval "unset ${high_ndx_varname}"
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# array_get_size - return the size of the array whose name is given by $1.
|
|
|
|
# The size, which is the highest index plus one is written to standard output
|
|
|
|
#
|
|
|
|
# sample call: size=$(array_get_size my_array)
|
|
|
|
#
|
|
|
|
|
|
|
|
array_get_size ()
|
|
|
|
{
|
|
|
|
local array_name="$1"
|
|
|
|
|
|
|
|
local high_ndx_varname="${array_name}__ARRAY_HIGH_INDEX"
|
|
|
|
local high_ndx
|
|
|
|
|
|
|
|
eval "high_ndx=\$${high_ndx_varname}"
|
|
|
|
|
|
|
|
if [ -z "$high_ndx" ]; then
|
|
|
|
high_ndx=-1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo $(expr $high_ndx + 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# array_set_element - set an element to a value. $1 is the array name, $2 is the element index,
|
|
|
|
# $3 is the element value.
|
|
|
|
#
|
|
|
|
# sample call: array_set_element my_array index "the new element value"
|
|
|
|
#
|
|
|
|
|
|
|
|
array_set_element ()
|
|
|
|
{
|
|
|
|
local array_name="$1"
|
|
|
|
local ndx="$2"
|
|
|
|
local elem_value="$3"
|
|
|
|
local high_ndx_varname="${array_name}__ARRAY_HIGH_INDEX"
|
|
|
|
local elem_varname
|
|
|
|
local high_ndx
|
|
|
|
|
|
|
|
# Set specified element to specified value
|
|
|
|
|
|
|
|
elem_varname="${array_name}__${ndx}"
|
|
|
|
|
|
|
|
eval "${elem_varname}=\"${elem_value}\""
|
|
|
|
|
|
|
|
# Adjust high index
|
|
|
|
|
|
|
|
eval "high_ndx=\$${high_ndx_varname}"
|
|
|
|
|
|
|
|
if [ -z "$high_ndx" ]; then
|
|
|
|
high_ndx=-1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $ndx -gt $high_ndx ]; then
|
|
|
|
eval "${high_ndx_varname}=${ndx}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# array_get_element - get an element's value. $1 is the array name, $2 is the element index.
|
|
|
|
#
|
|
|
|
# sample call: value=$(array_get_element my_array index)
|
|
|
|
#
|
|
|
|
|
|
|
|
array_get_element ()
|
|
|
|
{
|
|
|
|
local array_name="$1"
|
|
|
|
local ndx="$2"
|
|
|
|
|
|
|
|
eval "echo \"\$${array_name}__${ndx}\""
|
|
|
|
}
|
|
|
|
|
|
|
|
##
|
|
|
|
## End of set routines.
|
|
|
|
##
|
|
|
|
|
|
|
|
|
2012-11-25 02:33:54 +00:00
|
|
|
RETURNVAL=0
|
2012-07-26 08:23:38 +00:00
|
|
|
|
2010-07-23 18:27:29 +00:00
|
|
|
debug=0
|
|
|
|
|
2011-09-26 13:42:37 +00:00
|
|
|
OS_TYPE=`uname -s`
|
|
|
|
|
|
|
|
if [ "$OS_TYPE" != "Linux" ]; then
|
2010-07-23 18:59:22 +00:00
|
|
|
#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
|
2011-09-27 00:52:33 +00:00
|
|
|
if [ -z "$UPDATENODE" ] || [ $UPDATENODE -ne 1 ]; then
|
2010-07-23 18:27:29 +00:00
|
|
|
echo " Did not install any extra rpms."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2011-09-26 13:42:37 +00:00
|
|
|
if [ -z "$OSPKGS" ]; then
|
2012-11-25 02:33:54 +00:00
|
|
|
echo "$0: no extra rpms to install"
|
|
|
|
exit 0
|
2010-07-23 18:27:29 +00:00
|
|
|
fi
|
|
|
|
|
2012-05-01 15:35:13 +00:00
|
|
|
|
|
|
|
argnum=$#;
|
|
|
|
args=$@
|
|
|
|
keeprepo=0
|
|
|
|
if [ $argnum -gt 0 ]; then
|
|
|
|
if ( pmatch "$args" "*keeprepo*" ); then
|
|
|
|
keeprepo=1
|
|
|
|
fi
|
|
|
|
if ( pmatch "$args" "*debug*" ); then
|
|
|
|
debug=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2011-09-26 13:42:37 +00:00
|
|
|
if [ -z "$NFSSERVER" ]; then
|
2010-07-23 18:27:29 +00:00
|
|
|
NFSSERVER=$MASTER
|
|
|
|
fi
|
|
|
|
|
2011-09-26 13:42:37 +00:00
|
|
|
if [ -z "$INSTALLDIR" ]; then
|
2010-07-23 18:27:29 +00:00
|
|
|
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
|
2011-01-04 02:41:15 +00:00
|
|
|
NFSSERVER="/install"
|
2010-07-23 18:27:29 +00:00
|
|
|
mounted=1
|
|
|
|
fi
|
|
|
|
|
2011-09-26 13:42:37 +00:00
|
|
|
if [ -z "$OSPKGDIR" ]; then
|
2011-12-30 08:57:37 +00:00
|
|
|
if [ $mounted -eq 0 ]; then
|
|
|
|
OSPKGDIR="$NFSSERVER$INSTALLDIR/$OSVER/$ARCH"
|
|
|
|
else
|
|
|
|
OSPKGDIR="$NFSSERVER/$OSVER/$ARCH"
|
|
|
|
fi
|
2012-07-26 08:23:38 +00:00
|
|
|
|
|
|
|
if ( pmatch "$OSVER" "sles*" ); then
|
|
|
|
OSPKGDIR="$OSPKGDIR/1"
|
|
|
|
elif ( pmatch "$OSVER" "rhel*" ); then
|
|
|
|
OSPKGDIR="$OSPKGDIR/Server"
|
2012-09-10 01:48:33 +00:00
|
|
|
elif ( pmatch "$OSVER" "SL5*" ); then
|
2012-07-26 08:23:38 +00:00
|
|
|
OSPKGDIR="$OSPKGDIR/SL"
|
|
|
|
fi
|
2012-07-20 09:55:45 +00:00
|
|
|
|
2012-07-26 08:23:38 +00:00
|
|
|
else
|
|
|
|
|
|
|
|
if [ "$KERNELDIR" != "" ]; then
|
|
|
|
if [ $mounted -eq 0 ]; then
|
2012-10-30 09:06:04 +00:00
|
|
|
OSPKGDIR="$OSPKGDIR,$KERNELDIR"
|
2012-07-26 08:23:38 +00:00
|
|
|
fi
|
2010-07-23 18:27:29 +00:00
|
|
|
fi
|
2012-07-26 08:23:38 +00:00
|
|
|
|
|
|
|
OIFS=$IFS
|
2012-08-30 01:52:27 +00:00
|
|
|
IFS=$','
|
2012-07-26 08:23:38 +00:00
|
|
|
if ( pmatch "$OSVER" "ubuntu*" ); then
|
2012-08-30 01:52:27 +00:00
|
|
|
IFS=$(printf ',')
|
2012-07-26 08:23:38 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
array_ospkgdirs=($OSPKGDIR)
|
|
|
|
IFS=$OIFS
|
|
|
|
array_empty os_path
|
|
|
|
index=0
|
|
|
|
for dir in ${array_ospkgdirs[@]}
|
|
|
|
do
|
|
|
|
if [ $mounted -eq 0 ]; then
|
|
|
|
OSPKGDIR="$OSPKGDIR"
|
|
|
|
ospkgdir="$NFSSERVER$dir"
|
|
|
|
array_set_element os_path $index $ospkgdir
|
|
|
|
else
|
|
|
|
OSPKGDIR="$NFSSERVER$OSPKGDIR"
|
|
|
|
array_set_element os_path $index $dir
|
|
|
|
fi
|
|
|
|
|
|
|
|
index=$(expr $index + 1)
|
|
|
|
|
|
|
|
done
|
2010-07-23 18:27:29 +00:00
|
|
|
|
2012-07-20 09:55:45 +00:00
|
|
|
fi
|
2012-07-26 08:23:38 +00:00
|
|
|
|
2012-07-20 09:55:45 +00:00
|
|
|
|
|
|
|
|
2012-04-12 09:29:17 +00:00
|
|
|
if [ "$SDKDIR" != "" ]; then
|
|
|
|
if [ $mounted -eq 0 ]; then
|
|
|
|
SDKDIR="$NFSSERVER/$SDKDIR"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2012-07-20 09:55:45 +00:00
|
|
|
#if [ $mounted -eq 0 ]; then
|
|
|
|
# OSPKGDIR_NO_PREFIX=${OSPKGDIR#$INSTALLDIR}
|
2011-09-26 13:42:37 +00:00
|
|
|
|
2012-07-20 09:55:45 +00:00
|
|
|
# if [ "$OSPKGDIR" != "$OSPKGDIR_NO_PREFIX" ]; then
|
|
|
|
# OSPKGDIR="$NFSSERVER/$OSPKGDIR_NO_PREFIX"
|
|
|
|
# fi
|
|
|
|
#fi
|
2010-07-23 18:27:29 +00:00
|
|
|
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "NFSSERVER=$NFSSERVER"
|
|
|
|
logger -t xcat -p local4.info "OSPKGDIR=$OSPKGDIR"
|
|
|
|
logger -t xcat -p local4.info "OSPKGS=$OSPKGS"
|
2010-07-23 18:27:29 +00:00
|
|
|
|
|
|
|
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
|
2012-04-12 19:26:55 +00:00
|
|
|
IFS=$'\n'
|
|
|
|
if ( pmatch "$OSVER" "ubuntu*" ); then
|
|
|
|
IFS=$(printf '\n')
|
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
2011-09-26 13:42:37 +00:00
|
|
|
if ( pmatch "$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
|
|
|
|
|
2012-05-01 15:35:13 +00:00
|
|
|
if [ $keeprepo -ne 1 ]; then
|
|
|
|
#remove old repo
|
|
|
|
old_repo=`rug sl |grep -e "^[0-9]" | cut -f2 -d '|'`
|
|
|
|
for x in $old_repo
|
|
|
|
do
|
|
|
|
result=`rug sd $x`
|
|
|
|
done
|
|
|
|
result=`rug refresh 2>&1`
|
|
|
|
if [ $debug -ne 0 ]; then
|
|
|
|
echo "rug refresh"
|
|
|
|
echo $result
|
|
|
|
fi
|
2010-07-23 18:27:29 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
#add new repo
|
|
|
|
if [ $mounted -eq 0 ]; then
|
2011-11-10 14:26:08 +00:00
|
|
|
path="http://$OSPKGDIR"
|
2010-07-23 18:27:29 +00:00
|
|
|
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
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "ospkgs: rug sa $path $OSVER\n $result"
|
2011-09-26 13:42:37 +00:00
|
|
|
echo "ospkgs: rug sa $path $OSVER"
|
|
|
|
echo " $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
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "ospkgs: rug sub $OSVER\n $result"
|
2011-09-26 13:42:37 +00:00
|
|
|
echo "ospkgs: rug sub $OSVER"
|
|
|
|
echo " $result"
|
2010-07-30 20:20:51 +00:00
|
|
|
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
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "rug update -y --agree-to-third-party-licences\n $result"
|
2011-09-26 13:42:37 +00:00
|
|
|
echo "ospkgs: rug update -y --agree-to-third-party-licences"
|
2012-11-25 02:33:54 +00:00
|
|
|
echo " $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
|
2011-10-10 07:46:18 +00:00
|
|
|
cmd="$ENVLIST rug install -y --agree-to-third-party-licences -t pattern $groups"
|
|
|
|
result=`eval $cmd 2>&1`
|
2010-07-30 20:20:51 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2012-11-25 02:33:54 +00:00
|
|
|
RETURNVAL=$?
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "ospkgs: $cmd\n $result"
|
2010-07-30 20:20:51 +00:00
|
|
|
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
|
2011-10-10 07:46:18 +00:00
|
|
|
cmd="$ENVLIST rug install -y --agree-to-third-party-licences $pkgs"
|
|
|
|
result=`eval $cmd 2>&1`
|
2010-07-30 20:20:51 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2012-11-25 02:33:54 +00:00
|
|
|
RETURNVAL=$?
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "ospkgs: $cmd\n $result"
|
2010-07-30 20:20:51 +00:00
|
|
|
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
|
2011-10-10 07:46:18 +00:00
|
|
|
cmd="$ENVLIST rug remove -y $pkgs_d"
|
|
|
|
result=`eval $cmd 2>&1`
|
2010-07-30 20:20:51 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2012-11-25 02:33:54 +00:00
|
|
|
RETURNVAL=$?
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "ospkgs: $cmd\n $result"
|
2010-07-30 20:20:51 +00:00
|
|
|
echo "ospkgs: $cmd"
|
|
|
|
echo $result
|
|
|
|
else
|
|
|
|
if [ $debug -ne 0 ]; then
|
|
|
|
echo "ospkgs: $cmd"
|
|
|
|
echo $result
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2011-09-26 13:42:37 +00:00
|
|
|
elif ( pmatch "$OSVER" "sles11*" ); then
|
2010-07-23 18:27:29 +00:00
|
|
|
#check if zypper is installed
|
|
|
|
result=`rpm -q zypper`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Please install zypper on $NODE."
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-05-01 15:35:13 +00:00
|
|
|
if [ $keeprepo -ne 1 ]; then
|
|
|
|
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
|
2010-07-23 18:27:29 +00:00
|
|
|
fi
|
|
|
|
|
2012-07-26 08:23:38 +00:00
|
|
|
SUM=$(array_get_size os_path)
|
|
|
|
i=0
|
|
|
|
|
|
|
|
if [ $SUM -eq 0 ]; then
|
|
|
|
|
|
|
|
if [ $mounted -eq 0 ]; then
|
|
|
|
path="http://$OSPKGDIR"
|
|
|
|
else
|
|
|
|
path="file://$OSPKGDIR"
|
|
|
|
fi
|
|
|
|
result=`zypper ar $path $OSVER 2>&1`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
if ( ! pmatch "$result" "*exists*" ); then
|
|
|
|
logger -t xcat -p local4.info "ospkgs: zypper ar $path $OSVER\n $result"
|
|
|
|
echo "ospkgs: zypper ar $path $OSVER"
|
|
|
|
echo " $result"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
while [ $i -lt $SUM ]; do
|
|
|
|
OSPKGDIR=$(array_get_element os_path $i)
|
|
|
|
if [ $mounted -eq 0 ]; then
|
|
|
|
path="http://$OSPKGDIR"
|
|
|
|
else
|
|
|
|
path="file://$OSPKGDIR"
|
|
|
|
fi
|
|
|
|
result=`zypper ar $path $OSVER-"path$i" 2>&1`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
if ( ! pmatch "$result" "*exists*" ); then
|
|
|
|
logger -t xcat -p local4.info "ospkgs: zypper ar $path $OSVER-path$i\n $result"
|
|
|
|
echo "ospkgs: zypper ar $path $OSVER-path$i"
|
|
|
|
echo " $result"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
i=$((i+1))
|
|
|
|
done
|
2010-07-23 18:27:29 +00:00
|
|
|
fi
|
2012-04-12 09:29:17 +00:00
|
|
|
|
|
|
|
if [ "$SDKDIR" != "" ]; then
|
|
|
|
if [ $mounted -eq 0 ]; then
|
|
|
|
SDKDIR="http://$SDKDIR"
|
|
|
|
else
|
|
|
|
SDKDIR="file://$SDKDIR"
|
|
|
|
fi
|
2012-05-01 15:35:13 +00:00
|
|
|
result=`zypper ar $SDKDIR $OSVER-sdk 2>&1`
|
2012-04-12 09:29:17 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2012-05-01 15:35:13 +00:00
|
|
|
if ( ! pmatch "$result" "*exists*" ); then
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "ospkgs: zypper ar $SDKDIR $OSVER-sdk\n $result"
|
2012-05-01 15:35:13 +00:00
|
|
|
echo "ospkgs: zypper ar $SDKDIR $OSVER-sdk"
|
|
|
|
echo " $result"
|
|
|
|
fi
|
|
|
|
fi
|
2012-04-12 09:29:17 +00:00
|
|
|
fi
|
2010-07-23 18:27:29 +00:00
|
|
|
|
|
|
|
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
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "ospkgs: zypper --non-interactive update --auto-agree-with-licenses\n $result"
|
2011-09-26 13:42:37 +00:00
|
|
|
echo "ospkgs: zypper --non-interactive update --auto-agree-with-licenses"
|
|
|
|
echo " $result"
|
2010-07-23 18:27:29 +00:00
|
|
|
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
|
2011-10-10 07:46:18 +00:00
|
|
|
cmd="$ENVLIST zypper install -y --auto-agree-with-licenses -t pattern $groups"
|
|
|
|
result=`eval $cmd 2>&1`
|
2010-07-30 20:20:51 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2012-11-25 02:33:54 +00:00
|
|
|
RETURNVAL=$?
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "ospkgs: $cmd\n $result"
|
2010-07-30 20:20:51 +00:00
|
|
|
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
|
2011-10-10 07:46:18 +00:00
|
|
|
cmd="$ENVLIST zypper install -y --auto-agree-with-licenses $pkgs"
|
|
|
|
result=`eval $cmd 2>&1`
|
2010-07-30 20:20:51 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2012-11-25 02:33:54 +00:00
|
|
|
RETURNVAL=$?
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "ospkgs: $cmd $result"
|
2010-07-30 20:20:51 +00:00
|
|
|
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
|
2011-10-10 07:46:18 +00:00
|
|
|
cmd="$ENVLIST zypper remove -y $pkgs_d"
|
|
|
|
result=`eval $cmd 2>&1`
|
2010-07-30 20:20:51 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2012-11-25 02:33:54 +00:00
|
|
|
RETURNVAL=$?
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "ospkgs: $cmd $result"
|
2010-07-30 20:20:51 +00:00
|
|
|
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
|
2011-09-26 13:42:37 +00:00
|
|
|
elif ( pmatch "$OSVER" "ubuntu*" ); then
|
|
|
|
# verify dpkg is installed
|
|
|
|
result=`which dpkg`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Please install dpkg on $NODE."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# verify apt is installed
|
|
|
|
result=`dpkg -l apt`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Please install apt on $NODE."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# No need to setup a /etc/apt/sources.list.d/ file because installation
|
|
|
|
# should already lead to /etc/apt/sources.list including the xcat install
|
|
|
|
# media repository.
|
|
|
|
|
|
|
|
# upgrade existing packages
|
|
|
|
command="apt-get -y upgrade"
|
|
|
|
echo "=== $command"
|
|
|
|
$command
|
|
|
|
|
|
|
|
# install groups (NOTE: It's not clear rpm-like "groups" are supported by dpkg/apt,
|
|
|
|
# but keeping this here doesn't really hurt. Anything that looks like a group will
|
|
|
|
# be installed as though it were a package.)
|
|
|
|
if [ -n "$groups" ]; then
|
2011-10-10 07:46:18 +00:00
|
|
|
command="$ENVLIST apt-get -q -y --force-yes install $groups"
|
2011-09-26 13:42:37 +00:00
|
|
|
echo "=== $command"
|
2011-10-10 07:46:18 +00:00
|
|
|
eval $command
|
2012-11-25 02:33:54 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
RETURNVAL=$?
|
|
|
|
fi
|
2011-09-26 13:42:37 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# install packages
|
|
|
|
if [ -n "$pkgs" ]; then
|
2011-10-10 07:46:18 +00:00
|
|
|
command="$ENVLIST apt-get -q -y --force-yes install $pkgs"
|
2011-09-26 13:42:37 +00:00
|
|
|
echo "=== $command"
|
2011-10-10 07:46:18 +00:00
|
|
|
eval $command
|
2012-11-25 02:33:54 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
RETURNVAL=$?
|
|
|
|
fi
|
2011-09-26 13:42:37 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# remove packages
|
|
|
|
if [ -n "$pkgs_d" ]; then
|
2011-10-10 07:46:18 +00:00
|
|
|
command="$ENVLIST apt-get -y remove $pkgs_d"
|
2011-09-26 13:42:37 +00:00
|
|
|
echo "=== $command"
|
2011-10-10 07:46:18 +00:00
|
|
|
eval $command
|
2012-11-25 02:33:54 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
RETURNVAL=$?
|
|
|
|
fi
|
2011-09-26 13:42:37 +00:00
|
|
|
fi
|
2010-07-23 18:27:29 +00:00
|
|
|
else
|
|
|
|
#check if yum is installed
|
|
|
|
result=`rpm -q yum`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Please install yum on $NODE."
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
2012-05-01 15:35:13 +00:00
|
|
|
if [ $keeprepo -ne 1 ]; then
|
|
|
|
#remove old repo
|
|
|
|
mkdir -p /etc/yum.repos.d
|
|
|
|
result=`rm /etc/yum.repos.d/*.repo 2>&1`
|
|
|
|
fi
|
|
|
|
|
2010-07-23 18:27:29 +00:00
|
|
|
result=`yum clean all`
|
|
|
|
|
2012-07-26 08:23:38 +00:00
|
|
|
SUM=$(array_get_size os_path)
|
|
|
|
i=0
|
|
|
|
|
|
|
|
if [ $SUM -eq 0 ]; then
|
2010-07-23 18:27:29 +00:00
|
|
|
#create new repo file
|
2012-07-26 08:23:38 +00:00
|
|
|
REPOFILE="/etc/yum.repos.d/$OSVER.repo"
|
|
|
|
if [ ! -f $REPOFILE ]; then
|
|
|
|
echo "[$OSVER]" > $REPOFILE
|
|
|
|
echo "name=$OSVER" >> $REPOFILE
|
|
|
|
if [ $mounted -eq 0 ]; then
|
|
|
|
echo "baseurl=http://$OSPKGDIR" >> $REPOFILE
|
|
|
|
else
|
|
|
|
echo "baseurl=file://$OSPKGDIR" >> $REPOFILE
|
|
|
|
fi
|
|
|
|
echo "enabled=1" >> $REPOFILE
|
|
|
|
echo "gpgcheck=0" >> $REPOFILE
|
|
|
|
fi
|
|
|
|
else
|
2010-07-23 18:27:29 +00:00
|
|
|
|
2012-07-26 08:23:38 +00:00
|
|
|
while [ $i -lt $SUM ]; do
|
|
|
|
REPOFILE="/etc/yum.repos.d/$OSVER-path$i.repo"
|
|
|
|
OSPKGDIR=$(array_get_element os_path $i)
|
|
|
|
if [ ! -f $REPOFILE ]; then
|
|
|
|
echo "[$OSVER-path$i]" > $REPOFILE
|
|
|
|
echo "name=$OSVER-path$i" >> $REPOFILE
|
|
|
|
if [ $mounted -eq 0 ]; then
|
|
|
|
echo "baseurl=http://$OSPKGDIR" >> $REPOFILE
|
|
|
|
else
|
|
|
|
echo "baseurl=file://$OSPKGDIR" >> $REPOFILE
|
|
|
|
fi
|
|
|
|
echo "enabled=1" >> $REPOFILE
|
|
|
|
echo "gpgcheck=0" >> $REPOFILE
|
|
|
|
fi
|
|
|
|
i=$((i+1))
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2010-07-23 18:27:29 +00:00
|
|
|
#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
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "ospkgs: yum -y upgrade\n $result"
|
2011-09-26 13:42:37 +00:00
|
|
|
echo "ospkgs: yum -y upgrade"
|
|
|
|
echo " $result"
|
2010-07-23 18:27:29 +00:00
|
|
|
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
|
2011-10-10 07:46:18 +00:00
|
|
|
cmd="echo $groups| $ENVLIST xargs yum -y groupinstall"
|
|
|
|
result=`eval $cmd 2>&1`
|
2010-07-30 20:20:51 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2012-11-25 02:33:54 +00:00
|
|
|
RETURNVAL=$?
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "ospkgs: $cmd\n $result"
|
2010-07-30 20:20:51 +00:00
|
|
|
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
|
2011-10-10 07:46:18 +00:00
|
|
|
cmd="$ENVLIST yum -y install $pkgs"
|
|
|
|
result=`eval $cmd 2>&1`
|
2010-07-30 20:20:51 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2012-11-25 02:33:54 +00:00
|
|
|
RETURNVAL=$?
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "ospkgs: $cmd\n $result"
|
2010-07-30 20:20:51 +00:00
|
|
|
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
|
2011-10-10 07:46:18 +00:00
|
|
|
cmd="$ENVLIST yum -y remove $pkgs_d"
|
|
|
|
result=`eval $cmd 2>&1`
|
2010-07-30 20:20:51 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2012-11-25 02:33:54 +00:00
|
|
|
RETURNVAL=$?
|
2012-05-15 03:33:46 +00:00
|
|
|
logger -t xcat -p local4.info "ospkgs: $cmd\n $result"
|
2010-07-30 20:20:51 +00:00
|
|
|
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
|
|
|
|
|
2012-11-25 02:33:54 +00:00
|
|
|
exit $RETURNVAL
|
2010-07-23 18:27:29 +00:00
|
|
|
|
|
|
|
|