Created
May 1, 2021 22:35
-
-
Save un1xman/39abb7118123f3fd3920cff979618344 to your computer and use it in GitHub Desktop.
Aide Automation for LInux Servers
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
#!/bin/bash | |
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" | |
change_var=$(/usr/sbin/aide --check | tee -a "$SCRIPT_DIR"/temp.log | grep "differences between") | |
current_date=$( date +%Y%m%d) | |
if [ "$change_var" == "" ] | |
then | |
echo "everythink ok" | |
else | |
echo -e "\e[31m ================================================================================ \e[0m" >> "$SCRIPT_DIR"/report-"$current_date".log | |
/usr/sbin/aide --check >> "$SCRIPT_DIR"/report-"$current_date".log | |
/usr/sbin/aide --update 2>&1 >> /dev/null | |
mv /var/lib/aide/aide.db.gz /var/lib/aide/aide.db."$current_date".gz | |
mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz | |
echo -e "\e[31m ================================================================================ \e[0m" >> "$SCRIPT_DIR"/report-"$current_date".log | |
cat $SCRIPT_DIR/temp.log | grep "added:" | awk '{print $2}' | while read add_i | |
do | |
echo "Yaradilan file\'lar: $add_i" >> "$SCRIPT_DIR"/mail.log | |
done | |
cat $SCRIPT_DIR/temp.log | grep "removed:" | awk '{print $2}' | while read remove_i | |
do | |
echo "Silinen file\'lar: $remove_i" >> "$SCRIPT_DIR"/mail.log | |
done | |
cat $SCRIPT_DIR/temp.log | grep "changed:" | awk '{print $2}' | while read changed_i | |
do | |
echo "Deyishilen file\'lar: $changed_i" >> "$SCRIPT_DIR"/mail.log | |
done | |
cat "$SCRIPT_DIR"/mail.log | |
#cat "$SCRIPT_DIR"/mail.log | mailx -v -s "DIQQET $hostname SERVERINDE SYSTEM FILE'DA DEYISHIKLIK VAR" -S smtp=smtp://smtp-adres -S from="no-reply@gmail.com" nihadbekir@gmail.com | |
fi | |
rm -rf "$SCRIPT_DIR"/temp.log | |
rm -rf "$SCRIPT_DIR"/mail.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment