-
Notifications
You must be signed in to change notification settings - Fork 6
/
install
executable file
·80 lines (62 loc) · 4.45 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/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";
exit(1);
}
mkdir( "/var/cpanel/addons", 0755 );
mkdir( "/var/cpanel/addons/maldet", 0700 );
system '/usr/bin/rsync', '-rlptD', 'src/bin', '/var/cpanel/addons/maldet/';
if (! -e '/usr/local/sbin/maldet') {
if (-X "/var/cpanel/addons/maldet/bin/install_lmd") {
system '/var/cpanel/addons/maldet/bin/install_lmd';
if ($? != 0) {
print "LMD Install Script Failed\n";
exit(1);
}
} else {
print "LMD Install Script Not Found?\n";
exit(1);
}
} else {
print "LMD installed\n";
}
mkdir( "/usr/local/cpanel/whostmgr/docroot/cgi/addons", 0755 ) if !-e "/usr/local/cpanel/whostmgr/docroot/cgi/addons";
mkdir( "/usr/local/cpanel/base/frontend/paper_lantern/maldet", 0755 ) if !-e "/usr/local/cpanel/base/frontend/paper_lantern/maldet";
mkdir( "/usr/local/cpanel/whostmgr/docroot/cgi/addons/maldet", 0700 );
mkdir( "/var/cpanel/apps", 0755 );
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/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" );
install( "-o", "root", "-g", "wheel", "-m" . "0400", "src/templates/err.tmpl", "/usr/local/cpanel/whostmgr/docroot/templates/maldet/err.tmpl" );
install( "-o", "root", "-g", "wheel", "-m" . "0400", "src/templates/report.tmpl", "/usr/local/cpanel/whostmgr/docroot/templates/maldet/report.tmpl" );
install( "-o", "root", "-g", "wheel", "-m" . "0400", "src/templates/editor.tmpl", "/usr/local/cpanel/whostmgr/docroot/templates/maldet/editor.tmpl" );
install( "-o", "root", "-g", "wheel", "-m" . "0400", "src/templates/start_scan.tmpl", "/usr/local/cpanel/whostmgr/docroot/templates/maldet/start_scan.tmpl" );
install( "-o", "root", "-g", "wheel", "-m" . "0444", "src/lib/Maldet.pm", "/usr/local/cpanel/Cpanel/Plugins/Maldet.pm" );
install( "-o", "root", "-g", "wheel", "-m" . "0444", "src/lib/API/Maldet.pm", "/usr/local/cpanel/Cpanel/API/Maldet.pm" );
install( "-o", "root", "-g", "wheel", "-m" . "0444", "src/lib/WHM/Maldet.pm", "/usr/local/cpanel/Whostmgr/Maldet.pm" );
install( "-o", "root", "-g", "wheel", "-m" . "0444", "src/paper_lantern/maldet/index.html.tt", "/usr/local/cpanel/base/frontend/paper_lantern/maldet/index.html.tt" );
install( "-o", "root", "-g", "wheel", "-m" . "0444", "src/paper_lantern/maldet/report.html.tt", "/usr/local/cpanel/base/frontend/paper_lantern/maldet/report.html.tt" );
install( "-o", "root", "-g", "wheel", "-m" . "0444", "src/paper_lantern/maldet/scan.html.tt", "/usr/local/cpanel/base/frontend/paper_lantern/maldet/scan.html.tt" );
install( "-o", "root", "-g", "wheel", "-m" . "0444", "src/paper_lantern/maldet/latest.html.tt", "/usr/local/cpanel/base/frontend/paper_lantern/maldet/latest.html.tt" );
install( "-o", "root", "-g", "wheel", "-m" . "0444", "src/paper_lantern/maldet/action.html.tt", "/usr/local/cpanel/base/frontend/paper_lantern/maldet/action.html.tt" );
system "/usr/local/cpanel/bin/register_appconfig", "appconfig/maldet.conf";
mkdir( "/usr/local/cpanel/whostmgr/docroot/addon_plugins", 0755 ) if !-e "/usr/local/cpanel/whostmgr/docroot/addon_plugins";
install( "-o", "root", "-g", "wheel", "-m" . "0600", "icon/ico-maldet.png", "/usr/local/cpanel/whostmgr/docroot/addon_plugins/ico-maldet.png" );
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 {
system( "/usr/bin/install", @_ );
}