From: Laurent Mazet Date: Fri, 12 Dec 2014 14:25:07 +0000 (+0100) Subject: add a script to control all blade in an IBM HS22 chassis X-Git-Tag: debian_7.5_20141215~4 X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=480e6d0205bd4d0a6c3fa55c12a0e48eb3d0e03b;p=debian6500.git add a script to control all blade in an IBM HS22 chassis --- diff --git a/master/etc/init.d/ammwake b/master/etc/init.d/ammwake new file mode 100755 index 0000000..d592e98 --- /dev/null +++ b/master/etc/init.d/ammwake @@ -0,0 +1,69 @@ +#!/bin/bash +VER=1.0 +# ============================================================================ +# +# Copyright (C) THALES. All rights reserved +# Author: Laurent Mazet +# Date : 12/12/2014 +# ============================================================================ + +### BEGIN INIT INFO +# Provides: ammwake +# Required-Start: $network waitswitches +# Required-Stop: +# Should-Start: +# Default-Start: S +# Default-Stop: +# Short-Description: Wake cluster blades (AMM command) +# Description: Boot all cluster blades by AMM power command +### END INIT INFO + +HOSTS="/etc/hosts" +ENABLE="yes" +SCRIPT=/opt/trc6500/script/set_blade_power.tcl + +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +[ -f /etc/default/ammwake ] && . /etc/default/ammwake +[ -x $SCRIPT ] || exit 1 +[ "$ENABLE" = "yes" ] || exit 0 + +. /lib/lsb/init-functions + +do_action () { + ACTION=$1 + + log_action_msg "Send AMM power $ACTION command" + + for amm in $(awk '{ sub(/#.*/, "") } /amm[0-9]/ { print $2}' $HOSTS); do + ping -c 1 $amm >&/dev/null || continue + for id in $(seq 1 14); do + [ $id -eq 1 -a "$amm" = amm00 ] && continue + + log_action_msg "Wake-up blade-$id (AMM $amm $id $ACTION)" + $SCRIPT $amm -b $id -$ACTION >&/dev/null || log_failure_msg "Can't power $ACTION blade $id on $amm" + done + done +} + +case "$1" in + -v) + echo "$(basename $0), version $VER" + ;; + start) + do_action on + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + do_action off + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac + +# vim:set tabstop=4 expandtab shiftwidth=4: