2008-01-10 01:59:16 +00:00
|
|
|
#!/bin/sh
|
2012-05-07 18:46:25 +00:00
|
|
|
|
|
|
|
# Provide serial console access to nodes
|
|
|
|
|
|
|
|
# To handle cases like running this via sudo, get the home dir properly
|
2012-04-10 02:45:38 +00:00
|
|
|
os=`uname`
|
|
|
|
if [ "$os" == "Linux" ]; then
|
|
|
|
HOME=`getent passwd $(whoami)|cut -d: -f 6`
|
|
|
|
export HOME
|
|
|
|
fi
|
2012-05-07 18:46:25 +00:00
|
|
|
if [ "$os" == "AIX" ]; then
|
|
|
|
HOME=`lsuser -a home $(whoami)|cut -d= -f 2`
|
|
|
|
export HOME
|
|
|
|
fi
|
2012-04-10 02:45:38 +00:00
|
|
|
|
2009-09-01 15:55:58 +00:00
|
|
|
if [ -z "$1" ] || [ "$1" = "-h" ]; then
|
2008-10-31 15:01:50 +00:00
|
|
|
echo "rcons - remotely accesses the serial console of a node"
|
2009-04-24 10:33:09 +00:00
|
|
|
echo "rcons <singlenode> [conserver] [-f]"
|
2010-03-09 05:45:59 +00:00
|
|
|
echo "rcons <singlenode> [conserver] [-s]"
|
2008-10-31 15:01:50 +00:00
|
|
|
echo "rcons [-h|--help|-v|--version]"
|
|
|
|
exit 0
|
|
|
|
fi
|
2009-09-01 15:55:58 +00:00
|
|
|
if [ "$1" = "-v" ]; then
|
2008-10-31 15:01:50 +00:00
|
|
|
echo "Version 2.1"
|
|
|
|
exit 0
|
|
|
|
fi
|
2009-04-24 10:33:09 +00:00
|
|
|
|
|
|
|
if [ -n "$3" ] && [ "$3" = "-f" ]; then
|
|
|
|
FORCE=-f
|
|
|
|
CONSERVER=$2
|
|
|
|
fi
|
|
|
|
|
2010-03-09 05:45:59 +00:00
|
|
|
#console spy mode
|
|
|
|
if [ -n "$3" ] && [ "$3" = "-s" ]; then
|
|
|
|
FORCE=-s
|
|
|
|
CONSERVER=$2
|
|
|
|
fi
|
|
|
|
|
2009-04-24 10:33:09 +00:00
|
|
|
if [ -n "$2" ] && [ "$2" = "-f" ]; then
|
|
|
|
FORCE=-f
|
|
|
|
fi
|
|
|
|
|
2010-03-09 05:45:59 +00:00
|
|
|
#console spy mode
|
|
|
|
if [ -n "$2" ] && [ "$2" = "-s" ]; then
|
|
|
|
FORCE=-s
|
|
|
|
fi
|
|
|
|
|
2009-11-18 06:24:36 +00:00
|
|
|
if [ -z "$CONSERVER" ]; then
|
|
|
|
CONSERVER=`nodels $1 nodehm.conserver 2>/dev/null | awk -F: '{print $2}' | tr -d ' '`
|
|
|
|
fi
|
|
|
|
|
2008-02-01 16:23:20 +00:00
|
|
|
if [ -z "$CONSERVER" ]; then
|
2008-01-10 01:59:16 +00:00
|
|
|
CONSERVER=$XCATHOST
|
|
|
|
fi
|
2008-02-01 16:23:20 +00:00
|
|
|
if [ -z "$CONSERVER" ]; then
|
2008-01-10 01:59:16 +00:00
|
|
|
CONSERVER=localhost
|
|
|
|
fi
|
2008-01-10 02:02:57 +00:00
|
|
|
#NOTE: IPv6 is not good with the below if going by IP, needs more sophisticated
|
|
|
|
#parsing
|
|
|
|
CONSERVER=`echo $CONSERVER|cut -d: -f 1`
|
2009-07-22 05:58:07 +00:00
|
|
|
|
2009-09-23 18:01:38 +00:00
|
|
|
#Detect console support of SSL, only fixup consolerc if encryption is detected
|
|
|
|
if ! console -h 2>&1 | grep "encryption not compiled" > /dev/null; then
|
2009-07-22 05:58:07 +00:00
|
|
|
if [ ! -f $HOME/.consolerc ]; then
|
|
|
|
echo 'config * {' > $HOME/.consolerc
|
|
|
|
echo " port 782;" >> $HOME/.consolerc
|
|
|
|
echo " sslenabled yes;" >> $HOME/.consolerc
|
|
|
|
echo " sslauthority $HOME/.xcat/ca.pem;" >> $HOME/.consolerc
|
|
|
|
echo " sslcredentials $HOME/.xcat/client-cred.pem;" >> $HOME/.consolerc
|
|
|
|
echo '}' >> $HOME/.consolerc
|
|
|
|
fi
|
2010-02-23 05:49:30 +00:00
|
|
|
else
|
|
|
|
# ssl is not enabled, comment out the ssl settings in .consolerc
|
|
|
|
if [ -f $HOME/.consolerc ]; then
|
|
|
|
sed -i 's/\Wssl/#ssl/1' $HOME/.consolerc
|
|
|
|
fi
|
2008-01-10 01:59:16 +00:00
|
|
|
fi
|
2009-04-24 10:33:09 +00:00
|
|
|
|
|
|
|
exec console $FORCE -M $CONSERVER $1
|