+#!/bin/sh
+VER=1.0
+# ============================================================================
+#
+# Copyright (C) THALES. All rights reserved
+# Author: Laurent Mazet & Thomas Perennou
+# Date : 03/12/2014
+# ============================================================================
+
+### BEGIN INIT INFO
+# Provides: ipmiwake
+# Required-Start: $network
+# Required-Stop:
+# Should-Start:
+# Default-Start: S
+# Default-Stop:
+# Short-Description: IPMI wake cluster blades
+# Description: Boot all cluster blades by IPMI boot command
+### END INIT INFO
+
+DHCPCONF=/etc/dhcp/dhcpd.conf
+ENABLE="yes"
+TIMEOUT=10000
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+[ -f /etc/default/ipmiwake ] && . /etc/default/ipmiwake
+[ "$ENABLE" = "yes" ] || exit 0
+
+. /lib/lsb/init-functions
+
+do_start () {
+
+ log_action_msg "Send IPMI boot command"
+
+ ip addr add 10.133.25.1/24 dev eth0
+
+ for mac in $(awk '{ sub(/#.*/, "") } /trc[0-9]/ && ! /-rf/ { gsub(/[;{}]/, " "); print $5}' $DHCPCONF); do
+ ipmi=$(grep $mac $DHCPCONF | sed 's/.* [0-9.]*\.\([0-9][0-9]*\)[^0-9].*/10.133.25.\1/')
+ host=$(awk '{sub(/#.*/, "")} /'$mac'/ {gsub(/[{}]/, " "); print $2}' $DHCPCONF)
+ log_action_msg "Wake-up $host (IPMI boot $ipmi)"
+ ipmipower --session-timeout=$TIMEOUT -h $ipmi -u ADMIN -p ADMIN --on &
+ done
+
+ wait
+
+ ip addr del 10.133.25.1/24 dev eth0
+}
+
+case "$1" in
+ -v)
+ echo "$(basename $0), version $VER"
+ ;;
+ start)
+ do_start
+ ;;
+ restart|reload|force-reload)
+ echo "Error: argument '$1' not supported" >&2
+ exit 3
+ ;;
+ stop)
+ # No-op
+ ;;
+ *)
+ echo "Usage: $0 start|stop" >&2
+ exit 3
+ ;;
+esac
+
+# vim:set tabstop=4 expandtab shiftwidth=4: