diff --git a/xCAT/postscripts/otherpkgs b/xCAT/postscripts/otherpkgs index eb17aae10..a97cb73f7 100755 --- a/xCAT/postscripts/otherpkgs +++ b/xCAT/postscripts/otherpkgs @@ -10,15 +10,15 @@ # 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: -# profile.os.arch.otherpkgs.pkglist -# profile.os.otherpkgs.pkglist -# profile.arch.otherpkgs.pkglist +# profile.os.arch.otherpkgs.pkglist +# profile.os.otherpkgs.pkglist +# profile.arch.otherpkgs.pkglist # profile.otherpkgs.pkglist -# The install/deployment process will pick up the rpms and install them on the nodes. +# 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: -# updatenode noderange otherpkgs -# +# updatenode noderange otherpkgs +# #=cut #------------------------------------------------------------------------------- @@ -28,7 +28,7 @@ if [ -f /etc/os-release ] && cat /etc/os-release |grep -i -e "^NAME=[ \"']*Cumulus Linux[ \"']*$" >/dev/null 2>&1 ; then #TODO echo "Cumulus OS is not supported yet, nothing to do..." - logger -t xcat -p local4.info "Cumulus OS is not supported yet, nothing to do..." + logger -t xcat -p local4.info "Cumulus OS is not supported yet, nothing to do..." exit 0 fi @@ -219,14 +219,14 @@ if [ -z "$UPDATENODE" ] || [ $UPDATENODE -ne 1 ]; then if [ "$NODESETSTATE" = "netboot" -o \ "$NODESETSTATE" = "statelite" -o \ "$NODESETSTATE" = "diskless" -o \ - "$NODESETSTATE" = "dataless" ] + "$NODESETSTATE" = "dataless" ] then echo " Did not install any extra packages." exit 0 fi -fi +fi -if [ -z "$OTHERPKGS_INDEX" ]; then +if [ -z "$OTHERPKGS_INDEX" ]; then echo "$0: no extra rpms to install" exit 0 fi @@ -243,7 +243,7 @@ fi mounted=0; result=`mount |grep " $INSTALLDIR " |grep $NFSSERVER` if [ $? -eq 0 ]; then - mounted=1 + mounted=1 fi if [ -n "$OTHERPKGDIR" ]; then @@ -271,10 +271,10 @@ if [ -z "$OTHERPKGDIR" ]; then else OTHERPKGDIR="$INSTALLDIR/post/otherpkgs/$OSVER/$ARCH" fi - + if ( pmatch "$OSVER" "ubuntu*" ); then OTHERPKGDIR="" - fi + fi else if [ $mounted -eq 0 ]; then OTHERPKGDIR=${NFSSERVER}${OTHERPKGDIR} @@ -282,12 +282,12 @@ else fi ######################### -##start collecting the repositories for os +##start collecting the repositories for os if [ -z "$OSPKGDIR" ]; then OSPKGDIR="$INSTALLDIR/$OSVER/$ARCH" fi - -if [ "$KERNELDIR" != "" ]; then + +if [ "$KERNELDIR" != "" ]; then OSPKGDIR="$OSPKGDIR,$KERNELDIR" fi @@ -297,22 +297,22 @@ fi IFS=$(printf ',') fi - array_ospkgdirs=($OSPKGDIR) + array_ospkgdirs=($OSPKGDIR) IFS=$OIFS array_empty os_path index=0 - for dir in ${array_ospkgdirs[@]} + for dir in ${array_ospkgdirs[@]} do - + default_pkgdir="$INSTALLDIR/$OSVER/$ARCH" - OSPKGDIR="$OSPKGDIR" + OSPKGDIR="$OSPKGDIR" if [ $mounted -eq 0 ]; then - #OSPKGDIR="$OSPKGDIR" + #OSPKGDIR="$OSPKGDIR" ospkgdir="$NFSSERVER$dir" - else + else ospkgdir="$dir" fi - + # for the os base pkg dir(default_pkgdir) , there are some special cases. # (1)for rhels6, there is one repodata in the os base dir; so keep it here, and handle the other cases below # (2)for sles, we should specified the baseurl should be ./install/sles11/ppc64/1 @@ -329,37 +329,37 @@ fi fi fi array_set_element os_path $index $ospkgdir - + if ( pmatch "$OSVER" "rhel*" ); then #default_pkgdir="$INSTALLDIR/$OSVER/$ARCH" if [ $dir == $default_pkgdir ] || [ $dir == "$default_pkgdir/" ]; then - + if ( pmatch "$OSVER" "rhels6*" ); then if [ $ARCH == "ppc64" ]; then ospkgdir_ok="$ospkgdir/Server" - index=$(expr $index + 1) + index=$(expr $index + 1) array_set_element os_path $index $ospkgdir_ok - fi - + fi + if [ $ARCH == "x86_64" ]; then - for arg in "Server" "ScalableFileSystem" "HighAvailability" "ResilientStorage" "LoadBalancer" + for arg in "Server" "ScalableFileSystem" "HighAvailability" "ResilientStorage" "LoadBalancer" do ospkgdir_ok="$ospkgdir/$arg" - index=$(expr $index + 1) + index=$(expr $index + 1) array_set_element os_path $index $ospkgdir_ok done - fi + fi elif ( pmatch "$OSVER" "rhels5*" ); then # for rhels5, the repodata is in ./Server, ./Cluster, ./CusterStorage, not in ./ ospkgdir_ok="$ospkgdir/Server" array_set_element os_path $index $ospkgdir_ok - + if [ $ARCH == "x86_64" ]; then for arg in "Cluster" "ClusterStorage" do ospkgdir_ok="$ospkgdir/$arg" - index=$(expr $index + 1) + index=$(expr $index + 1) array_set_element os_path $index $ospkgdir_ok done fi # x86_64 @@ -367,20 +367,20 @@ fi fi # eq default_pkgdir fi # match rhel* - index=$(expr $index + 1) - - done + index=$(expr $index + 1) + + done #fi -#if [ "$SDKDIR" != "" ]; then +#if [ "$SDKDIR" != "" ]; then # if [ $mounted -eq 0 ]; then # SDKDIR="$NFSSERVER/$SDKDIR" # fi #fi -##end collecting the repositories for os +##end collecting the repositories for os ######################### if [ $VERBOSE ]; then echo NFSSERVER=$NFSSERVER @@ -395,12 +395,12 @@ logger -p local4.info -t xcat "OTHERPKGDIR=$OTHERPKGDIR" # dhcpcd -n $PRIMARYNIC #fi -#check if the node has yum or zypper installed, it will try yum first, then zypper and last rpm -# for rpm based machines, or check if apt is installed, then it will use apt then dpkg +#check if the node has yum or zypper installed, it will try yum first, then zypper and last rpm +# for rpm based machines, or check if apt is installed, then it will use apt then dpkg hasrpm=0 -hasyum=0 -haszypper=0 +hasyum=0 +haszypper=0 hasapt=0 hasdpkg=0 supdatecommand="rpm -Uvh --replacepkgs" @@ -450,8 +450,8 @@ if ( ! ( pmatch "$OSVER" "sles10*" ) && [ $haszypper -eq 1 ] ); then SUM=$(array_get_size os_path) i=0 - - if [ $SUM -eq 0 ]; then + + if [ $SUM -eq 0 ]; then if [ $mounted -eq 0 ]; then path="http://$OSPKGDIR" @@ -459,8 +459,8 @@ if ( ! ( pmatch "$OSVER" "sles10*" ) && [ $haszypper -eq 1 ] ); then path="file://$OSPKGDIR" fi result=`zypper ar $path xCAT-$OSVER 2>&1` - if [ $? -ne 0 ]; then - if ( ! pmatch "$result" "*exists*" ); then + if [ $? -ne 0 ]; then + if ( ! pmatch "$result" "*exists*" ); then logger -t xcat -p local4.info "ospkgs: zypper ar $path xCAT-$OSVER\n $result" if [ $VERBOSE ]; then echo "ospkgs: zypper ar $path xCAT-$OSVER" @@ -468,8 +468,8 @@ if ( ! ( pmatch "$OSVER" "sles10*" ) && [ $haszypper -eq 1 ] ); then fi fi fi - else - while [ $i -lt $SUM ]; do + else + while [ $i -lt $SUM ]; do OSPKGDIR=$(array_get_element os_path $i) if [ $mounted -eq 0 ]; then path="http://$OSPKGDIR" @@ -477,8 +477,8 @@ if ( ! ( pmatch "$OSVER" "sles10*" ) && [ $haszypper -eq 1 ] ); then path="file://$OSPKGDIR" fi result=`zypper ar $path xCAT-$OSVER-"path$i" 2>&1` - if [ $? -ne 0 ]; then - if ( ! pmatch "$result" "*exists*" ); then + if [ $? -ne 0 ]; then + if ( ! pmatch "$result" "*exists*" ); then logger -t xcat -p local4.info "ospkgs: zypper ar $path xCAT-$OSVER-path$i\n $result" if [ $VERBOSE ]; then echo "ospkgs: zypper ar $path xCAT-$OSVER-path$i" @@ -486,8 +486,8 @@ if ( ! ( pmatch "$OSVER" "sles10*" ) && [ $haszypper -eq 1 ] ); then fi fi fi - - i=$((i+1)) + + i=$((i+1)) done fi @@ -518,9 +518,9 @@ if ( ! ( pmatch "$OSVER" "sles10*" ) && [ $haszypper -eq 1 ] ); then IFS=$OIFS fi - result=`zypper --non-interactive --no-gpg-checks refresh 2>&1` + result=`zypper --non-interactive --no-gpg-checks refresh 2>&1` -elif ( ((pmatch "$OSVER" "rhel*") || (pmatch "$OSVER" "centos*") || (pmatch "$OSVER" "SL*")) && [ $hasyum -eq 1 ] ); then +elif ( ((pmatch "$OSVER" "rhel*") || (pmatch "$OSVER" "centos*") || (pmatch "$OSVER" "SL*")) && [ $hasyum -eq 1 ] ); then #remove old repo mkdir -p /etc/yum.repos.d if [ -r "/etc/yum.repos.d/local-repository.repo" ]; then @@ -534,8 +534,8 @@ elif ( ((pmatch "$OSVER" "rhel*") || (pmatch "$OSVER" "centos*") || (pmatch "$OS SUM=$(array_get_size os_path) i=0 - - while [ $i -lt $SUM ]; do + + while [ $i -lt $SUM ]; do REPOFILE="/etc/yum.repos.d/xCAT-$OSVER-path$i.repo" OSPKGDIR=$(array_get_element os_path $i) @@ -551,8 +551,8 @@ elif ( ((pmatch "$OSVER" "rhel*") || (pmatch "$OSVER" "centos*") || (pmatch "$OS echo "enabled=1" >> $REPOFILE echo "gpgcheck=0" >> $REPOFILE fi - i=$((i+1)) - done + i=$((i+1)) + done fi ##end generating the os pkg repositories @@ -568,11 +568,11 @@ fi # through this loop) op_index=1 #echo "OTHERPKGS_INDEX = $OTHERPKGS_INDEX" -while [ $op_index -le $OTHERPKGS_INDEX ]; do +while [ $op_index -le $OTHERPKGS_INDEX ]; do eval pkglist=\$OTHERPKGS$op_index eval envlist=\$ENVLIST$op_index #echo "pkglist = $pkglist" - if [ $hasyum -eq 1 ]; then + if [ $hasyum -eq 1 ]; then mkdir -p /etc/yum.repos.d result=`rm /etc/yum.repos.d/xCAT-otherpkgs*.repo 2>&1` result=`yum clean all` @@ -612,12 +612,12 @@ while [ $op_index -le $OTHERPKGS_INDEX ]; do echo "yum: $hasyum, apt: $hasapt, zypper: $haszypper" for x in ${pkgsarray[@]} do - #check if the file name starts with -- or -. + #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 + if [ $pos -eq 1 ]; then x=`echo ${x#-}` pos=`expr index $x -` if [ $pos -eq 1 ]; then @@ -627,7 +627,7 @@ while [ $op_index -le $OTHERPKGS_INDEX ]; do string_type=-1 #start with - fi fi - + if [ $hasyum -eq 0 ] && [ $haszypper -eq 0 ] && [ $hasapt -eq 0 ]; then if [ $string_type -eq -1 ]; then plain_pkgs_preremove="$plain_pkgs_preremove $x" @@ -668,7 +668,7 @@ while [ $op_index -le $OTHERPKGS_INDEX ]; do fi j=$((j+1)) done - break + break fi i=$((i+1)) done @@ -718,12 +718,12 @@ while [ $op_index -le $OTHERPKGS_INDEX ]; do done IFS=$OLDIFS fi - fi + fi fi - if [ $hasyum -eq 1 ]; then + if [ $hasyum -eq 1 ]; then #use yum result=`yum --showduplicates list $fn 2>&1` - if [ $? -eq 0 ]; then + if [ $? -eq 0 ]; then rc=0 array_set_element repo_path $index $path #else @@ -740,7 +740,7 @@ EOF` fi result=`zypper --non-interactive refresh xcat-otherpkgs$index 2>&1` - if [ $? -eq 0 ]; then + if [ $? -eq 0 ]; then rc=0 array_set_element repo_path $index $path else @@ -752,12 +752,12 @@ EOF` result=`zypper sd xcat-otherpkgs$index` fi fi - elif [ $hasapt -eq 1 ]; then + elif [ $hasapt -eq 1 ]; then #use apt apt_get_update_if_repos_changed $REPOFILE result=`apt-cache show $fn 2>&1` - if [ $? -eq 0 ]; then + if [ $? -eq 0 ]; then rc=0 array_set_element repo_path $index $path else @@ -766,22 +766,22 @@ EOF` fi if [ $rc -eq 0 ]; then - repo_pkgs="$repo_pkgs $fn" + repo_pkgs="$repo_pkgs $fn" else #now no hope we have to use rpm command plain_pkgs="$plain_pkgs $x*" fi array_set_element handled_path $(array_get_size handled_path) $path fi - done + done - #add repo for url repos in otherpkgdir + #add repo for url repos in otherpkgdir if [ -n "OTHERPKGDIR_INTERNET" ];then OIFS=$IFS IFS=',' OTHERPKGDIRLIST_INTERNET=($OTHERPKGDIR_INTERNET) - index=$(array_get_size repo_path) + index=$(array_get_size repo_path) for url in ${OTHERPKGDIRLIST_INTERNET[@]} do if [ $hasyum -eq 1 ] || [ $haszypper -eq 1 ] ; then @@ -809,14 +809,14 @@ EOF` fi #now update all the existing rpms - if [ $hasyum -eq 1 ]; then + if [ $hasyum -eq 1 ]; then if [ $VERBOSE ]; then echo "$envlist yum -y upgrade" fi result=`eval $envlist yum -y upgrade 2>&1` R=$? if [ $R -ne 0 ]; then - RETURNVAL=$R + RETURNVAL=$R fi logger -p local4.info -t xcat "$result" if [ $VERBOSE ]; then @@ -827,10 +827,10 @@ EOF` echo "$envlist zypper --non-interactive update --auto-agree-with-license" fi result=`eval $envlist zypper --non-interactive update --auto-agree-with-license 2>&1` - + R=$? if [ $R -ne 0 ]; then - RETURNVAL=$R + RETURNVAL=$R fi logger -p local4.info -t xcat "$result" if [ $VERBOSE ]; then @@ -844,13 +844,13 @@ EOF` result=`eval $envlist DEBIAN_FRONTEND=noninteractive apt-get -y --allow-unauthenticated --force-yes -o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef' upgrade 2>&1` R=$? if [ $R -ne 0 ]; then - RETURNVAL=$R + RETURNVAL=$R fi logger -p local4.info -t xcat "$result" if [ $VERBOSE ]; then echo "$result" fi - fi + fi #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" @@ -858,14 +858,14 @@ EOF` #Now we have parsed the input, let's remove rpms if is specified with - if [ "$repo_pkgs_preremove" != "" ]; then - if [ $hasyum -eq 1 ]; then + if [ $hasyum -eq 1 ]; then if [ $VERBOSE ]; then echo "$envlist yum -y remove $repo_pkgs_preremove" - fi + fi result=`eval $envlist yum -y remove $repo_pkgs_preremove 2>&1` R=$? if [ $R -ne 0 ]; then - RETURNVAL=$R + RETURNVAL=$R fi logger -p local4.info -t xcat "$result" if [ $VERBOSE ]; then @@ -878,7 +878,7 @@ EOF` result=`eval $envlist zypper remove -y $repo_pkgs_preremove 2>&1` R=$? if [ $R -ne 0 ]; then - RETURNVAL=$R + RETURNVAL=$R fi logger -p local4.info -t xcat "$result" if [ $VERBOSE ]; then @@ -892,23 +892,23 @@ EOF` result=`DEBIAN_FRONTEND=noninteractive apt-get -y remove $repo_pkgs_preremove 2>&1` R=$? if [ $R -ne 0 ]; then - RETURNVAL=$R + RETURNVAL=$R fi logger -p local4.info -t xcat "$result" if [ $VERBOSE ]; then echo "$result" fi fi - fi + fi - if [ "$plain_pkgs_preremove" != "" ]; then + if [ "$plain_pkgs_preremove" != "" ]; then if [ $VERBOSE ]; then - echo "$envlist $sremovecommand $plain_pkgs_preremove" - fi + echo "$envlist $sremovecommand $plain_pkgs_preremove" + fi result=`eval $envlist $sremovecommand $plain_pkgs_preremove 2>&1` R=$? if [ $R -ne 0 ]; then - RETURNVAL=$R + RETURNVAL=$R fi logger -p local4.info -t xcat "$result" if [ $VERBOSE ]; then @@ -917,16 +917,16 @@ EOF` fi - #installation using yum or zypper + #installation using yum or zypper if [ "$repo_pkgs" != "" ]; then - if [ $hasyum -eq 1 ]; then + if [ $hasyum -eq 1 ]; then if [ $VERBOSE ]; then echo "$envlist yum -y install $repo_pkgs" fi result=`eval $envlist yum -y install $repo_pkgs 2>&1` R=$? if [ $R -ne 0 ]; then - RETURNVAL=$R + RETURNVAL=$R fi logger -p local4.info -t xcat "$result" if [ $VERBOSE ]; then @@ -939,7 +939,7 @@ EOF` result=`eval $envlist zypper install -y $repo_pkgs 2>&1` R=$? if [ $R -ne 0 ]; then - RETURNVAL=$R + RETURNVAL=$R fi logger -p local4.info -t xcat "$result" if [ $VERBOSE ]; then @@ -959,31 +959,31 @@ EOF` result=`eval $envlist DEBIAN_FRONTEND=noninteractive apt-get -q -y --force-yes -o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef' install $repo_pkgs 2>&1` R=$? if [ $R -ne 0 ]; then - RETURNVAL=$R + RETURNVAL=$R fi logger -p local4.info -t xcat "$result" if [ $VERBOSE ]; then echo "$result" fi fi - fi + fi #Handle the rest with rpm - if [ "$plain_pkgs" != "" -a -n "$OTHERPKGDIR" ]; then + if [ "$plain_pkgs" != "" -a -n "$OTHERPKGDIR" ]; then echo "Warning: the packages $plain_pkgs could not be found in the yum/apt repository, falling back to rpm/dpkg command. If you want your packages to be installed with yum/apt, verify yum/apt is installed and createrepo/dpkg-scanpackages has been run." - logger -p local4.info -t xcat "Warning: the packages $plain_pkgs could not be found in the yum/apt repository, falling back to rpm/dpkg command. If you want your packages to be installed with yum/apt, verify yum/apt is installed and createrepo/dpkg-scanpackages has been run." + logger -p local4.info -t xcat "Warning: the packages $plain_pkgs could not be found in the yum/apt repository, falling back to rpm/dpkg command. If you want your packages to be installed with yum/apt, verify yum/apt is installed and createrepo/dpkg-scanpackages has been run." if [ $mounted -eq 0 ]; then dir_no_ftproot=${OTHERPKGDIR#*$INSTALLDIR/} - mkdir -p /xcatpost/$dir_no_ftproot + mkdir -p /xcatpost/$dir_no_ftproot rm -f -R /xcatpost/$dir_no_ftproot/* mkdir -p /tmp/postage/ rm -f -R /tmp/postage/* cd /tmp/postage - - wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -e robots=off -t 0 -T 60 --reject "index.html*" --no-parent http://$OTHERPKGDIR/ 2> /tmp/wget.log - + + wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -e robots=off -t 0 -T 60 --reject "index.html*" --no-parent http://$OTHERPKGDIR/ 2> /tmp/wget.log + cd /tmp/postage/$NFSSERVER$INSTALLDIR - mv $dir_no_ftproot/* /xcatpost/$dir_no_ftproot; + mv $dir_no_ftproot/* /xcatpost/$dir_no_ftproot; rm -rf $dir_no_ftproot cd /xcatpost/$dir_no_ftproot else @@ -991,18 +991,18 @@ EOF` fi if [ $VERBOSE ]; then - echo "$envlist $supdatecommand $plain_pkgs" + echo "$envlist $supdatecommand $plain_pkgs" fi result=`eval $envlist $supdatecommand $plain_pkgs 2>&1` R=$? if [ $R -ne 0 ]; then - RETURNVAL=$R + RETURNVAL=$R fi logger -p local4.info -t xcat "$result" if [ $VERBOSE ]; then echo "$result" fi - + if [ $mounted -eq 0 ]; then cd /xcatpost dir_no_ftproot=${OTHERPKGDIR#*$INSTALLDIR/} @@ -1013,14 +1013,14 @@ EOF` #remove more rpms if specified with -- if [ "$repo_pkgs_postremove" != "" ]; then - if [ $hasyum -eq 1 ]; then + if [ $hasyum -eq 1 ]; then if [ $VERBOSE ]; then echo "$envlist yum -y remove $repo_pkgs_postremove" fi result=`eval $envlist yum -y remove $repo_pkgs_postremove 2>&1` R=$? if [ $R -ne 0 ]; then - RETURNVAL=$R + RETURNVAL=$R fi logger -p local4.info -t xcat "$result" if [ $VERBOSE ]; then @@ -1033,13 +1033,13 @@ EOF` result=`eval $envlist zypper remove -y $repo_pkgs_postremove 2>&1` R=$? if [ $R -ne 0 ]; then - RETURNVAL=$R + RETURNVAL=$R fi logger -p local4.info -t xcat "$result" if [ $VERBOSE ]; then echo "$result" fi - elif [ $hasapt -eq 1 ]; then + elif [ $hasapt -eq 1 ]; then apt_get_update_if_repos_changed $REPOFILE if [ $VERBOSE ]; then echo "$envlist apt-get -y remove $repo_pkgs_postremove" @@ -1047,23 +1047,23 @@ EOF` result=`eval $envlist apt-get -y remove $repo_pkgs_postremove 2>&1` R=$? if [ $R -ne 0 ]; then - RETURNVAL=$R + RETURNVAL=$R fi logger -p local4.info -t xcat "$result" if [ $VERBOSE ]; then echo "$result" fi fi - fi + fi - if [ "$plain_pkgs_postremove" != "" ]; then + if [ "$plain_pkgs_postremove" != "" ]; then if [ $VERBOSE ]; then - echo "$envlist $sremovecommand $plain_pkgs_postremove" + echo "$envlist $sremovecommand $plain_pkgs_postremove" fi result=`eval $envlist $sremovecommand $plain_pkgs_postremove 2>&1` R=$? if [ $R -ne 0 ]; then - RETURNVAL=$R + RETURNVAL=$R fi logger -p local4.info -t xcat "$result" if [ $VERBOSE ]; then