From 15db1f56a5e1ba259d761fd16dc997f91e3f5827 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Wed, 3 Dec 2014 18:20:26 +0100 Subject: [PATCH] add ipmi wake service --- master/etc/init.d/ipmiwake | 69 +++++++++++++++++++ master/opt/cluster/slave/etc/default/ipmiwake | 1 + 2 files changed, 70 insertions(+) create mode 100755 master/etc/init.d/ipmiwake create mode 100644 master/opt/cluster/slave/etc/default/ipmiwake diff --git a/master/etc/init.d/ipmiwake b/master/etc/init.d/ipmiwake new file mode 100755 index 0000000..d20b9bc --- /dev/null +++ b/master/etc/init.d/ipmiwake @@ -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 index 0000000..60d1c73 --- /dev/null +++ b/master/opt/cluster/slave/etc/default/ipmiwake @@ -0,0 +1 @@ +ENABLE=no -- 2.30.2