@@ -3,6 +3,8 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
3
3
export LMDCRON=1
4
4
inspath=' /usr/local/maldetect'
5
5
intcnf=" $inspath /internals/internals.conf"
6
+ CRON_LOCKDIR=/var/lock/subsys
7
+ CRON_LOCKFILE=${CRON_LOCKDIR} /maldet_daily_cron
6
8
7
9
if [ -f " $intcnf " ]; then
8
10
source $intcnf
@@ -38,6 +40,10 @@ if [ -z "$cron_prune_days" ]; then
38
40
cron_prune_days=21
39
41
fi
40
42
43
+ if [ -z " $cron_lockfile_days " ]; then
44
+ cron_lockfile_days=3
45
+ fi
46
+
41
47
if [ " $find " ]; then
42
48
# prune any quarantine/session/tmp data older than 7 days
43
49
tmpdirs=" $tmpdir $varlibpath /sess $varlibpath /quarantine $varlibpath /pub"
@@ -46,6 +52,7 @@ if [ "$find" ]; then
46
52
$find $dir -type f -mtime +${cron_prune_days} -print0 | xargs -0 rm -f >> /dev/null 2>&1
47
53
fi
48
54
done
55
+ $find ${CRON_LOCKFILE} -type f -mtime +${cron_lockfile_days} -print0 2> /dev/null | xargs -0 rm -f >> /dev/null 2>&1
49
56
fi
50
57
51
58
if [ " $autoupdate_version " == " 1" ] || [ " $autoupdate_signatures " == " 1" ]; then
67
74
if [ " $( ps -A --user root -o " cmd" | grep -E maldetect | grep -E inotifywait) " ]; then
68
75
$inspath /maldet --monitor-report >> /dev/null 2>&1
69
76
elif [ " $cron_daily_scan " == " 1" ]; then
77
+ (
78
+ pid=$( exec sh -c ' echo "$PPID"' ) ;
79
+ if ! (set -o noclobber; echo " $pid " > " ${CRON_LOCKFILE} " ) 2> /dev/null; then
80
+ exit
81
+ fi
82
+
83
+ trap ' rm -f "${CRON_LOCKFILE}"; exit $?' INT TERM EXIT
84
+
70
85
if [ -d " /home/virtual" ] && [ -d " /usr/lib/opcenter" ]; then
71
86
# ensim
72
- $inspath /maldet -b - r /home/virtual/? /fst/var/www/html/,/home/virtual/? /fst/home/? /public_html/ $scan_days >> /dev/null 2>&1
87
+ $inspath /maldet -r /home/virtual/? /fst/var/www/html/,/home/virtual/? /fst/home/? /public_html/ $scan_days >> /dev/null 2>&1
73
88
elif [ -d " /etc/psa" ] && [ -d " /var/lib/psa" ]; then
74
89
# psa
75
- $inspath /maldet -b - r /var/www/vhosts/? / $scan_days >> /dev/null 2>&1
90
+ $inspath /maldet -r /var/www/vhosts/? / $scan_days >> /dev/null 2>&1
76
91
elif [ -d " /usr/local/directadmin" ]; then
77
92
# DirectAdmin
78
- $inspath /maldet -b - r /home? /? /domains/? /public_html/,/var/www/html/? / $scan_days >> /dev/null 2>&1
93
+ $inspath /maldet -r /home? /? /domains/? /public_html/,/var/www/html/? / $scan_days >> /dev/null 2>&1
79
94
elif [ -d " /var/www/clients" ]; then
80
95
# ISPConfig
81
- $inspath /maldet -b - r /var/www/clients/? /web? /web,/var/www/clients/? /web? /subdomains,/var/www $scan_days >> /dev/null 2>&1
96
+ $inspath /maldet -r /var/www/clients/? /web? /web,/var/www/clients/? /web? /subdomains,/var/www $scan_days >> /dev/null 2>&1
82
97
elif [ -d " /etc/webmin/virtual-server" ]; then
83
98
# Virtualmin
84
- $inspath /maldet -b - r /home/? /public_html/,/home/? /domains/? /public_html/ $scan_days >> /dev/null 2>&1
99
+ $inspath /maldet -r /home/? /public_html/,/home/? /domains/? /public_html/ $scan_days >> /dev/null 2>&1
85
100
elif [ -d " /usr/local/ispmgr" ] || [ -d " /usr/local/mgr5" ]; then
86
101
# ISPmanager
87
- $inspath /maldet -b - r /var/www/? /data/,/home/? /data/ $scan_days >> /dev/null 2>&1
102
+ $inspath /maldet -r /var/www/? /data/,/home/? /data/ $scan_days >> /dev/null 2>&1
88
103
elif [ -d " /var/customers/webs" ]; then
89
104
# froxlor
90
- $inspath /maldet -b - r /var/customers/webs/ $scan_days >> /dev/null 2>&1
105
+ $inspath /maldet -r /var/customers/webs/ $scan_days >> /dev/null 2>&1
91
106
elif [ -d " /usr/local/vesta" ]; then
92
107
# VestaCP
93
- $inspath /maldet -b - r /home/? /web/? /public_html/,/home/? /web/? /public_shtml/,/home/? /tmp/,/home/? /web/? /private/ $scan_days >> /dev/null 2>&1
108
+ $inspath /maldet -r /home/? /web/? /public_html/,/home/? /web/? /public_shtml/,/home/? /tmp/,/home/? /web/? /private/ $scan_days >> /dev/null 2>&1
94
109
elif [ -d " /usr/share/dtc" ]; then
95
110
# DTC
96
111
if [ -f /var/lib/dtc/saved_install_config ]; then
97
112
. /var/lib/dtc/saved_install_config
98
113
fi
99
- $inspath /maldet -b - r ${conf_hosting_path:-/ var/ www/ sites} /? /? /subdomains/? /html/ $scan_days >> /dev/null 2>&1
114
+ $inspath /maldet -r ${conf_hosting_path:-/ var/ www/ sites} /? /? /subdomains/? /html/ $scan_days >> /dev/null 2>&1
100
115
else
101
116
# cpanel, interworx and other standard home/user/public_html setups
102
- $inspath /maldet -b - r /home? /? /public_html/,/var/www/html/,/usr/local/apache/htdocs/ $scan_days >> /dev/null 2>&1
117
+ $inspath /maldet -r /home? /? /public_html/,/var/www/html/,/usr/local/apache/htdocs/ $scan_days >> /dev/null 2>&1
103
118
fi
119
+
120
+ rm -f " ${CRON_LOCKFILE} "
121
+ trap - INT TERM EXIT
122
+ ) &
104
123
fi
105
124
106
125
if [ -f " $cron_custom_exec " ]; then
0 commit comments