2008-05-02 19:39:55 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#egan@us.ibm.com
|
|
|
|
#(C)IBM Corp
|
|
|
|
#
|
2011-12-07 17:40:24 +00:00
|
|
|
# This routine transfers the client credentials from ~/.xcat on the MN
|
|
|
|
# to the SN for Linux.
|
|
|
|
# It only does something, if called with the -d flag.
|
|
|
|
# The -d flag was implemented when the call to the routine was moved
|
|
|
|
# from the postscript table into the servicenode postscript.
|
|
|
|
#
|
|
|
|
if [ ! $1 ]; then
|
|
|
|
logger -t xcat "xcatclient call without -d, doing nothing."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
if [ $1 != "-d" ]; then
|
|
|
|
logger -t xcat "xcatclient call without -d, doing nothing."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
logger -t xcat "xcatclient call with -d. getting credentials and cfgloc "
|
2008-05-02 19:39:55 +00:00
|
|
|
|
2009-06-25 19:18:22 +00:00
|
|
|
if [ ! -x /usr/bin/openssl ]; then #Unless we have openssl stup
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "$0: /usr/bin/openssl is not executable"
|
2009-06-25 19:18:22 +00:00
|
|
|
exit 0
|
2009-04-08 14:44:16 +00:00
|
|
|
fi
|
2009-09-01 18:39:07 +00:00
|
|
|
USEOPENSSLFORXCAT=1 #Declare 2.3 style SSL
|
|
|
|
export USEOPENSSLFORXCAT
|
2008-05-02 19:39:55 +00:00
|
|
|
allowcred.awk &
|
|
|
|
CREDPID=$!
|
|
|
|
sleep 1
|
|
|
|
mkdir -p /root/.xcat
|
|
|
|
chmod 700 /root/.xcat
|
2011-04-27 08:53:38 +00:00
|
|
|
getcredentials.awk xcat_client_cred > /tmp/xcat_client_cred
|
|
|
|
grep -E '<error>' /tmp/xcat_client_cred
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
cat /tmp/xcat_client_cred | grep -v '<'|sed -e 's/</</' -e 's/>/>/' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /root/.xcat/client-cred.pem
|
2008-05-13 23:33:16 +00:00
|
|
|
CONT=`cat /root/.xcat/client-cred.pem`
|
2011-04-27 08:53:38 +00:00
|
|
|
while [ -z "$CONT" ]; do
|
2011-09-28 14:06:57 +00:00
|
|
|
SLI=$(awk 'BEGIN{srand(); printf("%d\n",rand()*10)}')
|
|
|
|
SLI=$((10 + $SLI))
|
2011-04-27 08:53:38 +00:00
|
|
|
sleep $SLI
|
|
|
|
getcredentials.awk xcat_client_cred | grep -v '<'|sed -e 's/</</' -e 's/>/>/' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /root/.xcat/client-cred.pem
|
|
|
|
CONT=`cat /root/.xcat/client-cred.pem`
|
|
|
|
done
|
|
|
|
else
|
|
|
|
ERR_MSG=`sed -n 's%.*<error>\(.*\)</error>.*%\1%p' /tmp/xcat_client_cred`
|
|
|
|
logger -t xCAT xcat_client_cred Error: $ERR_MSG
|
|
|
|
fi
|
|
|
|
rm /tmp/xcat_client_cred
|
|
|
|
|
2008-05-02 19:39:55 +00:00
|
|
|
chmod 600 /root/.xcat/client-cred.pem
|
2008-05-02 19:53:01 +00:00
|
|
|
cp _xcat/ca.pem /root/.xcat/ca.pem
|
2008-05-02 20:34:40 +00:00
|
|
|
kill -9 $CREDPID
|