WIP add scripts
This commit is contained in:
27
files/check_crontab.sh
Executable file
27
files/check_crontab.sh
Executable 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
|
Reference in New Issue
Block a user