source: genesis/tools/batch-cmd@ 10619

Last change on this file since 10619 was 10619, checked in by rick, 13 years ago

Find differences between active IP configuration and stored IP configuration.

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/bin/sh
2#
3# Mega simple wrapper for batch control on nodes.
4#
5# Rick van der Zwet <rick@wirelessleiden.nl>
6#
7
8HOSTS=${*:-"`$(dirname $0)/gformat.py list up systems fqdn`"}
9PREFIX=${PREFIX:-'ip'}
10CMD=${CMD:-'md5 /usr/local/etc/rc.d/lvrouted'}
11
12echo "# WARN: Going to run at: " $HOSTS; sleep 2
13
14cat << 'EOF' >/tmp/command
15sh -c ". /etc/rc.subr; load_rc_config "networking"; set" > /tmp/networking-env
16grep -e ^ifconfig -e ^ipv4 /tmp/networking-env
17{ grep -e ^ipv4 /tmp/networking-env | cut -d= -f2 | tr -d \' | xargs -n1 | cut -d/ -f1;
18 grep -e ^ifconfig /tmp/networking-env | grep -v -i 'dhcp' | cut -d= -f2 | tr -d \' | cut -d' ' -f2 | cut -d'/' -f1
19} | sort -u > /tmp/current
20ifconfig -a | grep 'inet ' | cut -d' ' -f2 | sort > /tmp/config
21echo "# Comparing IP differences /tmp/current vs /tmp/config"
22sdiff /tmp/current /tmp/config
23EOF
24
25# Cleanup old entries
26rm $PREFIX-* stderr-*
27
28for HOST in $HOSTS; do
29 stdout_file="$PREFIX-${HOST%%.}.txt"
30 stderr_file="stderr-${HOST%%.}.txt"
31 : > $stdout_file
32 : > $stderr_file
33 cat /tmp/command | ssh -o ConnectTimeout=3 -o BatchMode=yes root@$HOST 'cat >/tmp/command && sh /tmp/command' 1>$stdout_file 2>$stderr_file &
34done
35
36echo "# Wait for all processes to complete."
37wait
Note: See TracBrowser for help on using the repository browser.