From 545c1fd0dfa3c0f2fde947aef9a317bc7b27b002 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Wed, 3 Dec 2014 18:26:34 +0100 Subject: [PATCH] clean code --- master/etc/init.d/etherwake | 10 ++++++---- master/etc/init.d/wakeonlan | 15 ++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/master/etc/init.d/etherwake b/master/etc/init.d/etherwake index 401992e..d23bccb 100755 --- a/master/etc/init.d/etherwake +++ b/master/etc/init.d/etherwake @@ -1,5 +1,5 @@ #!/bin/sh -VER=1.3 +VER=1.4 # ============================================================================ # # Copyright (C) THALES. All rights reserved @@ -13,6 +13,8 @@ VER=1.3 # temps entre 2 wake # - V1.3: Laurent Mazet 02/05/2013 # Daemonisation +# - V1.4: Laurent Mazet & Thomas Perennou 03/12/2014 +# Legers correctifs # ============================================================================ ### BEGIN INIT INFO @@ -45,10 +47,10 @@ do_start () { n=0 while [ $NB_TRY -gt 0 ]; do - for mac in $(awk '{sub(/#.*/, "")} /trc[0-9]/ {gsub(/;/, " "); print $6}' $DHCPCONF); do - host=$(awk '{sub(/#.*/, "")} /'$mac'/ {print $2}' $DHCPCONF) + for mac in $(awk '{sub(/#.*/, "")} /trc[0-9]/ {gsub(/[;{}]/, " "); print $5}' $DHCPCONF); do + host=$(awk '{sub(/#.*/, "")} /'$mac'/ {gsub(/[{}]/, " "); print $2}' $DHCPCONF) - log_action_msg "Wake-up $host ($mac)" + log_action_msg "Wake-up $host (EtherWake $mac)" etherwake $mac n=$(expr $n + 1) diff --git a/master/etc/init.d/wakeonlan b/master/etc/init.d/wakeonlan index 2a36ed8..1c360ce 100755 --- a/master/etc/init.d/wakeonlan +++ b/master/etc/init.d/wakeonlan @@ -1,5 +1,5 @@ #!/bin/sh -VER=1.3 +VER=1.5 # ============================================================================ # # Copyright (C) THALES. All rights reserved @@ -13,6 +13,8 @@ VER=1.3 # et de broadcast # - V1.4: Laurent Mazet 09/05/2014 # Daemonisation +# - V1.5: Laurent Mazet & Thomas Perennou 03/12/2014 +# Legers correctifs # ============================================================================ ### BEGIN INIT INFO @@ -39,12 +41,11 @@ do_start () { log_action_msg "Activate Wake On Lan" - mac=$(awk '{ sub(/#.*/, "") } /trc[0-9]/ { gsub(/;/, " "); print $6}' $DHCPCONF) - - for m in $mac; do - broadcast=$(grep $m /etc/dhcp/dhcpd.conf | sed 's/.* \([0-9.]*\)\..*/\1.255/') - log_action_msg "Wake-up $broadcast ($m)" - wakeonlan -p 7 -i $broadcast $m + for mac in $(awk '{ sub(/#.*/, "") } /trc[0-9]/ { gsub(/[;{}]/, " "); print $5}' $DHCPCONF); do + broadcast=$(grep $mac $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 done } -- 2.30.2