diff --git a/xCAT-nbroot2/getdestiny b/xCAT-nbroot2/getdestiny
index e780f0f30..ac45c52a6 100755
--- a/xCAT-nbroot2/getdestiny
+++ b/xCAT-nbroot2/getdestiny
@@ -7,20 +7,24 @@ echo "
300
" > /tmp/destreq.xml
rm /tmp/destreq.xml
-while [ ! -f /tmp/destreq.xml ] || grep error /tmp/ipmicfg.xml; do
+while [ ! -f /tmp/destreq.xml ] || grep error /tmp/destiny.xml; do
if [ -f /tmp/destreq.xml ]; then
- echo -n "Retrying in 60 seconds...";
timer=60
while [ $timer -gt 0 ]; do
+ echo -en "Retrying in $timer seconds \r"
sleep 1
- echo -n .
timer=$(($timer-1));
done
fi
+ echo -en " \r";
if [ -f /etc/xcat/cert.pem -a -f /etc/xcat/certkey.pem ]; then #use client cert if available
- cat /tmp/destreq.xml | openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect $XCATDEST -quiet 2> /dev/null > /tmp/ipmicfg.xml
+ cat /tmp/destreq.xml | openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect $XCATDEST -quiet 2> /dev/null > /tmp/destiny.xml
else
- cat /tmp/destreq.xml | openssl s_client -connect $XCATDEST -quiet 2> /dev/null > /tmp/ipmicfg.xml
+ cat /tmp/destreq.xml | openssl s_client -connect $XCATDEST -quiet 2> /dev/null > /tmp/destiny.xml
fi
done
rm /tmp/destreq.xml
+DESTINY=`grep destiny /tmp/destiny.xml | awk -F'>' '{print $2}'|awk -F'<' '{print $1}'`
+rm /tmp/destiny.xml
+echo $DESTINY
+
diff --git a/xCAT-nbroot2/getipmi b/xCAT-nbroot2/getipmi
index 5beb1e56a..b7b5a3752 100755
--- a/xCAT-nbroot2/getipmi
+++ b/xCAT-nbroot2/getipmi
@@ -20,14 +20,15 @@ echo "
rm /tmp/ipmicfg.xml
while [ ! -f /tmp/ipmicfg.xml ] || grep error /tmp/ipmicfg.xml; do
if [ -f /tmp/ipmicfg.xml ]; then
- echo -n "Retrying in 60 seconds...";
timer=60
while [ $timer -gt 0 ]; do
sleep 1
- echo -n .
+ echo -en "Retrying in $timer seconds \r"
timer=$(($timer-1));
done
fi
+ echo -en " \r";
+
if [ -f /etc/xcat/cert.pem -a -f /etc/xcat/certkey.pem ]; then #use client cert if available
cat /tmp/bmcreq.xml | openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect $XCATDEST -quiet 2> /dev/null > /tmp/ipmicfg.xml
else
diff --git a/xCAT-nbroot2/nextdestiny b/xCAT-nbroot2/nextdestiny
index 203b28f1a..892baa42c 100755
--- a/xCAT-nbroot2/nextdestiny
+++ b/xCAT-nbroot2/nextdestiny
@@ -7,20 +7,23 @@ echo "
300
" > /tmp/destreq.xml
rm /tmp/destreq.xml
-while [ ! -f /tmp/destreq.xml ] || grep error /tmp/ipmicfg.xml; do
+while [ ! -f /tmp/destreq.xml ] || grep error /tmp/destiny.xml; do
if [ -f /tmp/destreq.xml ]; then
- echo -n "Retrying in 60 seconds...";
timer=60
while [ $timer -gt 0 ]; do
+ echo -en "Retrying in $timer seconds \r"
sleep 1
- echo -n .
timer=$(($timer-1));
done
fi
+ echo -en " \r";
if [ -f /etc/xcat/cert.pem -a -f /etc/xcat/certkey.pem ]; then #use client cert if available
- cat /tmp/destreq.xml | openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect $XCATDEST -quiet 2> /dev/null > /tmp/ipmicfg.xml
+ cat /tmp/destreq.xml | openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect $XCATDEST -quiet 2> /dev/null > /tmp/destiny.xml
else
- cat /tmp/destreq.xml | openssl s_client -connect $XCATDEST -quiet 2> /dev/null > /tmp/ipmicfg.xml
+ cat /tmp/destreq.xml | openssl s_client -connect $XCATDEST -quiet 2> /dev/null > /tmp/destiny.xml
fi
done
rm /tmp/destreq.xml
+DESTINY=`grep destiny /tmp/destiny.xml | awk -F'>' '{print $2}'|awk -F'<' '{print $1}'`
+rm /tmp/destiny.xml
+echo $DESTINY
diff --git a/xCAT-nbroot2/xcat-cmdline.sh b/xCAT-nbroot2/xcat-cmdline.sh
index a0eab5a24..0cfb9bfd9 100755
--- a/xCAT-nbroot2/xcat-cmdline.sh
+++ b/xCAT-nbroot2/xcat-cmdline.sh
@@ -115,8 +115,47 @@ for parm in `cat /proc/cmdline`; do
XCATPORT=`echo $parm|awk -F= '{print $2}'|awk -F: '{print $2}'`
fi
done
-if [ "$destiny" = "discover" ]; then #skip a query to xCAT when /proc/cmdline will do
- /bin/dodiscovery
+if [ "$destiny" != "discover" ]; then #we aren't discoverying, we probably can and should get a cert
+ /bin/getcert $XCATMASTER:$XCATPORT
fi
-/bin/getcert $XCATMASTER:$XCATPORT
-/bin/sh
+while :; do
+ if [ -z "$destiny" ]; then
+ destiny=`getdestiny`
+ fi
+ destparameter=`echo $destiny|awk -F= '{print $2}'`
+ destiny=`echo $destiny|awk -F= '{print $1}'`
+ if [ "$destiny" = "discover" ]; then #skip a query to xCAT when /proc/cmdline will do
+ /bin/dodiscovery
+ /bin/getcert $XCATMASTER:$XCATPORT
+ destiny=''
+ elif [ "$destiny" = shell ]; then
+ echo "Dropping to debug shell, exit to check for further action"
+ destiny=''
+ /bin/sh
+ elif [ "$destiny" = runcmd ]; then
+ destiny=''
+ $destparameter
+ elif [ "$destiny" = "reboot" -o "$destiny" = "boot" ]; then
+ /bin/nextdestiny
+ reboot -f
+ elif [ "$destiny" = standby ]; then
+ destiny=''
+ delay=$((30+$RANDOM%270))
+ while [ $delay -gt 0 ]; do
+ echo -en "Received request to retry in a bit, will call xCAT back in $delay seconds \r"
+ delay=$((delay-1))
+ sleep 1
+ done
+ echo "Retrying ";
+ else
+ echo "Unrecognized directive $destiny"
+ destiny=''
+ delay=$((30+$RANDOM%270))
+ while [ $delay -gt 0 ]; do
+ echo -en "Will retry in $delay seconds \r"
+ delay=$((delay-1))
+ sleep 1
+ done
+
+ fi
+done