From f23054ce4344b32b1fb700ea4a10e8f4efcc092f Mon Sep 17 00:00:00 2001 From: David Beniamine <david.beniamine@tetras-libre.fr> Date: Fri, 26 Apr 2019 13:34:29 +0200 Subject: [PATCH] =?UTF-8?q?Rapport=20unifies=20de=20mise=20=C3=A0=20jour,?= =?UTF-8?q?=20fix=20#8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- registry/scripts/upgrade_all.sh | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/registry/scripts/upgrade_all.sh b/registry/scripts/upgrade_all.sh index 4da61b7..13fe9cb 100755 --- a/registry/scripts/upgrade_all.sh +++ b/registry/scripts/upgrade_all.sh @@ -16,6 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +mainlog="/var/log/`basename $0`_`date +%Y%m%d-%H%M`" + getip(){ awk '/^lease/{IP=$2} /hardware ethernet/{gsub(";","",$3);if($3 == "'$1'"){print IP}}' \ < /var/lib/dhcp/dhcpd.leases | tail -n 1 @@ -23,9 +25,14 @@ getip(){ runcmd(){ host=$1 + logfile=/tmp/$$-$host.log shift - echo "Runnig $@ on $host" - ssh -o StrictHostKeychecking=no root@$host $@ + echo "Runnig $@ on $host" | tee $logfile + ssh -o StrictHostKeychecking=no root@$host $@ | tee $logfile +} + +log(){ + echo $@ | tee -a $mainlog } # Switch to lametros repository @@ -43,19 +50,20 @@ cmd="cd /opt/primtux-eole/; export HTTPS_PROXY='http://dnsproxy:3128'; git pull; while read date mac name do # Boot machine + log "Trying to boot $mac" wakeonlan -i $broadcast "$mac" MACS+=" $mac" done < $conf_file # Wait for boot -echo "" +log "Wakeonlan sent, waiting" while [ $wait_time -gt 0 ] do - echo -ne "Waiting for boot, remaining $wait_time seconds\r" + log -ne "Waiting for boot, remaining $wait_time seconds\r" | tee $mainlog sleep $wait_step wait_time=$(($wait_time - $wait_step)) done -echo -e "\nWaiting finished" +log -e "\nWaiting finished" for mac in $MACS do @@ -65,3 +73,13 @@ do done # wait all pids wait $PIDS + +# Retrieving logs +for f in /tmp/$$-* +do + host=$(echo $f | cut -d '-' -f 2-) + log "===== Begin host $host ====" + cat $f >> $mainlog + log "===== End host $host ====" +done +log "Output written to $mainlog" -- GitLab