Last active
July 6, 2021 07:51
-
-
Save heywoodlh/a0ad5bb81ea9ee896b2a1e5d5f077cfd to your computer and use it in GitHub Desktop.
Post all Lynis warnings and suggestions to slack as a snippet
This file contains 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
#!/usr/bin/env bash | |
if [[ "$1" == '' ]] || [[ "$1" == '--help' ]] | |
then | |
echo "$0 [channel id] [slack token]" | |
exit 0 | |
fi | |
SLACK_CHANNEL_ID="$1" | |
SLACK_TOKEN="$2" | |
SLACK_ICON=':slack:' | |
MY_HOSTNAME="$(cat /etc/hostname)" | |
OUTFILE='/tmp/lynis-audit.txt' | |
lynis audit system --cronjob | grep -Pzo '.*Warnings(.*\n)*' > "$OUTFILE" | |
LYNIS_WARNINGS="$(cat $OUTFILE)" | |
curl -F "content=$LYNIS_WARNINGS" -F "initial_comment=lynis report for $MY_HOSTNAME" -F channels="$SLACK_CHANNEL_ID" -F token="$SLACK_TOKEN" https://slack.com/api/files.upload | |
rm "$OUTFILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment