diff --git a/xCAT-client/pods/man1/pasu.1.pod b/xCAT-client/pods/man1/pasu.1.pod index 022d81cb5..12ce672f3 100644 --- a/xCAT-client/pods/man1/pasu.1.pod +++ b/xCAT-client/pods/man1/pasu.1.pod @@ -4,9 +4,9 @@ B - run the ASU to many nodes in parallel =head1 SYNOPSIS -B [B<-V>] [B<-d>] [B<-n>] [B<-l> I] [B<-p> I] [B<-f> I] I I +B [B<-V>] [B<-d>] [B<-n>] [B<-l> I] [B<-p> I] [B<-f> I] [B<-i> I] I I -B [B<-V>] [B<-d>] [B<-n>] [B<-l> I] [B<-p> I] [B<-f> I] B<-b> I I +B [B<-V>] [B<-d>] [B<-n>] [B<-l> I] [B<-p> I] [B<-f> I] [B<-i> I] B<-b> I I B [B<-h> | B<--help>] @@ -60,6 +60,10 @@ By default, pasu filters out (i.e. does not display) the standard initial output If you want this output to be displayed, use this flag. +=item B<-i|--interface> I + +The hostname suffix to be appended to the node names. + =item B<-V|--verbose> Display verbose messages. diff --git a/xCAT-server/lib/xcat/plugins/debian.pm b/xCAT-server/lib/xcat/plugins/debian.pm index 94470d92f..010110f28 100755 --- a/xCAT-server/lib/xcat/plugins/debian.pm +++ b/xCAT-server/lib/xcat/plugins/debian.pm @@ -840,8 +840,11 @@ sub mkinstall errorcode => [1]}); next; } - $kcmdline .= " console=tty0 console=ttyS" - . $sent->{serialport} . "," . $sent->{serialspeed}; + if ( $arch =~ /ppc64/i ) { + $kcmdline .= " console=tty0 console=hvc".$sent->{serialport} . "," . $sent->{serialspeed}; + } else { + $kcmdline .= " console=tty0 console=ttyS".$sent->{serialport} . "," . $sent->{serialspeed}; + } if ($sent->{serialflow} =~ /(hard|cts|ctsrts)/){ $kcmdline .= "n8r"; } @@ -1493,8 +1496,13 @@ sub mknetboot ); next; } - $kcmdline .= + if ( $arch =~ /ppc64/i ) { + $kcmdline .= + "console=tty0 console=hvc" . $sent->{serialport} . "," . $sent->{serialspeed}; + } else { + $kcmdline .= "console=tty0 console=ttyS" . $sent->{serialport} . "," . $sent->{serialspeed}; + } if ($sent->{serialflow} =~ /(hard|tcs|ctsrts)/) { $kcmdline .= "n8r"; diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index 57b03ec70..48d88e15d 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -479,12 +479,24 @@ if ($::INITIALINSTALL || $::FORCE) if ($rc == 0) { xCAT::MsgUtils->message('W', "SELINUX is not disabled, disabling it now..."); - # Disable selinux for running system - my $cmd = "echo 0 > /selinux/enforce"; - my $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($::RUNCMD_RC != 0) + # set selinux be in permissive mode for running system, + # if the user forgot to disable selinux, + # try to not hurt xcat too much + my $enforcefile; + if ( -f "/selinux/enforce") { - xCAT::MsgUtils->message('E', "Failed to disable SELINUX."); + $enforcefile = "/selinux/enforce"; + } elsif ( -f "/sys/fs/selinux/enforce" ) { + $enforcefile = "/sys/fs/selinux/enforce"; + } + if ($enforcefile) + { + my $cmd = "echo 0 > $enforcefile"; + my $outref = xCAT::Utils->runcmd("$cmd", 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message('E', "Failed to disable SELINUX."); + } } # Disable selinux through reboots my $cmd = "sed -i 's/^SELINUX=.*\$/SELINUX=disabled/' /etc/selinux/config"; diff --git a/xCAT-server/share/xcat/install/scripts/post.ubuntu b/xCAT-server/share/xcat/install/scripts/post.ubuntu index 8a9d65132..2da17c8f2 100755 --- a/xCAT-server/share/xcat/install/scripts/post.ubuntu +++ b/xCAT-server/share/xcat/install/scripts/post.ubuntu @@ -185,6 +185,7 @@ echo "$TMP" > /xcatpost/mypostscript export NODE=#TABLE:nodelist:THISNODE:node# export OSVER=#TABLE:nodetype:THISNODE:os# export ARCH=#TABLE:nodetype:THISNODE:arch# +export CONSOLEPORT=#TABLE:nodehm:THISNODE:serialport# #addsiteyum if [[ -r /boot/grub/menu.lst ]]; then sed -i 's/^serial/#serial/' /boot/grub/menu.lst @@ -192,6 +193,33 @@ sed -i 's/^terminal/#terminal/' /boot/grub/menu.lst elif [[ -r /boot/grub/grub.cfg ]] ; then update-grub fi +if echo "$ARCH" | grep -i 'ppc64'; then + CONSOLE="hvc$CONSOLEPORT" + if [[ -r /etc/default/grub ]] ; then + sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"console=$CONSOLE\"/" /etc/default/grub + else + echo "GRUB_CMDLINE_LINUX_DEFAULT=\"console=$CONSOLE\"" > /etc/default/grub + fi + update-grub + +cat >/etc/init/$CONSOLE\.conf << 'EOF' +start on stopped rc RUNLEVEL=[2345] and (not-container or container container CONTAINER=lxc or container CONTAINER=lxc-libvirt) +stop on runlevel [!2345] +respawn +script + for i in `cat /proc/cmdline`; do + KEY=`echo $i|cut -d= -f 1` + if [ "$KEY" == "console" -a "$i" != "console=tty0" ]; then + VALUE=`echo $i | cut -d= -f 2` + COTTY=`echo $VALUE|cut -d, -f 1` + COSPEED=`echo $VALUE|cut -d, -f 2|cut -dn -f 1` + exec /sbin/getty -L $COSPEED $COTTY vt102 + break + fi + done +end script +EOF +fi sed -i 's/\(deb.*security.*\)/#\1/' /etc/apt/sources.list #iso does not contains source deb packages sed -i 's/^\(\s*deb-src.*install.*\)$/#\1/g' /etc/apt/sources.list diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.1.postinstall b/xCAT-server/share/xcat/netboot/ubuntu/compute.postinstall similarity index 77% rename from xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.1.postinstall rename to xCAT-server/share/xcat/netboot/ubuntu/compute.postinstall index d2bc8eb82..892a8ee49 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.1.postinstall +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.postinstall @@ -41,4 +41,19 @@ END #for ext in pkglist exlist postinstall repolist; do # [ -r $workdir/$profile.$ext ] && cat $workdir/$profile.$ext | grep -E '^[[:space:]]*#.*[[:space:]]\$Id' >> $installroot/etc/IMGVERSION #done - +if echo "$arch" | grep -i 'ppc64'; then + CONSOLE="hvc0" +for i in `cat /proc/cmdline`; do + KEY=`echo $i|cut -d= -f 1` + if [ "$KEY" == "console" -a "$i" != "console=tty0" ]; then + CONSOLEPARAM=$i + CONSOLE=`echo $i | cut -d= -f 2 | cut -d, -f 1` + fi +done +if [[ -r $installroot/etc/default/grub ]]; then + sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"console=$CONSOLE\"/" $installroot/etc/default/grub +else + echo "GRUB_CMDLINE_LINUX_DEFAULT=\"console=$CONSOLE\"" > $installroot/etc/default/grub +fi +#update-grub +fi diff --git a/xCAT-server/share/xcat/netboot/ubuntu/genimage b/xCAT-server/share/xcat/netboot/ubuntu/genimage index 8ae54c759..3e490c6ce 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/genimage +++ b/xCAT-server/share/xcat/netboot/ubuntu/genimage @@ -982,6 +982,14 @@ EOS1 print $inifile "mknod /dev/ttyS1 c 4 65\n"; print $inifile "mknod /dev/ttyS2 c 4 66\n"; print $inifile "mknod /dev/ttyS3 c 4 67\n"; + print $inifile "mknod /dev/hvc0 c 229 0\n"; + print $inifile "mknod /dev/hvc1 c 229 1\n"; + print $inifile "mknod /dev/hvc2 c 229 2\n"; + print $inifile "mknod /dev/hvc3 c 229 3\n"; + print $inifile "mknod /dev/hvc4 c 229 4\n"; + print $inifile "mknod /dev/hvc5 c 229 5\n"; + print $inifile "mknod /dev/hvc6 c 229 6\n"; + print $inifile "mknod /dev/hvc7 c 229 7\n"; foreach (@ndrivers) { print $inifile "insmod /lib/$_\n"; diff --git a/xCAT/postscripts/otherpkgs b/xCAT/postscripts/otherpkgs index 69099a94f..e929497d8 100755 --- a/xCAT/postscripts/otherpkgs +++ b/xCAT/postscripts/otherpkgs @@ -211,7 +211,7 @@ if [ -z "$UPDATENODE" ] || [ $UPDATENODE -ne 1 ]; then "$NODESETSTATE" = "diskless" -o \ "$NODESETSTATE" = "dataless" ] then - echo " Did not install any extra rpms." + echo " Did not install any extra packages." exit 0 fi fi diff --git a/xCAT/postscripts/otherpkgs.ubuntu b/xCAT/postscripts/otherpkgs.ubuntu deleted file mode 100755 index 468411a55..000000000 --- a/xCAT/postscripts/otherpkgs.ubuntu +++ /dev/null @@ -1,472 +0,0 @@ -#!/bin/bash -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html - -#------------------------------------------------------------------------------- -#=head1 otherpkgs -#=head2 It gets the extra rpms and install/update them. -# The environment variable OTHERPKGS contains the rpms to be installed/updated. -# On MN, You need to: -# 1. put rpms under /install/post/otherpkgs/os/arch directory where 'os' and 'arch' -# 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.otherpkgs.pkglist -# 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 -# -#=cut -#------------------------------------------------------------------------------- - - -# do nothing for diskless deployment case because it is done in the image already -if [[ $UPDATENODE -ne 1 ]]; then - if [ "$NODESETSTATE" = "netboot" -o \ - "$NODESETSTATE" = "statelite" -o \ - "$NODESETSTATE" = "diskless" -o \ - "$NODESETSTATE" = "dataless" ] - then - echo " Did not install any extra rpms." - exit 0 - fi -fi - -if [[ -z "$OTHERPKGS_INDEX" ]]; 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="/install" - mounted=1 -fi - -if [[ -z "$OTHERPKGDIR" ]]; then - OTHERPKGDIR="$NFSSERVER/post/otherpkgs/$OSVER/$ARCH" -fi - -if [ $mounted -eq 0 ]; then - OTHERPKGDIR=${OTHERPKGDIR/#$INSTALLDIR/$NFSSERVER/} -fi - -echo NFSSERVER=$NFSSERVER -logger -t xcat -p local4.info "NFSSERVER=$NFSSERVER" -echo OTHERPKGDIR=$OTHERPKGDIR -logger -t xcat -p local4.info "OTHERPKGDIR=$OTHERPKGDIR" - -#if [ -x "/sbin/dhcpcd" ]; then -# 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 - -RETURNVAL=0 -hasrpm=0 -hasyum=0 -haszypper=0 -hasapt=0 -hasdpkg=0 -scommand="rpm" -sinstallcommad="$scommand -ivh" -supdatecommad="$scommand -Uvh --replacepkgs" -sremovecommad="$scommand -ev" - -result=`which rpm` -if [ $? -eq 0 ]; then - hasrpm=1 - result=`rpm -q yum` - if [ $? -eq 0 ]; then - hasyum=1 - else - result=`rpm -q zypper` - if [ "$?" = "0" ]; then - haszypper=1 - fi - fi -else - result=`which dpkg` - if [ $? -eq 0 ]; then - hasdpkg=1 - scommand="dpkg" - sinstallcommand="$scommand -i" - supdatecommand="$sinstallcommand" - sremovecommand="$scommand -r" - result=`dpkg -l apt` - if [ $? -eq 0 ]; then - hasapt=1 - fi - fi -fi - - -# To support the #NEW_INSTALL_LIST# entry in otherpkgs.pkglist files, -# multiple lists of packages are provided to this script in the form: -# OTHERPKGS1, OTHERPKGS2, ... OTHERPKSn where n=OTHERPKGS_INDEX -# Each sublist will be installed in a separate call (separate pass -# through this loop) -op_index=1 -#echo "OTHERPKGS_INDEX = $OTHERPKGS_INDEX" -while [ $op_index -le $OTHERPKGS_INDEX ]; do - eval pkglist=\$OTHERPKGS$op_index - #echo "pkglist = $pkglist" - 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` - repo_base="/etc/yum.repos.d" - elif [ $haszypper -eq 1 ]; then - #remove old repo - old_repo=`zypper sl |grep xcat-otherpkgs | cut -f2 -d '|'` - for x in $old_repo - do - result=`zypper sd $x` - done - zypper --non-interactive refresh - repo_base="/tmp" - elif [ $hasapt -eq 1 ] ; then - mkdir -p /etc/apt/sources.list.d - result=`rm /etc/apt/sources.list.d/xCAT-otherpkgs*.list 2>&1` - result=`apt-get -y update` - repo_base="/etc/apt/sources.list.d" - fi - - repo_path=() - repo_pkgs="" - repo_pkgs_preremove="" - repo_pkgs_postremove="" - plain_pkgs="" - plain_pkgs_preremove="" - plain_pkgs_postremove="" - handled_path=() - for x in `echo "$pkglist" | tr "," "\n"` - do - #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 - - if [ $hasyum -eq 0 ] && [ $haszypper -eq 0 ] && [ $hasapt -eq 0 ]; then - 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 - continue - fi - - 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 - #whole_path=$OTHERPKGDIR - - #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 - - - #try to add the path to the repo - if [ $try_repo -eq 1 ]; then - index=${#repo_path[*]} - if [ $hasyum -eq 1 ] || [ $haszypper -eq 1 ] ; then - 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 - elif [ $hasapt -eq 1 ] ; then - REPOFILE="$repo_base/xCAT-otherpkgs$index.list" - - if [ $mounted -eq 0 ]; then - type=ftp - else - type=file - fi - - echo "deb $type://$whole_path /" >> $REPOFILE - fi - - 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 - if [[ "$OSVER" = sles11* ]]; then - result=`zypper ar -c $REPOFILE` - else - result=`zypper sa -c $REPOFILE` - fi - - result=`zypper --non-interactive refresh xcat-otherpkgs$index 2>&1` - if [ $? -eq 0 ]; then - rc=0 - repo_path[${#repo_path[*]}]=$path - else - result=`zypper sd xcat-otherpkgs$index` - fi - elif [ $hasapt -eq 1 ]; then - #use apt - result=`apt-cache search $fn 2>&1` - if [ $? -eq 0 ]; then - rc=0 - repo_path[${#repo_path[*]}]=$path - else - rm $REPOFILE - 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 - done - - #now update all the existing rpms - if [ $hasyum -eq 1 ]; then - echo "yum -y upgrade" - result=`yum -y upgrade 2>&1` - logger -t xcat -p local4.info "$result" - if [ $? -ne 0 ]; then - logger -t xcat -p local4.info "otherpkgs: $result" - fi - echo "$result" - elif [ $haszypper -eq 1 ]; then - echo "zypper --non-interactive update --auto-agree-with-license" - result=`zypper --non-interactive update --auto-agree-with-license 2>&1` - logger -t xcat -p local4.info "$result" - if [ $? -ne 0 ]; then - logger -t xcat -p local4.info "otherpkgs: $result" - fi - echo "$result" - 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" - - - #Now we have parsed the input, let's remove rpms if is specified with - - if [ "$repo_pkgs_preremove" != "" ]; then - if [ $hasyum -eq 1 ]; then - echo "yum -y remove $repo_pkgs_preremove" - result=`yum -y remove $repo_pkgs_preremove 2>&1` - R=$? - if [ $R -ne 0 ]; then - RETURNVAL=$R - fi - logger -t xcat -p local4.info "otherpkgs: $result" - echo "$result" - elif [ $haszypper -eq 1 ]; then - echo "zypper remove -y $repo_pkgs_preremove" - result=`zypper remove -y $repo_pkgs_preremove 2>&1` - R=$? - if [ $R -ne 0 ]; then - RETURNVAL=$R - fi - logger -t xcat -p local4.info "otherpkgs: $result" - echo "$result" - fi - fi - - if [ "$plain_pkgs_preremove" != "" ]; then - echo "$sremovecommand $plain_pkgs_preremove" - result=`$sremovecommand $plain_pkgs_preremove 2>&1` - R=$? - if [ $R -ne 0 ]; then - RETURNVAL=$R - fi - logger -t xcat -p local4.info "otherpkgs $result" - echo "$result" - fi - - - #installation using yum or zypper - if [ "$repo_pkgs" != "" ]; then - if [ $hasyum -eq 1 ]; then - echo "yum -y install $repo_pkgs" - result=`yum -y install $repo_pkgs 2>&1` - R=$? - if [ $R -ne 0 ]; then - RETURNVAL=$R - fi - logger -t xcat -p local4.info "otherpkgs: $result" - echo "$result" - elif [ $haszypper -eq 1 ]; then - echo "zypper install -y $repo_pkgs" - result=`zypper install -y $repo_pkgs 2>&1` - R=$? - if [ $R -ne 0 ]; then - RETURNVAL=$R - fi - logger -t xcat -p local4.info "otherpkgs: $result" - echo "$result" - #remove the repos - #old_repo=`zypper lr -u |grep xcat-otherpkgs | cut -f2 -d '|'` - #for x in $old_repo - #do - # result=`zypper sd $x` - #done - elif [ $hasapt -eq 1 ]; then - echo "apt-get -q -y --force-yes install $repo_pkgs" - result=`apt-get -q -y --force-yes install $repo_pkgs 2>&1` - R=$? - if [ $R -ne 0 ]; then - RETURNVAL=$R - fi - logger -t xcat -p local4.info "otherpkgs: $result" - echo "$result" - fi - fi - - #Handle the rest with rpm - if [ "$plain_pkgs" != "" ]; then - if [ $mounted -eq 0 ]; then - dir_no_ftproot=${OTHERPKGDIR#$INSTALLDIR/} - 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 - - for x in `echo "$plain_pkgs" | tr " " "\n"` - do - wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$OTHERPKGDIR/$x 2> /tmp/wget.log - done - - mv $dir_no_ftproot/* /xcatpost/$dir_no_ftproot; - rm -rf $NFSSERVER - cd /xcatpost/$dir_no_ftproot - else - cd $OTHERPKGDIR - fi - - echo "$supdatecommand --replacepkgs $plain_pkgs" - result=`$supdatecommand --replacepkgs $plain_pkgs 2>&1` - logger -t xcat -p local4.info "$result" - if [ $? -ne 0 ]; then - logger -t xcat -p local4.info "otherpkgs $result" - fi - echo "$result" - - if [ $mounted -eq 0 ]; then - cd /xcatpost - dir_no_ftproot=${OTHERPKGDIR#$INSTALLDIR/} - dir_no_ftproot=${dir_no_ftproot/\/*/} - rm -f -R $dir_no_ftproot - fi - fi - - #remove more rpms if specified with -- - if [ "$repo_pkgs_postremove" != "" ]; then - if [ $hasyum -eq 1 ]; then - echo "yum -y remove $repo_pkgs_postremove" - result=`yum -y remove $repo_pkgs_postremove 2>&1` - R=$? - if [ $R -ne 0 ]; then - RETURNVAL=$R - fi - logger -t xcat -p local4.info "otherpkgs: $result" - echo "$result" - elif [ $haszypper -eq 1 ]; then - echo "zypper remove -y $repo_pkgs_postremove" - result=`zypper remove -y $repo_pkgs_postremove 2>&1` - R=$? - if [ $R -ne 0 ]; then - RETURNVAL=$R - fi - logger -t xcat -p local4.info "otherpkgs: $result" - echo "$result" - elif [ $hasapt -eq 1 ]; then - echo "apt-get -y remove $repo_pkgs_postremove" - result=`apt-get -y remove $repo_pkgs_postremove 2>&1` - R=$? - if [ $R -ne 0 ]; then - RETURNVAL=$R - fi - logger -t xcat -p local4.info "otherpkgs: $result" - echo "$result" - fi - fi - - if [ "$plain_pkgs_postremove" != "" ]; then - echo "$sremovecommand $plain_pkgs_postremove" - result=`$sremovecommand $plain_pkgs_postremove 2>&1` - R=$? - if [ $R -ne 0 ]; then - RETURNVAL=$R - fi - logger -t xcat -p local4.info "otherpkgs $result" - echo "$result" - fi - - let op_index=$op_index+1 -done - -exit $RETURNVAL - diff --git a/xCAT/postscripts/routeop b/xCAT/postscripts/routeop index 091446d56..0f4f48ac5 100755 --- a/xCAT/postscripts/routeop +++ b/xCAT/postscripts/routeop @@ -6,7 +6,7 @@ #=head2 routeop is called by makeroutes command and setuproutes postscript to # setup a route on a node. # The syntax is: -# routeop add/delete net mask gateway ifnamea #NOTE: the add/delete will be +# routeop add/delete net mask gateway ifname #NOTE: the add/delete will be # obsoleted, using 'replace' is recommended. # routeop replace net mask gateway ifname #NOTE: it only works for sles so far # net - IP of net like 192.168.1.0. The keyword @@ -204,12 +204,6 @@ replace_persistent_route() OS_name="debian" fi - # The replace operation does not support debain so far - if [ "$OS_name" != "redhat" ] && [ "$OS_name" != "sles" ]; then - echo "Warning: replace operation only supports to add persistent route for sles and redhat by now." - return - fi - # set the destination of the route for searching in the route configuration file if [ "$net" = "default" ]; then routedest="default" @@ -221,105 +215,106 @@ replace_persistent_route() case $OS_name in sles) - filename="/etc/sysconfig/network/routes"; - if echo $net | grep : 2>&1 1>/dev/null - then - # for ipv6 - if [ "$gw" = "" -o "$gw" = "::" ] ; then - route="$net/$mask :: - $ifname" - route1="$net\/$mask :: - $ifname"; - else - route="$net/$mask $gw - -" - route1="$net\/$mask $gw - -"; - fi - else - # for ipv4 - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then - if [ "$net" = "default" ]; then - route="default - - $ifname"; - route1="default - - $ifname"; + filename="/etc/sysconfig/network/routes"; + if echo $net | grep : 2>&1 1>/dev/null + then + # for ipv6 + if [ "$gw" = "" -o "$gw" = "::" ] ; then + route="$net/$mask :: - $ifname" + route1="$net\/$mask :: - $ifname"; else - route="$net/$mask - - $ifname"; - route1="$net\/$mask - - $ifname"; + route="$net/$mask $gw - -" + route1="$net\/$mask $gw - -"; fi else - if [ "$net" = "default" ]; then - route="default $gw - $ifname"; - route1="default $gw - $ifname"; + # for ipv4 + if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then + if [ "$net" = "default" ]; then + route="default - - $ifname"; + route1="default - - $ifname"; + else + route="$net/$mask - - $ifname"; + route1="$net\/$mask - - $ifname"; + fi else - route="$net/$mask $gw - $ifname"; - route1="$net\/$mask $gw - $ifname"; + if [ "$net" = "default" ]; then + route="default $gw - $ifname"; + route1="default $gw - $ifname"; + else + route="$net/$mask $gw - $ifname"; + route1="$net\/$mask $gw - $ifname"; + fi fi fi - fi - if [ -f $filename ]; then - egrep "^$routedest" $filename 2>&1 1>/dev/null - if [ $? -ne 0 ]; then #route does not exist - echo $route >> $filename + if [ -f $filename ]; then + egrep "^$routedest" $filename 2>&1 1>/dev/null + if [ $? -ne 0 ]; then #route does not exist + echo $route >> $filename + echo "Persistent route \"$route\" has been added in $filename." + else + # replace it + sed -i -e "s/$routedest1.*/$route1/g" $filename + echo "Persistent route \"$route\" has been replaced in $filename." + fi + else + echo "$route" > $filename echo "Persistent route \"$route\" has been added in $filename." - else - # replace it - sed -i -e "s/$routedest1.*/$route1/g" $filename - echo "Persistent route \"$route\" has been replaced in $filename." fi - else - echo "$route" > $filename - echo "Persistent route \"$route\" has been added in $filename." - fi ;; redhat) - #echo "rh/fedora/centos" - if [ -z "$ifname" ]; then - echo "Error: the device name is necessary to configure static route." - return - fi - - if echo $net | grep : 2>&1 1>/dev/null - then - # ipv6 - filename="/etc/sysconfig/network-scripts/route6-$ifname" - if [ "$gw" = "" -o "$gw" = "::" ] ; then - route="$net/$mask dev $ifname" - route1="$net\/$mask dev $ifname" - else - route="$net/$mask via $gw" - route1="$net\/$mask via $gw" + #echo "rh/fedora/centos" + if [ -z "$ifname" ]; then + echo "Error: the device name is necessary to configure static route." + return fi - else - # ipv4 - filename="/etc/sysconfig/network-scripts/route-$ifname" - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then - route="$net/$mask dev $ifname" - route1="$net\/$mask dev $ifname" + + if echo $net | grep : 2>&1 1>/dev/null + then + # ipv6 + filename="/etc/sysconfig/network-scripts/route6-$ifname" + if [ "$gw" = "" -o "$gw" = "::" ] ; then + route="$net/$mask dev $ifname" + route1="$net\/$mask dev $ifname" + else + route="$net/$mask via $gw" + route1="$net\/$mask via $gw" + fi else - route="$net/$mask via $gw" - route1="$net\/$mask via $gw" + # ipv4 + filename="/etc/sysconfig/network-scripts/route-$ifname" + if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then + route="$net/$mask dev $ifname" + route1="$net\/$mask dev $ifname" + else + route="$net/$mask via $gw" + route1="$net\/$mask via $gw" + fi fi - fi - if [ -f $filename ]; then - egrep "^$routedest" $filename 2>&1 1>/dev/null - if [ $? -ne 0 ]; then #route does not exist - echo $route >> $filename + if [ -f $filename ]; then + egrep "^$routedest" $filename 2>&1 1>/dev/null + if [ $? -ne 0 ]; then #route does not exist + echo $route >> $filename + echo "Persistent route \"$route\" has been added in $filename." + else + # replace it + sed -i -e "s/$routedest1.*/$route1/g" $filename + echo "Persistent route \"$route\" has been replaced in $filename." + fi + else + echo "$route" > $filename echo "Persistent route \"$route\" has been added in $filename." - else - # replace it - sed -i -e "s/$routedest1.*/$route1/g" $filename - echo "Persistent route \"$route\" has been replaced in $filename." fi - else - echo "$route" > $filename - echo "Persistent route \"$route\" has been added in $filename." - fi ;; debian) debianpreconf matchstr="" v6flag=0 - #on debian/ubuntu need the network device name - if [ ! $ifname ];then - ifname=`netstat -nr | grep "$net" | awk '{print $8}' | head -1` + # on debian/ubuntu need the network device name + if [ -z "$ifname" ]; then + echo "Error: the device name is necessary to configure static route." + return fi filename="/etc/network/interfaces.d/$ifname" @@ -327,83 +322,47 @@ replace_persistent_route() echo "auto $ifname" > $filename echo "iface $ifname inet dhcp" >> $filename fi - echo $net | grep : 2>&1 1>/dev/null - #ipv6 - if [ $? -eq 0 ];then - if [ "$gw" = "" -o "$gw" = "::" ] ; then - matchstr="$net/$mask dev $ifname" - else - matchstr="$net/$mask gw $gw" - fi - v6flag=1 - else - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then - matchstr="net $net netmask $mask dev $ifname" - else - matchstr="net $net netmask $mask gw $gw" - fi - fi - grep "$matchstr" $filename 2>&1 1>/dev/null - if [ $? -ne 0 ];then - foundflag=0 - tempfile="/etc/network/interfaces.d/tmp" - while read LINE - do - echo $LINE | grep "iface" 2>&1 1>/dev/null - if [ $? -eq 0 -a $foundflag -eq 1 ];then - foundflag=0 - if [ $v6flag -eq 1 ];then - if [ "$gw" = "" -o "$gw" = "::" ] ; then - echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile - echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile - else - echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile - echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile - fi - else - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then - echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile - echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile - else - echo " up route add -net $net netmask $mask gw $gw" >> $tempfile - echo " down route del -net $net netmask $mask gw $gw" >> $tempfile - fi - fi - fi - echo $LINE | grep "iface $ifname " 2>&1 1>/dev/null - #this is the last line of the device - if [ $? -eq 0 ];then - foundflag=1 - fi + # if the route entry for a target net has been added in the if cfg file, just replace it + cmd="post-up $cmd" + #cmd1=${cmd//\//\\\/} + #sed -i -e "s/.*$routedest1.*/$cmd1/g" $filename - echo $LINE >> $tempfile - done < $filename - #the insert place is the last line of the config file - if [ $foundflag -eq 1 ];then - if [ $v6flag -eq 1 ];then - if [ "$gw" = "" -o "$gw" = "::" ] ; then - echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile - echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile - else - echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile - echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile - fi - else - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then - echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile - echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile - else - echo " up route add -net $net netmask $mask gw $gw" >> $tempfile - echo " down route del -net $net netmask $mask gw $gw" >> $tempfile - fi - fi + # for the case to add a new cmd for certain interface + foundflag=0 + setflag=0 + tempfile="/etc/network/interfaces.d/tmp" + >$tempfile + + while read LINE + do + # replace the existed setting + echo $LINE | grep "$routedest1" 2>&1 1>/dev/null + if [ $? -eq 0 -a $foundflag -eq 1 ];then + LINE=$cmd + setflag=1 fi - mv -f $tempfile $filename - echo "Persistent route \"$matchstr\" added in $filename." - else - echo "Persisten route \"$match\" already exists in $filename" + + echo $LINE | grep "iface" 2>&1 1>/dev/null + if [ $? -eq 0 -a $foundflag -eq 1 -a $setflag -eq 0 ];then + foundflag=0 + echo "$cmd" >> $tempfile + fi + echo $LINE | grep "iface $ifname " 2>&1 1>/dev/null + #this is the last line of the device + if [ $? -eq 0 ];then + foundflag=1 + fi + + echo $LINE >> $tempfile + done < $filename + + #the insert place is the last line of the config file + if [ $foundflag -eq 1 -a $setflag -eq 0 ];then + echo "$cmd" >> $tempfile fi + mv -f $tempfile $filename + echo "Persistent route \"$cmd\" is added in $filename.; " ;; esac @@ -925,7 +884,7 @@ elif [ "$op" = "replace" ]; then fi fi - echo "Adding temporary route: $cmd" + echo "Adding temporary route: $cmd; " result=`$cmd 2>&1` code=$? if [ $code -ne 0 ]; then @@ -935,7 +894,9 @@ elif [ "$op" = "replace" ]; then fi #replace the persistent route - replace_persistent_route $net $mask $gw $ifname + # the $cmd param is used for Ubuntu since it needs to run the specific cmd to enable + # the route during the up of the device + replace_persistent_route $net $mask $gw $ifname fi exit 0