Unverified Commit 582cdb32 authored by David Beniamine's avatar David Beniamine
Browse files

Improved upgrade_all loging for primtux-eole/grenoble/primtux-eole#25

parent e4eec971
......@@ -46,13 +46,21 @@ wait_time=120
wait_step=5
cmd="cd /opt/primtux-eole/; export HTTPS_PROXY='http://dnsproxy:3128'; git pull; ./upgrade-session.sh $1"
declare -A HOSTS
declare -A IPTOMACS
declare -A DOWNS
while read date mac name
do
# Boot machine
log "Trying to boot $mac"
wakeonlan -i $broadcast "$mac"
MACS+=" $mac"
if [ ! -z "$date" ]
then
HOSTS[$mac]=$name
log "Trying to boot $name ($mac)"
wakeonlan -i $broadcast "$mac"
sleep 5
MACS+=" $mac"
fi
done < $conf_file
# Wait for boot
......@@ -65,10 +73,12 @@ do
done
log -e "\nWaiting finished"
# Running command
for mac in $MACS
do
for ip in $(getips $mac)
do
IPTOMACS[$ip]=$mac
runcmd $ip $cmd &
PIDS="$PIDS $!"
done
......@@ -82,9 +92,27 @@ done
# Retrieving logs
for f in /tmp/$$-*
do
host=$(echo $f | cut -d '-' -f 2-)
log "===== Begin host $host ===="
ip=$(echo $f | cut -d '-' -f 2- | sed 's/\.log$//')
mac=${IPTOMACS[$ip]}
name=${HOSTS[$mac]}
log "===== Begin host $name ($mac - $ip) ===="
cat $f >> $mainlog
log "===== End host $host ===="
log "===== End host $name ===="
if [ $(wc -l $f | awk '{print $1}') -gt 0 ]
then
DOWNS[$mac]=$name
fi
done
# Listing down hosts
if [ ${#DOWNS[@]} -eq 0 ]
then
log "All ${#HOSTS[@]} hosts answered"
else
log "On a total of ${#HOSTS[@]} hosts, ${#DOWNS[@]} are still down:"
for mac in ${!DOWNS[@]}
do
log -e "\t* ${DOWNS[$mac]} ($mac)"
done
fi
log "Output written to $mainlog"
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