Commit | Line | Data |
---|---|---|
480e6d02 LM |
1 | #!/bin/bash |
2 | VER=1.0 | |
3 | # ============================================================================ | |
4 | # | |
5 | # Copyright (C) THALES. All rights reserved | |
6 | # Author: Laurent Mazet | |
7 | # Date : 12/12/2014 | |
8 | # ============================================================================ | |
9 | ||
10 | ### BEGIN INIT INFO | |
11 | # Provides: ammwake | |
12 | # Required-Start: $network waitswitches | |
13 | # Required-Stop: | |
14 | # Should-Start: | |
15 | # Default-Start: S | |
16 | # Default-Stop: | |
17 | # Short-Description: Wake cluster blades (AMM command) | |
18 | # Description: Boot all cluster blades by AMM power command | |
19 | ### END INIT INFO | |
20 | ||
21 | HOSTS="/etc/hosts" | |
22 | ENABLE="yes" | |
23 | SCRIPT=/opt/trc6500/script/set_blade_power.tcl | |
24 | ||
25 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
26 | ||
27 | [ -f /etc/default/ammwake ] && . /etc/default/ammwake | |
28 | [ -x $SCRIPT ] || exit 1 | |
29 | [ "$ENABLE" = "yes" ] || exit 0 | |
30 | ||
31 | . /lib/lsb/init-functions | |
32 | ||
33 | do_action () { | |
34 | ACTION=$1 | |
35 | ||
36 | log_action_msg "Send AMM power $ACTION command" | |
37 | ||
38 | for amm in $(awk '{ sub(/#.*/, "") } /amm[0-9]/ { print $2}' $HOSTS); do | |
39 | ping -c 1 $amm >&/dev/null || continue | |
40 | for id in $(seq 1 14); do | |
41 | [ $id -eq 1 -a "$amm" = amm00 ] && continue | |
42 | ||
43 | log_action_msg "Wake-up blade-$id (AMM $amm $id $ACTION)" | |
44 | $SCRIPT $amm -b $id -$ACTION >&/dev/null || log_failure_msg "Can't power $ACTION blade $id on $amm" | |
45 | done | |
46 | done | |
47 | } | |
48 | ||
49 | case "$1" in | |
50 | -v) | |
51 | echo "$(basename $0), version $VER" | |
52 | ;; | |
53 | start) | |
54 | do_action on | |
55 | ;; | |
56 | restart|reload|force-reload) | |
57 | echo "Error: argument '$1' not supported" >&2 | |
58 | exit 3 | |
59 | ;; | |
60 | stop) | |
61 | do_action off | |
62 | ;; | |
63 | *) | |
64 | echo "Usage: $0 start|stop" >&2 | |
65 | exit 3 | |
66 | ;; | |
67 | esac | |
68 | ||
69 | # vim:set tabstop=4 expandtab shiftwidth=4: |