bashscripts/scan_rkh.sh

27 lines
794 B
Bash
Raw Normal View History

2022-09-29 12:27:20 +02:00
#!/bin/bash
2023-07-25 17:20:02 +02:00
# variables
LOGFILE="$(hostname)_rkhunter-$(date +'%Y-%m-%d').log";
2023-07-21 10:30:04 +02:00
GOTIFY_MESSAGE="Scan init: **"`date +"%d/%m/%Y %H:%M:%S"`"** \r"
2023-07-25 17:20:02 +02:00
LOGS_RELATIVE_PATH="security/"
2022-09-29 12:27:20 +02:00
readonly TOKEN="<TOKEN_GOTIFY_APP>"
2023-07-25 17:20:02 +02:00
OUT=$(rkhunter -c -sk --rwo -l "./$LOGFILE")
2022-09-29 12:27:20 +02:00
if [ -n "$OUT" ]
then
2023-07-21 10:30:04 +02:00
issues=$(echo "$OUT" | wc -l)
# send log to logs public archive
2023-07-25 17:20:02 +02:00
LOG_URL=$(sh ./utils/logger.sh "./$LOGFILE" $LOGS_RELATIVE_PATH)
2023-07-21 10:30:04 +02:00
# delete local log
rm $LOGFILE
GOTIFY_MESSAGE="${GOTIFY_MESSAGE} Scan end: **"`date +"%d/%m/%Y %H:%M:%S"`"** \r"
GOTIFY_MESSAGE="${GOTIFY_MESSAGE} There are **$issues** security issues \r"
GOTIFY_MESSAGE="${GOTIFY_MESSAGE} [LogFile]($LOG_URL)"
sh ./utils/gotifypush.sh "RKH Scan $(hostname)" "$GOTIFY_MESSAGE" 5 $TOKEN
2022-09-29 12:27:20 +02:00
else
2023-07-21 10:30:04 +02:00
echo "[rkhunter] system clean"
2022-09-29 12:27:20 +02:00
fi