File: //usr/local/cwaf/scripts/fix_exclude_cache.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
#SVN
use strict qw(refs subs);
use warnings;
no warnings 'redefine';
BEGIN { require '/etc/cwaf/use_lib.pl' if -f '/etc/cwaf/use_lib.pl'; }
use Comodo::CWAF::Main;# qw(%conf is_cpanel);
require Comodo::CWAF::Cpanel;
print("script to fix exclude cache for SSL hosts on cPanel\n");
unless (&is_cpanel()) {
print("no installed cPanel found\n");
exit;
}
print("fixing exclude cache for SSL hosts\n");
my($domains, $newfile, $oldfile, $name, $sslport, $oldcfile, $newcfile);
$domains = Comodo::CWAF::Cpanel::cp_get_domainlist();
foreach my $domain (@$domains) {
print(" attempting to fix exclude cache for $domain \n");
if(index($domain, '|') != -1) {
($name, $sslport) = split('\|', $domain);
$oldfile = $conf{'cwaf_path'}.'/etc/yml/'.$name.'_exclude.yml';
$newfile = $conf{'cwaf_path'}.'/etc/yml/'.$domain.'_exclude.yml';
$oldcfile = "$conf{'cwaf_path'}/etc/httpd/domains/000_exclude_$name.conf";
$newcfile = "$conf{'cwaf_path'}/etc/httpd/domains/000_exclude_$domain.conf";
if( (-e $oldfile) && (-e $newfile) ) {
print(" creating backup of old files\n");
rename $newfile, $newfile.'.backup';
rename $newcfile, $newcfile.'.backup';
print(" renaming $oldfile to $newfile\n");
rename $oldfile, $newfile;
print(" renaming config $oldcfile to $newcfile\n");
rename $oldcfile, $newcfile;
}
}
}
print("fixing exclude cache done\n");