Import from Clearcase LIV_TRC6500_V2.2.3
[debian6500.git] / install / cluster / master / etc / init.d / etherwake
1 #!/bin/sh
2 VER=1.3
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 # ============================================================================
17
18 ### BEGIN INIT INFO
19 # Provides: etherwake
20 # Required-Start: $network
21 # Required-Stop:
22 # Should-Start:
23 # Default-Start: S
24 # Default-Stop:
25 # Short-Description: EW cluster blades
26 # Description: Boot all cluster blades by EtherWake protocol
27 ### END INIT INFO
28
29 DHCPCONF=/etc/dhcp/dhcpd.conf
30 GROUP_SIZE=5
31 NB_TRY=1
32 ENABLE="yes"
33
34 PATH=/sbin:/usr/sbin:/bin:/usr/bin
35 [ -f /etc/default/etherwake ] && . /etc/default/etherwake
36 [ "$ENABLE" = "yes" ] || exit 0
37
38 . /lib/lsb/init-functions
39
40 do_start () {
41
42 log_action_msg "Activate EtherWake"
43
44 n=0
45 while [ $NB_TRY -gt 0 ]; do
46
47 for mac in $(awk '{sub(/#.*/, "")} /trc[0-9]/ && /-rf/ {gsub(/;/, " "); print $6}' $DHCPCONF); do
48 host=$(awk '{sub(/#.*/, "")} /'$mac'/ {print $2}' $DHCPCONF)
49
50 log_action_msg "Wake-up $host ($mac)"
51 etherwake $mac
52
53 n=$(expr $n + 1)
54 [ $(expr $n % $GROUP_SIZE) -eq 0 ] && sleep 1
55
56 done
57
58 NB_TRY=$(expr $NB_TRY - 1)
59 done
60 }
61
62 case "$1" in
63 -v)
64 echo "$(basename $0), version $VER"
65 ;;
66 start)
67 do_start
68 ;;
69 restart|reload|force-reload)
70 echo "Error: argument '$1' not supported" >&2
71 exit 3
72 ;;
73 stop)
74 # No-op
75 ;;
76 *)
77 echo "Usage: $0 start|stop" >&2
78 exit 3
79 ;;
80 esac
81
82 # vim:set tabstop=4 expandtab shiftwidth=4: