Changeset 2823 for trunk/locker/sbin
- Timestamp:
- Feb 23, 2017, 12:19:45 AM (8 years ago)
- Location:
- trunk/locker/sbin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/locker/sbin/rpm-master.sh
r2274 r2823 1 #!/bin/sh 1 #!/bin/bash 2 set -eu -o pipefail 2 3 3 4 export LC_ALL=C … … 8 9 9 10 echo "Cleaning up environment..." 10 rm -rf *.rpmlist*.diff rpmlist.master missing.rpms11 rm -rf ./*.rpmlist ./*.diff rpmlist.master missing.rpms 11 12 12 servers= `finger @scripts-director.mit.edu | grep "\->" | grep EDU | awk '{print $2}' | cut -d: -f1 | sort | uniq`13 servers=$(finger @scripts-director.mit.edu | grep "\->" | grep EDU | awk '{print $2}' | cut -d: -f1 | sort | uniq) 13 14 14 15 for server in $servers; do 15 16 echo "Connecting to $server..." 16 { ssh $server /mit/scripts/sbin/rpmlist.sh 2>&1 >&3 | grep -Fxv 'If you have trouble logging in, see http://scripts.mit.edu/faq/41/.'; } 3>&1 >&217 { ssh "$USER@$server" /mit/scripts/sbin/rpmlist.sh 2>&1 >&3 | { grep -Fxv 'If you have trouble logging in, see http://scripts.mit.edu/faq/41/.' || [ $? -eq 1 ]; }; } 3>&1 >&2 17 18 done 18 19 19 20 echo "Creating master package list..." 20 cat *.rpmlist | sort | uniq > rpmlist.master21 cat ./*.rpmlist | sort | uniq > rpmlist.master 21 22 22 23 echo "Comparing scripts servers to overall rpm list..." 23 24 touch missing.rpms 24 25 for server in *.rpmlist; do 25 diff -U3 $server rpmlist.master > $server.diff26 serverPretty= `basename $server .rpmlist`26 diff -U3 "$server" rpmlist.master > "$server.diff" || : 27 serverPretty=$(basename "$server" .rpmlist) 27 28 echo "Server $serverPretty is missing:" >> missing.rpms 28 grep "^+[^+]" $server.diff| cut -b 1 --complement >> missing.rpms29 grep "^+[^+]" "$server.diff" | cut -b 1 --complement >> missing.rpms 29 30 echo >> missing.rpms 30 31 done 31 32 32 if [ `egrep -c -v '(missing)|(^$)' missing.rpms` -gt 0 ]; then33 if egrep -qv '(missing)|(^$)' missing.rpms; then 33 34 echo "Sending email..." 34 cat missing.rpms | mail -s "scripts.mit.edu servers are out of sync" root@scripts.mit.edu35 mail -s "scripts.mit.edu servers are out of sync" root@scripts.mit.edu < missing.rpms 35 36 else 36 37 echo "No email needs to be sent! scripts.mit.edu is up to date." -
trunk/locker/sbin/rpmlist.sh
r2274 r2823 1 1 #!/bin/sh 2 set -eu 2 3 3 4 export LC_ALL=C 4 5 5 6 copyTo='/mit/scripts/cron_scripts/rpm-sync/' 6 packages= `mktemp --tmpdir rpmlist.XXXXXX`7 rpm -qa --queryformat '%{NAME}.%{ARCH}\n' | sort | uniq > $packages7 packages=$(mktemp --tmpdir rpmlist.XXXXXX) 8 rpm -qa --queryformat '%{NAME}.%{ARCH}\n' | sort | uniq > "$packages" 8 9 9 host= `hostname`10 host=$(hostname) 10 11 extension='.rpmlist' 11 12 file="$copyTo/$host$extension" 12 mv $packages $file13 mv "$packages" "$file"
Note: See TracChangeset
for help on using the changeset viewer.