correct depends between *wake* services
[debian6500.git] / master / etc / init.d / etherwake
CommitLineData
4e802319 1#!/bin/sh
545c1fd0 2VER=1.4
4e802319 3# ============================================================================
4#
5# Copyright (C) THALES. All rights reserved
6# Author: Jean-Noel Raguenes
7# Date : 07/12/2009
8# - V1.1: Herve Petit 10/03/2010
9# reprise de la commande recuperation des @mac pour prendre
10# en compte le fait que l'interface eth1 a ete configuree
11# - V1.2: Herve Petit 04/06/2010
12# etude probleme non demarrage lames esclave par tuning temps total et
13# temps entre 2 wake
14# - V1.3: Laurent Mazet 02/05/2013
15# Daemonisation
545c1fd0
LM
16# - V1.4: Laurent Mazet & Thomas Perennou 03/12/2014
17# Legers correctifs
4e802319 18# ============================================================================
19
20### BEGIN INIT INFO
21# Provides: etherwake
40cb1de8 22# Required-Start: $network waitswitches
4e802319 23# Required-Stop:
24# Should-Start:
25# Default-Start: S
26# Default-Stop:
27# Short-Description: EW cluster blades
28# Description: Boot all cluster blades by EtherWake protocol
29### END INIT INFO
30
31DHCPCONF=/etc/dhcp/dhcpd.conf
32GROUP_SIZE=5
605d1269 33NB_TRY=2
4e802319 34ENABLE="yes"
35
36PATH=/sbin:/usr/sbin:/bin:/usr/bin
37[ -f /etc/default/etherwake ] && . /etc/default/etherwake
38[ "$ENABLE" = "yes" ] || exit 0
39
40. /lib/lsb/init-functions
41
42do_start () {
43
44 log_action_msg "Activate EtherWake"
45
605d1269 46 sleep 1
4e802319 47 n=0
48 while [ $NB_TRY -gt 0 ]; do
49
545c1fd0
LM
50 for mac in $(awk '{sub(/#.*/, "")} /trc[0-9]/ {gsub(/[;{}]/, " "); print $5}' $DHCPCONF); do
51 host=$(awk '{sub(/#.*/, "")} /'$mac'/ {gsub(/[{}]/, " "); print $2}' $DHCPCONF)
4e802319 52
545c1fd0 53 log_action_msg "Wake-up $host (EtherWake $mac)"
4e802319 54 etherwake $mac
55
56 n=$(expr $n + 1)
57 [ $(expr $n % $GROUP_SIZE) -eq 0 ] && sleep 1
58
59 done
60
61 NB_TRY=$(expr $NB_TRY - 1)
62 done
63}
64
65case "$1" in
66 -v)
67 echo "$(basename $0), version $VER"
68 ;;
69 start)
70 do_start
71 ;;
72 restart|reload|force-reload)
73 echo "Error: argument '$1' not supported" >&2
74 exit 3
75 ;;
76 stop)
77 # No-op
78 ;;
79 *)
80 echo "Usage: $0 start|stop" >&2
81 exit 3
82 ;;
83esac
84
85# vim:set tabstop=4 expandtab shiftwidth=4: