2011-08-31 20:31:54 +00:00
|
|
|
#!/bin/bash
|
|
|
|
if [ -z "$XCATDEST" ]; then
|
|
|
|
XCATDEST=$1
|
|
|
|
fi
|
|
|
|
echo "<xcatrequest>
|
|
|
|
<command>getdestiny</command>
|
|
|
|
<callback_port>300</callback_port>
|
|
|
|
</xcatrequest>" > /tmp/destreq.xml
|
2011-09-06 16:26:16 +00:00
|
|
|
if [ -f /tmp/destiny.xml ]; then rm /tmp/destiny.xml; fi
|
|
|
|
while [ ! -f /tmp/destiny.xml ] || grep error /tmp/destiny.xml; do
|
|
|
|
if [ -f /tmp/destiny.xml ]; then
|
2011-08-31 20:31:54 +00:00
|
|
|
timer=60
|
|
|
|
while [ $timer -gt 0 ]; do
|
2011-09-06 16:26:16 +00:00
|
|
|
echo -en "Retrying in $timer seconds \r" >&2
|
2011-08-31 20:31:54 +00:00
|
|
|
sleep 1
|
|
|
|
timer=$(($timer-1));
|
|
|
|
done
|
|
|
|
fi
|
2011-09-06 16:26:16 +00:00
|
|
|
echo " " >&2
|
2011-08-31 20:31:54 +00:00
|
|
|
if [ -f /etc/xcat/cert.pem -a -f /etc/xcat/certkey.pem ]; then #use client cert if available
|
2011-09-02 17:12:27 +00:00
|
|
|
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
|
2011-08-31 20:31:54 +00:00
|
|
|
else
|
2011-09-02 17:12:27 +00:00
|
|
|
cat /tmp/destreq.xml | openssl s_client -connect $XCATDEST -quiet 2> /dev/null > /tmp/destiny.xml
|
2011-08-31 20:31:54 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
rm /tmp/destreq.xml
|
2011-09-02 17:12:27 +00:00
|
|
|
DESTINY=`grep destiny /tmp/destiny.xml | awk -F'>' '{print $2}'|awk -F'<' '{print $1}'`
|
|
|
|
rm /tmp/destiny.xml
|
|
|
|
echo $DESTINY
|
|
|
|
|