#!/bin/bash
#author:1209233066@qq.com
#function:md5检测文件内容变动
source /etc/init.d/functions
timestamp=$(date +%F)
finger(){
file=(
/etc/passwd
/etc/shadow
/etc/sudoers
/etc/rc.local
/etc/rc.d/rc.local
$(ls /var/spool/cron/*)
)
if [ -f "md5_${timestamp}" ];then
rm -f md5_${timestamp}
fi
for i in "${file[@]}";do md5sum $i >>md5_${timestamp} ;done
}
check_finger(){
md5sum -c md5_${timestamp} &>/dev/null
if [ $? -eq 0 ];then
action "文件没用改动" /bin/true
else
action "" /bin/false
fi
}
declare -A main
main[‘finger‘]=finger
main[‘check‘]=check_finger
${main[$1]}
原文:https://www.cnblogs.com/wangend/p/14732693.html