correct depends between *wake* services
[debian6500.git] / master / etc / init.d / etherwake
1 #!/bin/sh
2 VER=1.4
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
16 # - V1.4: Laurent Mazet & Thomas Perennou 03/12/2014
17 # Legers correctifs
18 # ============================================================================
19
20 ### BEGIN INIT INFO
21 # Provides: etherwake
22 # Required-Start: $network waitswitches
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
31 DHCPCONF=/etc/dhcp/dhcpd.conf
32 GROUP_SIZE=5
33 NB_TRY=2
34 ENABLE="yes"
35
36 PATH=/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
42 do_start () {
43
44 log_action_msg "Activate EtherWake"
45
46 sleep 1
47 n=0
48 while [ $NB_TRY -gt 0 ]; do
49
50 for mac in $(awk '{sub(/#.*/, "")} /trc[0-9]/ {gsub(/[;{}]/, " "); print $5}' $DHCPCONF); do
51 host=$(awk '{sub(/#.*/, "")} /'$mac'/ {gsub(/[{}]/, " "); print $2}' $DHCPCONF)
52
53 log_action_msg "Wake-up $host (EtherWake $mac)"
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
65 case "$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 ;;
83 esac
84
85 # vim:set tabstop=4 expandtab shiftwidth=4: