Skip to content

Instantly share code, notes, and snippets.

@foozmeat
Last active May 8, 2019 19:56
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save foozmeat/d9067f347f1c8f9cf4bf to your computer and use it in GitHub Desktop.
Save foozmeat/d9067f347f1c8f9cf4bf to your computer and use it in GitHub Desktop.
Script to run lynis and notify you if something needs attention
#!/bin/sh
#set -x
EMAIL=someone@example.com
OLDHOME=${HOME}
cd ~/lynis
. /etc/apache2/envvars
./lynis -c -Q -q --profile /etc/lynis/default.prf
HOME=${OLDHOME}
# Check to ensure we're still at 100%
grep -q 'Hardening index : \[100\]' /var/log/lynis.log
if [ $? != 0 ]; then
./lynis --check-update --no-colors | mutt -s 'lynis report' $EMAIL -a /var/log/lynis.log
fi
# notify if there's an update available
./lynis --check-update > /tmp/lynis.check
if [ $? != 0 ]; then
./lynis --check-update --no-colors | mutt -s 'lynis update available' $EMAIL
fi
rm /tmp/lynis.check
# remove the turd made by mutt
if [ -f ~/sent ]; then
rm ~/sent
fi
# End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment