+#!/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: