Skip to content
Snippets Groups Projects
Verified Commit f23054ce authored by David Beniamine's avatar David Beniamine
Browse files

Rapport unifies de mise à jour, fix #8

parent bbc612f1
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
mainlog="/var/log/`basename $0`_`date +%Y%m%d-%H%M`"
getip(){ getip(){
awk '/^lease/{IP=$2} /hardware ethernet/{gsub(";","",$3);if($3 == "'$1'"){print IP}}' \ 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 | tail -n 1
...@@ -23,9 +25,14 @@ getip(){ ...@@ -23,9 +25,14 @@ getip(){
runcmd(){ runcmd(){
host=$1 host=$1
logfile=/tmp/$$-$host.log
shift shift
echo "Runnig $@ on $host" echo "Runnig $@ on $host" | tee $logfile
ssh -o StrictHostKeychecking=no root@$host $@ ssh -o StrictHostKeychecking=no root@$host $@ | tee $logfile
}
log(){
echo $@ | tee -a $mainlog
} }
# Switch to lametros repository # Switch to lametros repository
...@@ -43,19 +50,20 @@ cmd="cd /opt/primtux-eole/; export HTTPS_PROXY='http://dnsproxy:3128'; git pull; ...@@ -43,19 +50,20 @@ cmd="cd /opt/primtux-eole/; export HTTPS_PROXY='http://dnsproxy:3128'; git pull;
while read date mac name while read date mac name
do do
# Boot machine # Boot machine
log "Trying to boot $mac"
wakeonlan -i $broadcast "$mac" wakeonlan -i $broadcast "$mac"
MACS+=" $mac" MACS+=" $mac"
done < $conf_file done < $conf_file
# Wait for boot # Wait for boot
echo "" log "Wakeonlan sent, waiting"
while [ $wait_time -gt 0 ] while [ $wait_time -gt 0 ]
do 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 sleep $wait_step
wait_time=$(($wait_time - $wait_step)) wait_time=$(($wait_time - $wait_step))
done done
echo -e "\nWaiting finished" log -e "\nWaiting finished"
for mac in $MACS for mac in $MACS
do do
...@@ -65,3 +73,13 @@ do ...@@ -65,3 +73,13 @@ do
done done
# wait all pids # wait all pids
wait $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"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment