2010-04-08 01:29:57 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# IBM(c) 2010 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#(C)IBM Corp
|
|
|
|
|
|
|
|
#
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#setbootfromnet
|
|
|
|
#
|
|
|
|
# This sets up the node to boot from network, if the GATEWAY is set,
|
|
|
|
# the bootlist will be set with the client ip, server ip and gateway information,
|
|
|
|
# otherwise, only set to boot from network, the client ip, server ip
|
|
|
|
# and the gateway information will not be set to openfirmware
|
|
|
|
#
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
NODE_NAME=$NODE
|
|
|
|
GATE_WAY=$GATEWAY
|
|
|
|
|
|
|
|
OS=`uname`
|
2010-12-30 09:10:11 +00:00
|
|
|
if [ -z $MASTER ]; then
|
|
|
|
msg="$0: The environment variable MASTER is null, pls check.\n"
|
|
|
|
echo $msg
|
2012-05-15 06:24:34 +00:00
|
|
|
logger -t xcat -p local4.err "$msg"
|
2010-12-30 09:10:11 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
SERVER_IP=`echo $MASTER | grep -E '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'`
|
|
|
|
if [ ! -z $SERVER_IP ]; then
|
|
|
|
SERVER_IP=$MASTER
|
|
|
|
else
|
|
|
|
if [[ $OS = "Linux" ]]; then
|
|
|
|
SERVER_IP=`ping -c 3 $MASTER | sed '/icmp_seq/!d;s/.*(\([0-9.]\+\)).*/\1/' | uniq 2>&1`
|
|
|
|
SRET=`echo $?`
|
|
|
|
else ## for AIX
|
|
|
|
SERVER_IP=`ping -c 3 $MASTER | grep "icmp_seq" | sed 's/.*from \([0-9.]*\):.*/\1/' | uniq 2>&1`
|
|
|
|
SRET=`echo $?`
|
|
|
|
fi
|
|
|
|
if [ $SRET -ne 0 ]; then
|
|
|
|
msg="$0: The returned value is not correct, server_ip=$SERVER_IP\n"
|
|
|
|
echo $msg
|
2012-05-15 06:24:34 +00:00
|
|
|
logger -t xcat -p local4.err "$msg"
|
2010-12-30 09:10:11 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-04-08 01:29:57 +00:00
|
|
|
if [ ! -z $NODE_NAME ]; then
|
|
|
|
if [[ $OS = "Linux" ]]; then
|
|
|
|
CLIENT_IP=`ping -c 3 $NODE_NAME | sed '/icmp_seq/!d;s/.*(\([0-9.]\+\)).*/\1/' | uniq 2>&1`
|
|
|
|
RET=`echo $?`
|
|
|
|
NIC=`ip route | grep "src $CLIENT_IP" | sed -r 's/.*dev (.*) proto.*/\1/' 2>&1`
|
|
|
|
NRET=`echo $?`
|
|
|
|
else ## for AIX
|
|
|
|
CLIENT_IP=`ping -c 3 $NODE_NAME | grep "icmp_seq" | sed 's/.*from \([0-9.]*\):.*/\1/' | uniq 2>&1`
|
|
|
|
RET=`echo $?`
|
2011-12-05 08:05:17 +00:00
|
|
|
NIC=`netstat -rni | grep "$CLIENT_IP" | awk '{print $1}' | sed 's/en/ent/g;s/hf/hfi/g' | uniq 2>&1`
|
2010-04-08 01:29:57 +00:00
|
|
|
NRET=`echo $?`
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
msg="$0: The environment variable NODE is null, pls check.\n"
|
|
|
|
echo $msg
|
2012-05-15 06:24:34 +00:00
|
|
|
logger -t xcat -p local4.err "$msg"
|
2010-04-08 01:29:57 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $RET -ne 0 ]] || [[ $NRET -ne 0 ]]; then
|
|
|
|
msg="$0: The returned value is not correct, client_ip=$client_ip, nic=$nic\n"
|
2012-05-15 06:24:34 +00:00
|
|
|
logger -t xcat -p local4.info "$msg"
|
2010-04-08 01:29:57 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -z $NIC ]; then
|
|
|
|
if [[ ! -z $CLIENT_IP ]] && [[ ! -z $SERVER_IP ]] && [[ ! -z $GATE_WAY ]]; then
|
2010-04-13 03:48:29 +00:00
|
|
|
bootlist -m normal $NIC bserver=$SERVER_IP gateway=$GATE_WAY client=$CLIENT_IP
|
2010-04-08 01:29:57 +00:00
|
|
|
else
|
2010-04-13 03:48:29 +00:00
|
|
|
bootlist -m normal $NIC
|
2010-04-08 01:29:57 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
msg="$0: The network interface NIC on the host $CLIENT_IP is not retrieved, pls check.\n"
|
|
|
|
echo $msg
|
2012-05-15 06:24:34 +00:00
|
|
|
logger -t xcat -p local4.info "$msg"
|
2010-04-08 01:29:57 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|