HEX
Server: Apache/2
System: Linux nexus-01 4.18.0-553.120.1.el8_10.x86_64 #1 SMP Mon Apr 20 18:04:27 EDT 2026 x86_64
User: aglcoke (1118)
PHP: 8.2.31
Disabled: mail,exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/cwaf/scripts/uninstall_perl_mods.pl
#!/bin/sh
eval 'if [ -x /usr/local/cpanel/3rdparty/bin/perl ]; then exec /usr/local/cpanel/3rdparty/bin/perl -x -- $0 ${1+"$@"}; else exec /usr/bin/perl -x $0 ${1+"$@"}; fi;'
  if 0;

#!/usr/bin/perl

use ExtUtils::Installed qw();
use ExtUtils::Packlist qw();
use File::Path qw(remove_tree);
use File::Basename;

BEGIN { require '/etc/cwaf/use_lib.pl' if -f '/etc/cwaf/use_lib.pl'; }
use Comodo::CWAF::Main qw(%conf is_webpanel);
use Comodo::CWAF::Platform;

sub deleteCWAFDirs() {
    # Delete CWAF logs and conf
    print "Removing CWAF logs $conf{'log_dir'}\n";
    remove_tree($conf{'log_dir'} , { keep_root => 0 });
    print "Removing /etc/cwaf\n";
    unlink "/etc/cwaf";
}

sub getCWAFPath() {
    print "$conf{'cwaf_path'}";
}

sub deleteComodoCrontab() {
    print "Removing CRON tasks\n";
    set_crontab('none');
}

sub deleteComodoDir($) {
   my ($dir) = @_;

   # return if this is not Comodo dir
   return unless ( $dir =~ /\/Comodo\/CWAF$/);

   my @parts = split(/\//, $dir);
   $delDir = join("/", @parts[0 .. $#parts-1]);
   print "Delete directory $delDir\n";
   remove_tree($delDir, { keep_root => 0 });
}

sub deletePerlModule($) {
    my ($mod) = @_;
    $mod = "Comodo::CWAF" unless(defined ($mod));

    print "Uninstalling Perl module $mod\n";

    my $inst = ExtUtils::Installed->new;
    my $filename = '';

    foreach my $item (sort($inst->files($mod))) {
        print "Removing $item\n";
        unlink $item or warn "could not remove $item: $!\n";
        $filename = $item if ( $item =~ /\/Comodo\/CWAF\//);
    }

    deleteComodoDir( dirname($filename) );

    my $packfile = $inst->packlist($mod)->packlist_file;
    print "Removing $packfile\n";
    unlink $packfile or warn "could not remove $packfile: $!\n";
    deleteComodoDir( dirname($packfile) );
}

my $parcount = $#ARGV + 1;
if ($parcount && ($ARGV[0] eq "--uninstall") ) {

    # remove crontabs before uninstall
    deleteComodoCrontab() if(&is_webpanel());

    # delete Perl module
    deletePerlModule("Comodo::CWAF");

    # delete CWAF directory and logs
    deleteCWAFDirs();
}
elsif ($parcount && ($ARGV[0] eq "--module") ) {
    # delete Perl module
    deletePerlModule("Comodo::CWAF");
}
elsif ($parcount && ($ARGV[0] eq "--cwafpath") ) {
    getCWAFPath();
}
 else {
    print "Script to uninstall COMODO Perl modules and dirs\n";
    print "Usage: \n";
    print "   $0 --cwafpath         get Comodo WAF install path\n";
    print "   $0 --module           remove Comodo WAF perl module\n";
    print "   $0 --uninstall        remove all\n";
}