correct depends between *wake* services
[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
31do_start () {
32
33 log_action_msg "Send IPMI boot command"
34
35 ip addr add 10.133.25.1/24 dev eth0
36
37 for mac in $(awk '{ sub(/#.*/, "") } /trc[0-9]/ && ! /-rf/ { gsub(/[;{}]/, " "); print $5}' $DHCPCONF); do
38 ipmi=$(grep $mac $DHCPCONF | sed 's/.* [0-9.]*\.\([0-9][0-9]*\)[^0-9].*/10.133.25.\1/')
39 host=$(awk '{sub(/#.*/, "")} /'$mac'/ {gsub(/[{}]/, " "); print $2}' $DHCPCONF)
40 log_action_msg "Wake-up $host (IPMI boot $ipmi)"
41 ipmipower --session-timeout=$TIMEOUT -h $ipmi -u ADMIN -p ADMIN --on &
42 done
43
44 wait
45
46 ip addr del 10.133.25.1/24 dev eth0
47}
48
49case "$1" in
50 -v)
51 echo "$(basename $0), version $VER"
52 ;;
53 start)
54 do_start
55 ;;
56 restart|reload|force-reload)
57 echo "Error: argument '$1' not supported" >&2
58 exit 3
59 ;;
60 stop)
61 # No-op
62 ;;
63 *)
64 echo "Usage: $0 start|stop" >&2
65 exit 3
66 ;;
67esac
68
69# vim:set tabstop=4 expandtab shiftwidth=4: