|
Last change
on this file since 10619 was 10619, checked in by rick, 14 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 |
|
|---|
| 8 | HOSTS=${*:-"`$(dirname $0)/gformat.py list up systems fqdn`"}
|
|---|
| 9 | PREFIX=${PREFIX:-'ip'}
|
|---|
| 10 | CMD=${CMD:-'md5 /usr/local/etc/rc.d/lvrouted'}
|
|---|
| 11 |
|
|---|
| 12 | echo "# WARN: Going to run at: " $HOSTS; sleep 2
|
|---|
| 13 |
|
|---|
| 14 | cat << 'EOF' >/tmp/command
|
|---|
| 15 | sh -c ". /etc/rc.subr; load_rc_config "networking"; set" > /tmp/networking-env
|
|---|
| 16 | grep -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
|
|---|
| 20 | ifconfig -a | grep 'inet ' | cut -d' ' -f2 | sort > /tmp/config
|
|---|
| 21 | echo "# Comparing IP differences /tmp/current vs /tmp/config"
|
|---|
| 22 | sdiff /tmp/current /tmp/config
|
|---|
| 23 | EOF
|
|---|
| 24 |
|
|---|
| 25 | # Cleanup old entries
|
|---|
| 26 | rm $PREFIX-* stderr-*
|
|---|
| 27 |
|
|---|
| 28 | for 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 &
|
|---|
| 34 | done
|
|---|
| 35 |
|
|---|
| 36 | echo "# Wait for all processes to complete."
|
|---|
| 37 | wait
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.