[9947] | 1 | #!/bin/sh
|
---|
| 2 | #
|
---|
| 3 | # Mega simple wrapper for batch control on nodes.
|
---|
| 4 | #
|
---|
[10619] | 5 | # Rick van der Zwet <rick@wirelessleiden.nl>
|
---|
[9947] | 6 | #
|
---|
| 7 |
|
---|
[10619] | 8 | HOSTS=${*:-"`$(dirname $0)/gformat.py list up systems fqdn`"}
|
---|
[9947] | 9 | PREFIX=${PREFIX:-'ip'}
|
---|
[10619] | 10 | CMD=${CMD:-'md5 /usr/local/etc/rc.d/lvrouted'}
|
---|
[9947] | 11 |
|
---|
[10269] | 12 | echo "# WARN: Going to run at: " $HOSTS; sleep 2
|
---|
[9947] | 13 |
|
---|
[10632] | 14 | ##
|
---|
| 15 | ## Network differences
|
---|
| 16 | ##
|
---|
| 17 | #cat << 'EOF' >/tmp/command
|
---|
| 18 | #sh -c ". /etc/rc.subr; load_rc_config "networking"; set" > /tmp/networking-env
|
---|
| 19 | #grep -e ^ifconfig -e ^ipv4 /tmp/networking-env
|
---|
| 20 | #{ grep -e ^ipv4 /tmp/networking-env | cut -d= -f2 | tr -d \' | xargs -n1 | cut -d/ -f1;
|
---|
| 21 | # grep -e ^ifconfig /tmp/networking-env | grep -v -i 'dhcp' | cut -d= -f2 | tr -d \' | cut -d' ' -f2 | cut -d'/' -f1
|
---|
| 22 | #} | sort -u > /tmp/config
|
---|
| 23 | #ifconfig -a | grep 'inet ' | cut -d' ' -f2 | sort > /tmp/current
|
---|
| 24 | #echo "# Comparing IP differences /tmp/current vs /tmp/config"
|
---|
| 25 | #diff -u /tmp/current /tmp/config
|
---|
| 26 | #EOF
|
---|
| 27 |
|
---|
| 28 | ##
|
---|
| 29 | ## Migrate SSH authorized_keys symlink to new location.
|
---|
| 30 | ##
|
---|
| 31 | #cat <<'EOF' > /tmp/command
|
---|
| 32 | #mount -uwo noatime / && unlink /root/.ssh && mkdir /root/.ssh && ln -s /etc/ssh/authorized_keys /root/.ssh/ && mount -ur
|
---|
| 33 | #EOF
|
---|
| 34 |
|
---|
| 35 | ##
|
---|
| 36 | ## View lvrouted configured flages
|
---|
| 37 | ##
|
---|
[10634] | 38 | #cat <<'EOF' > /tmp/command
|
---|
[10632] | 39 | #/usr/local/etc/rc.d/lvrouted rcvar | grep flags
|
---|
[10634] | 40 | #EOF
|
---|
[10632] | 41 |
|
---|
[10634] | 42 | ##
|
---|
| 43 | ## Restart lvrouted
|
---|
| 44 | ##
|
---|
| 45 | cat <<'EOF' > /tmp/command
|
---|
| 46 | sleep 30
|
---|
| 47 | nohup /usr/local/etc/rc.d/lvrouted restart
|
---|
| 48 | EOF
|
---|
| 49 |
|
---|
| 50 | ##
|
---|
| 51 | ## Sync lvrouted and wl-config files
|
---|
| 52 | ##
|
---|
| 53 | #cat <<'EOF' > /tmp/command
|
---|
| 54 | #mount -uwo noatime / || exit 1
|
---|
| 55 | #trap "mount -ur /; exit 1" 1 2 3 15
|
---|
| 56 | #trap "mount -ur /; exit 0" 0
|
---|
[10632] | 57 | #
|
---|
[10634] | 58 | #cp -v /tmp/wl-config /tools || exit 1
|
---|
| 59 | #cp -v /tmp/lvrouted.in /usr/local/etc/rc.d/lvrouted || exit 1
|
---|
| 60 | #cp -v /tmp/lvrouted.in /conf/base/etc/local/rc.d/lvrouted || exit 1
|
---|
[10632] | 61 | #
|
---|
[10634] | 62 | #/usr/local/etc/rc.d/lvrouted rcvar
|
---|
| 63 | #EOF
|
---|
[10632] | 64 |
|
---|
[10634] | 65 | ##
|
---|
| 66 | ## Run /tools/wl-config with random scheduler to avoid gold-rush and killing the
|
---|
| 67 | ## config generator server
|
---|
| 68 | ##
|
---|
| 69 | #cat <<'EOF' > /tmp/command
|
---|
| 70 | ##sleep `expr $$ % 120`
|
---|
| 71 | #/tools/wl-config -b
|
---|
| 72 | #EOF
|
---|
[10619] | 73 |
|
---|
[10632] | 74 |
|
---|
[10619] | 75 | # Cleanup old entries
|
---|
| 76 | rm $PREFIX-* stderr-*
|
---|
| 77 |
|
---|
[9947] | 78 | for HOST in $HOSTS; do
|
---|
[10634] | 79 | echo "# Working on $HOST"
|
---|
[10619] | 80 | stdout_file="$PREFIX-${HOST%%.}.txt"
|
---|
| 81 | stderr_file="stderr-${HOST%%.}.txt"
|
---|
| 82 | : > $stdout_file
|
---|
| 83 | : > $stderr_file
|
---|
[10632] | 84 | {
|
---|
[10634] | 85 | #scp -o ConnectTimeout=3 -o BatchMode=yes /tmp/wl-config /tmp/lvrouted.in root@$HOST:/tmp || exit 1
|
---|
[10632] | 86 | cat /tmp/command | ssh -o ConnectTimeout=3 -o BatchMode=yes root@$HOST 'cat >/tmp/command && sh /tmp/command'
|
---|
| 87 | } 1>$stdout_file 2>$stderr_file &
|
---|
[9947] | 88 | done
|
---|
| 89 |
|
---|
[10619] | 90 | echo "# Wait for all processes to complete."
|
---|
[9947] | 91 | wait
|
---|