Created
May 30, 2019 03:06
-
-
Save bitwombat/efb9ce8ada50b92fd0582e8533de9de7 to your computer and use it in GitHub Desktop.
Package verification script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Use debsums to check for any altered binaries | |
# | |
# To recreate the baseline file, simply rm it | |
cd /root/verify || exit | |
TERMINAL= | |
if [[ "$TERM" =~ ^xterm ]]; then | |
TERMINAL=y | |
fi | |
# First, take a current verify snapshot, | |
# | |
[ $TERMINAL ] && echo "Looking at MD5 sum for package files" | |
debsums | grep FAILED &> verify.current.txt | |
# Now, see if we need to make that snapshot the baseline. | |
if [ ! -e verify.baseline.txt ]; then | |
[ $TERMINAL ] && echo "No verify.baseline.txt... making one." | |
mv verify.current.txt verify.baseline.txt | |
else | |
# Compare current with baseline. | |
# Capture STDOUT so there's no email when run via cron | |
diffs=$(diff verify.current.txt verify.baseline.txt) | |
if [ "$diffs" ]; then | |
SUBJECT="FAILURE" | |
else | |
SUBJECT="ran" | |
fi | |
if [ ! -z "$diffs" -o "$(date +"%d")" == "13" ]; then | |
[ $TERMINAL ] && echo "Sending mail" | |
/usr/sbin/sendmail gbell2@localhost <<MAILHEADER | |
From [email protected] $(date) | |
Return-Path: <[email protected]> | |
From: "Verify Czar" <[email protected]> | |
To: "Greg Bell" <gbell2@localhost> | |
Subject: Verification $SUBJECT | |
Date: $(date) | |
Status: | |
$diffs | |
MAILHEADER | |
/usr/sbin/sendmail -q | |
fi | |
fi | |
[ $TERMINAL ] && echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment