From aa1a77f38ec5c946f83373ed76759cbc70cf17b5 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Fri, 4 Dec 2015 20:02:55 +0100 Subject: [PATCH] correct service --- master/etc/init.d/etherwake | 2 +- master/etc/init.d/ipmiwake | 4 ++-- master/etc/init.d/shutdownallblades | 3 ++- master/etc/init.d/wakeonlan | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/master/etc/init.d/etherwake b/master/etc/init.d/etherwake index 1fa7481..3e011ff 100755 --- a/master/etc/init.d/etherwake +++ b/master/etc/init.d/etherwake @@ -47,7 +47,7 @@ do_start () { n=0 while [ $NB_TRY -gt 0 ]; do - for mac in $(awk '{sub(/#.*/, "")} /trc[0-9]/ {gsub(/[;{}]/, " "); print $5}' $DHCPCONF); do + for mac in $(awk '{sub(/#.*/, "")} /host\s+trc[0-9]/ {gsub(/[;{}]/, " "); print $5}' $DHCPCONF); do host=$(awk '{sub(/#.*/, "")} /'$mac'/ {gsub(/[{}]/, " "); print $2}' $DHCPCONF) log_action_msg "Wake-up $host (EtherWake $mac)" diff --git a/master/etc/init.d/ipmiwake b/master/etc/init.d/ipmiwake index 4b1c0ca..541f363 100755 --- a/master/etc/init.d/ipmiwake +++ b/master/etc/init.d/ipmiwake @@ -35,8 +35,8 @@ do_action () { ip addr add 10.133.25.1/24 dev eth0 - for mac in $(awk '{ sub(/#.*/, "") } /trc[0-9]/ && ! /-rf/ { gsub(/[;{}]/, " "); print $5}' $DHCPCONF); do - ipmi=$(grep $mac $DHCPCONF | sed 's/.* [0-9.]*\.\([0-9][0-9]*\)[^0-9].*/10.133.25.\1/') + for mac in $(awk '{sub(/#.*/, "")} /host\s+trc[0-9]/ && ! /-rf/ { gsub(/[;{}]/, " "); print $5}' $DHCPCONF); do + ipmi=$(awk '{sub(/#.*/, "")} /'$mac'/ {print}' $DHCPCONF | sed 's/.* [0-9.]*\.\([0-9][0-9]*\)[^0-9].*/10.133.25.\1/') host=$(awk '{sub(/#.*/, "")} /'$mac'/ {gsub(/[{}]/, " "); print $2}' $DHCPCONF) log_action_msg "Wake-up $host (IPMI boot $ACTION $ipmi)" ipmipower --session-timeout=$TIMEOUT -h $ipmi -u ADMIN -p ADMIN --$ACTION & diff --git a/master/etc/init.d/shutdownallblades b/master/etc/init.d/shutdownallblades index 29cfd31..ceb1183 100755 --- a/master/etc/init.d/shutdownallblades +++ b/master/etc/init.d/shutdownallblades @@ -25,6 +25,7 @@ VER=1.3 # Description: ### END INIT INFO +DHCPCONF=/etc/dhcp/dhcpd.conf REBOOT="no" TIMEOUT=15 ENABLE="yes" @@ -59,7 +60,7 @@ do_stop () { fi # shutdown all blades - for host in $(awk '{sub(/#.*/, "")} /trc[0-9][0-9]/ && ! /-rf/ {print $2}' /etc/dhcp/dhcpd.conf); do + for host in $(awk '{sub(/#.*/, "")} /host\s+trc[0-9][0-9]/ && ! /-rf/ {print $2}' $DHCPCONF); do grep $host /etc/hosts >&/dev/null || continue ( ping -c 1 $host >&/dev/null && { log_action_msg "shutdowning ${host/_1}"; ssh root@$host service $cmd stop; } ) & done diff --git a/master/etc/init.d/wakeonlan b/master/etc/init.d/wakeonlan index d67a847..32151e9 100755 --- a/master/etc/init.d/wakeonlan +++ b/master/etc/init.d/wakeonlan @@ -41,8 +41,8 @@ do_start () { log_action_msg "Activate Wake On Lan" - for mac in $(awk '{ sub(/#.*/, "") } /trc[0-9]/ { gsub(/[;{}]/, " "); print $5}' $DHCPCONF); do - broadcast=$(grep $mac $DHCPCONF | sed 's/.* \([0-9.]*\)\..*/\1.255/') + for mac in $(awk '{sub(/#.*/, "")} /host\s+trc[0-9]/ { gsub(/[;{}]/, " "); print $5}' $DHCPCONF); do + broadcast=$(awk '{sub(/#.*/, "")} /'$mac'/ {print}' $DHCPCONF | sed 's/.* \([0-9.]*\)\..*/\1.255/') host=$(awk '{sub(/#.*/, "")} /'$mac'/ {gsub(/[{}]/, " "); print $2}' $DHCPCONF) log_action_msg "Wake-up $host (WOL $mac $broadcast)" wakeonlan -p 7 -i $broadcast $mac -- 2.30.2