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

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