Skip to content

Commit

Permalink
Adjust so using maldet custom.cron
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul authored and Paul committed Jun 1, 2020
1 parent 19612c5 commit f0f3fdf
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
12 changes: 11 additions & 1 deletion install
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/local/cpanel/3rdparty/bin/perl

use Cpanel::Version ();
use Config::Tiny;

if ( $Cpanel::Version::MAJORVERSION < 11.78 ) {
print "This addon requires 11.78 or later.\n";
Expand Down Expand Up @@ -35,7 +36,7 @@ mkdir( "/usr/local/cpanel/whostmgr/docroot/templates/maldet/", 0700 );

install( "-o", "root", "-g", "wheel", "-m" . "0700", "src/cgi/index.cgi", "/usr/local/cpanel/whostmgr/docroot/cgi/addons/maldet/index.cgi" );
install( "-o", "root", "-g", "wheel", "-m" . "0600", "version.txt", "/usr/local/cpanel/whostmgr/docroot/cgi/addons/maldet/version.txt" );
install( "-o", "root", "-g", "wheel", "-m" . "0755", "src/cron/daily", "/etc/cron.daily/cp-maldet" );
install( "-o", "root", "-g", "wheel", "-m" . "0755", "src/cron/custom.cron", "/usr/local/cpanel/whostmgr/docroot/cgi/addons/maldet/custom.cron");

install( "-o", "root", "-g", "wheel", "-m" . "0400", "src/templates/maldet.tmpl", "/usr/local/cpanel/whostmgr/docroot/templates/maldet/index.tmpl" );
install( "-o", "root", "-g", "wheel", "-m" . "04600", "src/templates/update.tmpl", "/usr/local/cpanel/whostmgr/docroot/templates/maldet/update.tmpl" );
Expand Down Expand Up @@ -63,6 +64,15 @@ print "cPanel Linux Malware Detect installed into WHM.\n";

system "/usr/local/cpanel/scripts/install_plugin", "appconfig/maldet.tar.gz";


my $config = Config::Tiny->new;
my $config_file = "/usr/local/maldetect/conf.maldet.cron";
$config = Config::Tiny->read( $config_file );
if (!defined $config->{_}->{'cron_custom_exec'}) {
$config->{_}->{'cron_custom_exec'} = '/usr/local/cpanel/whostmgr/docroot/cgi/addons/maldet/custom.cron';
$config->write( $config_file );
}

exit(0);

sub install {
Expand Down
4 changes: 4 additions & 0 deletions src/bin/update
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ else
local_version='unknown';
fi

if [ -e "/etc/cron.daily/cp-maldet" ]; then
rm /etc/cron.daily/cp-maldet
fi

if [ "$local_version" == "$remote_version" ]; then
if [ -z "$PS1" ]; then
echo "cpanel_addon-maldet is up to date";
Expand Down
7 changes: 7 additions & 0 deletions src/cron/custom.cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if [ -d "/usr/local/cpanel" ] && [ -x "/var/cpanel/addons/maldet/bin/homematch" ]; then
#cpanel
HOMEMATCH=`/var/cpanel/addons/maldet/bin/homematch`
/usr/local/maldetect/maldet -b -r $HOMEMATCH?/?/public_html 2 >> /dev/null 2>&1
fi

/var/cpanel/addons/maldet/bin/update
20 changes: 0 additions & 20 deletions src/cron/daily

This file was deleted.

2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.4
0.3.0

0 comments on commit f0f3fdf

Please sign in to comment.