source: trunk/locker/sbin/rpm-master.sh

Last change on this file was 2823, checked in by andersk, 7 years ago
rpm-master.sh, rpmlist.sh: Improve shell hygiene
  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#!/bin/bash
2set -eu -o pipefail
3
4export LC_ALL=C
5
6echo "Entering correct directory..."
7mkdir -p /mit/scripts/cron_scripts/rpm-sync/
8cd /mit/scripts/cron_scripts/rpm-sync/
9
10echo "Cleaning up environment..."
11rm -rf ./*.rpmlist ./*.diff rpmlist.master missing.rpms
12
13servers=$(finger @scripts-director.mit.edu | grep "\->" | grep EDU | awk '{print $2}' | cut -d: -f1 | sort | uniq)
14
15for 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
18done
19
20echo "Creating master package list..."
21cat ./*.rpmlist | sort | uniq > rpmlist.master
22
23echo "Comparing scripts servers to overall rpm list..."
24touch missing.rpms
25for 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
31done
32
33if 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
36else
37    echo "No email needs to be sent! scripts.mit.edu is up to date."
38fi
Note: See TracBrowser for help on using the repository browser.