Last change
on this file since 2829 was
2823,
checked in by andersk, 8 years ago
|
rpm-master.sh, rpmlist.sh: Improve shell hygiene
|
-
Property svn:executable set to
*
|
File size:
1.3 KB
|
Rev | Line | |
---|
[2823] | 1 | #!/bin/bash |
---|
| 2 | set -eu -o pipefail |
---|
[1639] | 3 | |
---|
[2274] | 4 | export LC_ALL=C |
---|
| 5 | |
---|
[1639] | 6 | echo "Entering correct directory..." |
---|
| 7 | mkdir -p /mit/scripts/cron_scripts/rpm-sync/ |
---|
| 8 | cd /mit/scripts/cron_scripts/rpm-sync/ |
---|
| 9 | |
---|
| 10 | echo "Cleaning up environment..." |
---|
[2823] | 11 | rm -rf ./*.rpmlist ./*.diff rpmlist.master missing.rpms |
---|
[1639] | 12 | |
---|
[2823] | 13 | servers=$(finger @scripts-director.mit.edu | grep "\->" | grep EDU | awk '{print $2}' | cut -d: -f1 | sort | uniq) |
---|
[1639] | 14 | |
---|
| 15 | for server in $servers; do |
---|
| 16 | echo "Connecting to $server..." |
---|
[2823] | 17 | { 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 |
---|
[1639] | 18 | done |
---|
| 19 | |
---|
| 20 | echo "Creating master package list..." |
---|
[2823] | 21 | cat ./*.rpmlist | sort | uniq > rpmlist.master |
---|
[1639] | 22 | |
---|
| 23 | echo "Comparing scripts servers to overall rpm list..." |
---|
| 24 | touch missing.rpms |
---|
| 25 | for server in *.rpmlist; do |
---|
[2823] | 26 | diff -U3 "$server" rpmlist.master > "$server.diff" || : |
---|
| 27 | serverPretty=$(basename "$server" .rpmlist) |
---|
[1639] | 28 | echo "Server $serverPretty is missing:" >> missing.rpms |
---|
[2823] | 29 | grep "^+[^+]" "$server.diff" | cut -b 1 --complement >> missing.rpms |
---|
[1639] | 30 | echo >> missing.rpms |
---|
| 31 | done |
---|
| 32 | |
---|
[2823] | 33 | if egrep -qv '(missing)|(^$)' missing.rpms; then |
---|
[1639] | 34 | echo "Sending email..." |
---|
[2823] | 35 | mail -s "scripts.mit.edu servers are out of sync" root@scripts.mit.edu < missing.rpms |
---|
[1639] | 36 | else |
---|
| 37 | echo "No email needs to be sent! scripts.mit.edu is up to date." |
---|
| 38 | fi |
---|
Note: See
TracBrowser
for help on using the repository browser.