Unverified Commit e4eec971 authored by David Beniamine's avatar David Beniamine
Browse files

Try all ip associated to a mac in DHCP lease

parent f23054ce
......@@ -18,9 +18,9 @@
mainlog="/var/log/`basename $0`_`date +%Y%m%d-%H%M`"
getip(){
getips(){
awk '/^lease/{IP=$2} /hardware ethernet/{gsub(";","",$3);if($3 == "'$1'"){print IP}}' \
< /var/lib/dhcp/dhcpd.leases | tail -n 1
< /var/lib/dhcp/dhcpd.leases | sort -u
}
runcmd(){
......@@ -59,7 +59,7 @@ done < $conf_file
log "Wakeonlan sent, waiting"
while [ $wait_time -gt 0 ]
do
log -ne "Waiting for boot, remaining $wait_time seconds\r" | tee $mainlog
log -ne "Waiting for boot, remaining $wait_time seconds\r"
sleep $wait_step
wait_time=$(($wait_time - $wait_step))
done
......@@ -67,12 +67,17 @@ log -e "\nWaiting finished"
for mac in $MACS
do
ip=$(getip $mac)
runcmd $ip $cmd &
PIDS="$PIDS $!"
for ip in $(getips $mac)
do
runcmd $ip $cmd &
PIDS="$PIDS $!"
done
done
# wait all pids
wait $PIDS
for pid in $PIDS
do
wait $pid
done
# Retrieving logs
for f in /tmp/$$-*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment