correct service
[debian6500.git] / master / etc / init.d / ipmiwake
CommitLineData
15db1f56
LM
1#!/bin/sh
2VER=1.0
3# ============================================================================
4#
5# Copyright (C) THALES. All rights reserved
6# Author: Laurent Mazet & Thomas Perennou
7# Date : 03/12/2014
8# ============================================================================
9
10### BEGIN INIT INFO
11# Provides: ipmiwake
40cb1de8 12# Required-Start: $network waitswitches
15db1f56
LM
13# Required-Stop:
14# Should-Start:
15# Default-Start: S
16# Default-Stop:
17# Short-Description: IPMI wake cluster blades
18# Description: Boot all cluster blades by IPMI boot command
19### END INIT INFO
20
21DHCPCONF=/etc/dhcp/dhcpd.conf
22ENABLE="yes"
23TIMEOUT=10000
24
25PATH=/sbin:/usr/sbin:/bin:/usr/bin
26[ -f /etc/default/ipmiwake ] && . /etc/default/ipmiwake
27[ "$ENABLE" = "yes" ] || exit 0
28
29. /lib/lsb/init-functions
30
821b5805
LM
31do_action () {
32 ACTION=$1
15db1f56 33
821b5805 34 log_action_msg "Send IPMI boot $ACTION command"
15db1f56
LM
35
36 ip addr add 10.133.25.1/24 dev eth0
37
aa1a77f3
LM
38 for mac in $(awk '{sub(/#.*/, "")} /host\s+trc[0-9]/ && ! /-rf/ { gsub(/[;{}]/, " "); print $5}' $DHCPCONF); do
39 ipmi=$(awk '{sub(/#.*/, "")} /'$mac'/ {print}' $DHCPCONF | sed 's/.* [0-9.]*\.\([0-9][0-9]*\)[^0-9].*/10.133.25.\1/')
15db1f56 40 host=$(awk '{sub(/#.*/, "")} /'$mac'/ {gsub(/[{}]/, " "); print $2}' $DHCPCONF)
821b5805
LM
41 log_action_msg "Wake-up $host (IPMI boot $ACTION $ipmi)"
42 ipmipower --session-timeout=$TIMEOUT -h $ipmi -u ADMIN -p ADMIN --$ACTION &
15db1f56
LM
43 done
44
45 wait
46
47 ip addr del 10.133.25.1/24 dev eth0
48}
49
50case "$1" in
51 -v)
52 echo "$(basename $0), version $VER"
53 ;;
54 start)
821b5805 55 do_action on
15db1f56
LM
56 ;;
57 restart|reload|force-reload)
58 echo "Error: argument '$1' not supported" >&2
59 exit 3
60 ;;
61 stop)
821b5805 62 do_action off
15db1f56
LM
63 ;;
64 *)
65 echo "Usage: $0 start|stop" >&2
66 exit 3
67 ;;
68esac
69
70# vim:set tabstop=4 expandtab shiftwidth=4: