#!/bin/ksh
# This script move LPAR from poweredOff frame to active one.
# Arguments are : Name of source and target frame, name of LPAR.
# RemoteRestartLPAR.sh
# Argument1 :
# Argument 2 :
# -d : DEBUG mode
#
export HOSTNAME=`hostname -s`
export DIRADMINTOOLS=/AXIS/admintools/manapp/tools
export LOGFILE=/tmp/`basename $0 .sh`.admintools.$$.log
export OS=`uname `
export LANG=en_US
export TODAY=`date +%d%m%y.%H%M%S`
export ALLARGUMENTS="$*"
export ROOTNEEDED=NO
export ACTION=NO
sortie()
{
CODE=$1
# Codes de sortie
# 0 : OK
# 1 : Erreur
# 2 : Permission
# 3-4 : Syntaxe
# 5 Fichier absent
# 6 : Pas root l executant
case "$CODE" in
"6") echo "Ce script necessite les droits root. ABANDON"
exit 6
;;
esac
exit $CODE
}
action()
{
if test "$ACTION" = "YES"
then
eval "$*"
else
echo "$HOSTNAME : $*"
fi
}
banniere()
{
if test "$DEBUG" = "YES"
then
set -x
fi
if test "$NO_BANNER" != "YES"
then
echo "$*"
fi
}
if test "`whoami`" != "root" -a "$ROOTNEEDED" = "YES"
then
sortie 6
fi
while getopts :a:defvp:ns:t:yh object
do
case "$object" in
"a") OPTIONS="$OPTIONS -a $OPTARG"
AVALUE="$OPTARG"
;;
"e") ENVIRON="$OPTARG"
;;
"n") NAME="$OPTARG"
;;
"h") OPTIONS="$OPTIONS -h"
;;
"d") DEBUG=YES
OPTIONS="$OPTIONS -d"
;;
"f") FORCE=YES
OPTIONS="$OPTIONS -f"
;;
"v") VERBOSE=YES
OPTIONS="$OPTIONS -v"
;;
"y") AUTO=YES
OPTIONS="$OPTIONS -y"
;;
"p") PARTITION=$OPTARG
;;
"s") SOURCEFRAME=$OPTARG
;;
"t") TARGETFRAME=$OPTARG
;;
*) echo "$0 : Option inconnue : $object"
echo "Options : -y=AUTO -d=DEBUG -f=FORCE -v=VERBOSE"
;;
esac
done
shift $(($OPTIND -1))
export ARGUMENTS="$*"
# ###### ##### # # # # ####### # # ####### #####
# # # # # # # # ## ## # ## # # # #
# # # # # # # # # # # # # # # # #
# # ###### # #### # # # # # ##### # # # # #####
####### # # # # # # # # # # # # # #
# # # # # # # # # # # # ## # # #
# # # # ##### ##### # # ####### # # # #####
if test "$DEBUG" = "YES"
then
set -x
fi
debug()
{
if test "$DEBUG" = "YES"
then
echo "$*"
fi
}
verbose()
{
if test "$VERBOSE" = "YES"
then
echo "$*"
fi
}
# ### # #
# # # # #
# # # # #
# # # #
####### # # #
# # # # #
# # ### # #
foncAIX()
{
if test "$DEBUG" = "YES"
then
set -x
fi
# export ENVIRONMENT="`$DIRADMINTOOLS/chassis -e`"
export CHASSIS="`$DIRADMINTOOLS/chassis -n`"
export LPARNAME="`$DIRADMINTOOLS/infoLPAR.sh -N|sed 's/ //g'`"
#export OSLEVEL="`oslevel -q 2> /dev/null`"
# Récupération de la Frame de la LPAR en argument
# Recuperation de la HMC de la LPAR
echo "Recuperation de la LPAR $PARTITION ( actuellement sur $SOURCEFRAME ) sur $TARGETFRAME"
echo " Commande à lancer depuis la HMC :"
echo " rrstartlpar -o restart -m $SOURCEFRAME -t $TARGETFRAME -p $PARTITION"
}
# ### # # # # # #
# # ## # # # # #
# # # # # # # # #
# # # # # # # #
# # # # # # # # #
# # # ## # # # #
####### ### # # ##### # #
foncLINUX()
{
if test "$DEBUG" = "YES"
then
set -x
fi
echo "Bienvenue sur LINUX"
}
#verbose "ALLARGUMENTS= $ALLARGUMENTS"
#verbose "ARGUMENTS= $ARGUMENTS"
#verbose "Options=$OPTIONS"
# # # ### # #
## ## # # # ## #
# # # # # # # # # #
# # # # # # # # #
# # ####### # # # #
# # # # # # ##
# # # # ### # #
case "$OS" in
"AIX") foncAIX
;;
"Linux") foncLINUX
;;
*) echo "Systeme inconnu : $OS"
;;
esac
debug "================================================="
debug " ===== Fichier journal : $LOGFILE ====="
debug "================================================="