From 64400321119d1395aba2ec3f0304dfdba3d0a5ae Mon Sep 17 00:00:00 2001 From: ertaozh Date: Thu, 22 Dec 2016 02:39:54 -0500 Subject: [PATCH] modify getipmi and bmcsetup works also as a post/postboot script for diskful or diskless installation --- build-ubunturepo | 10 +++++++--- makerpm | 9 ++++++++- xCAT-genesis-scripts/bin/bmcsetup | 16 ++++++++++++++-- xCAT-genesis-scripts/bin/getipmi | 9 ++++++++- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/build-ubunturepo b/build-ubunturepo index b4220b4a6..797b4941a 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -232,6 +232,7 @@ then #genesis scripts package, don't remove genesis amd64 files #rm -f ../../$package_dir_name/${file_low}-amd64_*.deb cd $file + CURDIR=$(pwd) dch -v $pkg_version -b -c debian/changelog $build_string if [ "$target_arch" = "all" ]; then #xcat probe use some functions shipped by xCAT, for below reasons we need to copy files to xCAT-probe directory @@ -239,7 +240,6 @@ then #2 don't maintain two files for each script #3 symbolic link can't work during package if [ $file_low = "xcat-probe" ]; then - CURDIR=$(pwd) mkdir -p ${CURDIR}/lib/perl/xCAT/ cp -f ${CURDIR}/../perl-xCAT/xCAT/NetworkUtils.pm ${CURDIR}/lib/perl/xCAT/ cp -f ${CURDIR}/../perl-xCAT/xCAT/GlobalDef.pm ${CURDIR}/lib/perl/xCAT/ @@ -248,15 +248,19 @@ then dpkg-buildpackage -uc -us else if [ "$file" = "xCAT-genesis-scripts" ]; then - CURDIR=$(pwd) echo "Rename control file to build pkg: mv ${CURDIR}/debian/control-${target_arch} ${CURDIR}/debian/control" mv ${CURDIR}/debian/control-${target_arch} ${CURDIR}/debian/control + elif [ "$file" = "xCAT" ]; then + cp ${CURDIR}/../xCAT-genesis-scripts/bin/bmcsetup ${CURDIR}/postscripts/ + cp ${CURDIR}/../xCAT-genesis-scripts/bin/getipmi ${CURDIR}/postscripts/ fi dpkg-buildpackage -uc -us -a$target_arch if [ "$file" = "xCAT-genesis-scripts" ]; then - CURDIR=$(pwd) echo "Move control file back: mv ${CURDIR}/debian/control ${CURDIR}/debian/control-${target_arch}" mv ${CURDIR}/debian/control ${CURDIR}/debian/control-${target_arch} + elif [ "$file" = "xCAT" ]; then + rm -f ${CURDIR}/postscripts/bmcsetup + rm -f ${CURDIR}/postscripts/getipmi fi fi rc=$? diff --git a/makerpm b/makerpm index c80ed0edf..2042f1bbf 100755 --- a/makerpm +++ b/makerpm @@ -107,7 +107,10 @@ function makexcat { TARGET="--target $ARCH" if [ "$RPMNAME" = "xCAT" ]; then - cd `dirname $0`/$RPMNAME + cd `dirname $0`/ + cp xCAT-genesis-scripts/bin/bmcsetup $RPMNAME/postscripts + cp xCAT-genesis-scripts/bin/getipmi $RPMNAME/postscripts + cd $RPMNAME tar --exclude .svn --exclude upflag -czf $RPMROOT/SOURCES/postscripts.tar.gz postscripts LICENSE.html tar --exclude .svn -czf $RPMROOT/SOURCES/prescripts.tar.gz prescripts tar --exclude .svn -czf $RPMROOT/SOURCES/templates.tar.gz templates @@ -139,6 +142,10 @@ function makexcat { echo "Building $RPMROOT/RPMS/$ARCH/$RPMNAME-$VER-snap*.$ARCH.rpm $EMBEDTXT..." rpmbuild $QUIET -ba $RPMNAME/$RPMNAME.spec $TARGET --define "version $VER" $REL "$EASE" RC=$? + if [ "$RPMNAME" = "xCAT" ]; then + rm -f `dirname $0`/$RPMNAME/postscripts/bmcsetup + rm -f `dirname $0`/$RPMNAME/postscripts/getipmi + fi fi } diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 1be072fcd..27d82281c 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -13,7 +13,7 @@ # 0x08 0x00 0x49 0x4e 0x54 0x45 0x4c # 0x08 0x04 # -log_label="xcat.genesis.bmcsetup" +log_label="bmcsetup" TIMEOUT=15 @@ -29,6 +29,7 @@ TIMEOUT=15 function cold_reset_bmc() { if [ -z $XPROD ]; then logger -s -t $log_label -p local4.crit "CRITICAL ERROR - XPROD must be set before calling ${FUNCNAME[0]}" + rm -f /tmp/ipmicfg.xml exit 1 fi if [ "$XPROD" = "43707" -a "$IPMIMFG" != '0' ]; then @@ -87,6 +88,7 @@ function cold_reset_bmc() { function snooze() { if [ -z $XPROD ]; then logger -s -t $log_label -p local4.crit "CRITICAL ERROR - XPROD must be set before calling ${FUNCNAME[0]}" + rm -f /tmp/ipmicfg.xml exit 1 fi if [ "$XPROD" = "43707" -a "$IPMIMFG" != '0' ]; then @@ -100,7 +102,15 @@ function snooze() { logger -s -t $log_label -p local4.debug "snooze for 1 second..." sleep 1 fi -} +} + +if which ipmitool 2>&1 | grep no; then + echo "No ipmitool find, please install it first"; + exit 1; +fi + +# Add ipmi_devintf module to allow the ipmitool operation in-band +modprobe ipmi_devintf allowcred.awk & CREDPID=$! @@ -605,3 +615,5 @@ while [ $idev -gt 0 ]; do fi done +# remove the bmc configuration information before exit +rm -f /tmp/ipmicfg.xml diff --git a/xCAT-genesis-scripts/bin/getipmi b/xCAT-genesis-scripts/bin/getipmi index f129cb382..5ec67b7c6 100755 --- a/xCAT-genesis-scripts/bin/getipmi +++ b/xCAT-genesis-scripts/bin/getipmi @@ -1,11 +1,12 @@ #!/bin/bash -log_label="xcat.genesis.getipmi" allowcred.awk & CREDPID=$! if [ -z "$XCATDEST" ]; then XCATDEST=$1 fi + +# This section only works in genesis if [ -z "$XCATDEST" ]; then for parm in `cat /proc/cmdline` ; do if echo $parm |grep xcatd= > /dev/null; then @@ -13,6 +14,12 @@ if [ -z "$XCATDEST" ]; then fi done fi +# This section works in diskless/diskful +# The environment MASTER_IP and XCATDPORT is exported by mypostscript +if [ -z "$XCATDEST" ]; then + XCATDEST=$MASTER_IP:$XCATDPORT +fi + for LANCHAN in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do if ipmitool channel info $LANCHAN 2> /dev/null | grep 802.3 > /dev/null 2>&1 && ipmitool raw 0xc 2 $LANCHAN 5 0 0 > /dev/null 2>&1; then break;