Last change
on this file since 2842 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
|
Line | |
---|
1 | #!/bin/bash |
---|
2 | set -eu -o pipefail |
---|
3 | |
---|
4 | export LC_ALL=C |
---|
5 | |
---|
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..." |
---|
11 | rm -rf ./*.rpmlist ./*.diff rpmlist.master missing.rpms |
---|
12 | |
---|
13 | servers=$(finger @scripts-director.mit.edu | grep "\->" | grep EDU | awk '{print $2}' | cut -d: -f1 | sort | uniq) |
---|
14 | |
---|
15 | for server in $servers; do |
---|
16 | echo "Connecting to $server..." |
---|
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 |
---|
18 | done |
---|
19 | |
---|
20 | echo "Creating master package list..." |
---|
21 | cat ./*.rpmlist | sort | uniq > rpmlist.master |
---|
22 | |
---|
23 | echo "Comparing scripts servers to overall rpm list..." |
---|
24 | touch missing.rpms |
---|
25 | for server in *.rpmlist; do |
---|
26 | diff -U3 "$server" rpmlist.master > "$server.diff" || : |
---|
27 | serverPretty=$(basename "$server" .rpmlist) |
---|
28 | echo "Server $serverPretty is missing:" >> missing.rpms |
---|
29 | grep "^+[^+]" "$server.diff" | cut -b 1 --complement >> missing.rpms |
---|
30 | echo >> missing.rpms |
---|
31 | done |
---|
32 | |
---|
33 | if egrep -qv '(missing)|(^$)' missing.rpms; then |
---|
34 | echo "Sending email..." |
---|
35 | mail -s "scripts.mit.edu servers are out of sync" root@scripts.mit.edu < missing.rpms |
---|
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.