add ipmi wake service
authorLaurent Mazet <laurent.mazet@thalesgroup.com>
Wed, 3 Dec 2014 17:20:26 +0000 (18:20 +0100)
committerLaurent Mazet <laurent.mazet@thalesgroup.com>
Wed, 3 Dec 2014 17:20:26 +0000 (18:20 +0100)
master/etc/init.d/ipmiwake [new file with mode: 0755]
master/opt/cluster/slave/etc/default/ipmiwake [new file with mode: 0644]

diff --git a/master/etc/init.d/ipmiwake b/master/etc/init.d/ipmiwake
new file mode 100755 (executable)
index 0000000..d20b9bc
--- /dev/null
@@ -0,0 +1,69 @@
+#!/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:
diff --git a/master/opt/cluster/slave/etc/default/ipmiwake b/master/opt/cluster/slave/etc/default/ipmiwake
new file mode 100644 (file)
index 0000000..60d1c73
--- /dev/null
@@ -0,0 +1 @@
+ENABLE=no