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

Rapport unifies de mise à jour, fix #8

parent bbc612f1
......@@ -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"
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