WIP add scripts

This commit is contained in:
Tanguy MAZE
2018-12-13 18:51:03 +01:00
parent 2fd6ee2186
commit 2e94aefbc0
4 changed files with 58 additions and 2 deletions

27
files/check_crontab.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
cron=/etc/crontab
md5old=/etc/crontab_save
log=/var/log/check_crontab.log
printf "##### %s #####\n" "$(date)" >>$log
if [ ! -f $md5old ]
then
printf "Error: %s don't exist\nCreating %s ...\n" "$md5old" "$md5old" >>$log
md5sum $cron >$md5old
exit 1
fi
if [ ! -s $md5old ]
then
printf "Error: %s is empty\nadding md5 hash to %s ...\n" "$md5old" "$md5old" >>$log
md5sum $cron >$md5old
exit 1
fi
if [ ! $(md5sum -c $md5old 2>/dev/null | grep $cron | cut -d' ' -f2) = "OK" ]
then
printf "Error: %s modified\nsending mail ...\n" >>$log
echo "crontab has changed T_T" | mail -s "!!! PANIC !!! PANIC !!!! PANIC !!!" root
else
printf "file OK\n" >>$log
fi