Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
nuxwin committed Jul 30, 2016
1 parent c619a15 commit e73ba8b
Show file tree
Hide file tree
Showing 19 changed files with 102 additions and 191 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ sub uninstall
sub _restoreDebianConfig
{
return 0 unless -f '/etc/cron.daily/chkrootkit.disabled';

iMSCP::File->new( filename => '/etc/cron.daily/chkrootkit.disabled' )->moveFile( '/etc/cron.daily/chkrootkit' );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ sub _restoreDebianConfig

$fileContent =~ s/CRON_DAILY_RUN=".*"/CRON_DAILY_RUN=""/i;
$fileContent =~ s/CRON_DB_UPDATE=".*"/CRON_DB_UPDATE=""/i;

my $rs = $file->set( $fileContent );
$rs ||= $file->save();
return $rs if $rs;
Expand Down
13 changes: 3 additions & 10 deletions engine/PerlLib/Package/FileManager/MonstaFTP/Uninstaller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,16 @@ sub _unregisterConfig
{
my $self = shift;

for my $vhostFile('00_master.conf', '00_master_ssl.conf') {
next unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$vhostFile";

my $file = iMSCP::File->new(
filename => "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$vhostFile"
);

for ('00_master.conf', '00_master_ssl.conf') {
next unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$_";
my $file = iMSCP::File->new( filename => "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$_" );
my $fileContent = $file->get();
unless (defined $fileContent) {
error( sprintf( 'Could not read %s file', $file->{'filename'} ) );
return 1;
}

$fileContent =~ s/[\t ]*include imscp_monstaftp.conf;\n//;

my $rs = $file->set( $fileContent );
$rs ||= $file->save();
return $rs if $rs;
Expand All @@ -127,9 +122,7 @@ sub _removeFiles

my $rs = iMSCP::Dir->new( dirname => "$main::imscpConfig{'GUI_PUBLIC_DIR'}/tools/ftp" )->remove();
return $rs if $rs;

return 0 unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_CONF_DIR'}/imscp_monstaftp.conf";

iMSCP::File->new(
filename => "$self->{'frontend'}->{'config'}->{'HTTPD_CONF_DIR'}/imscp_monstaftp.conf"
)->delFile();
Expand Down
13 changes: 3 additions & 10 deletions engine/PerlLib/Package/FileManager/Net2ftp/Uninstaller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,16 @@ sub _unregisterConfig
{
my $self = shift;

for my $vhostFile('00_master.conf', '00_master_ssl.conf') {
next unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$vhostFile";

my $file = iMSCP::File->new(
filename => "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$vhostFile"
);

for ('00_master.conf', '00_master_ssl.conf') {
next unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$_";
my $file = iMSCP::File->new( filename => "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$_" );
my $fileContent = $file->get();
unless (defined $fileContent) {
error( sprintf( 'Could not read %s file', $file->{'filename'} ) );
return 1;
}

$fileContent =~ s/[\t ]*include imscp_net2ftp.conf;\n//;

my $rs = $file->set( $fileContent );
$rs ||= $file->save();
return $rs if $rs;
Expand All @@ -127,9 +122,7 @@ sub _removeFiles

my $rs = iMSCP::Dir->new( dirname => "$main::imscpConfig{'GUI_PUBLIC_DIR'}/tools/ftp" )->remove();
return $rs if $rs;

return 0 unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_CONF_DIR'}/imscp_net2ftp.conf";

iMSCP::File->new( filename => "$self->{'frontend'}->{'config'}->{'HTTPD_CONF_DIR'}/imscp_net2ftp.conf" )->delFile();
}

Expand Down
13 changes: 3 additions & 10 deletions engine/PerlLib/Package/FileManager/Pydio/Uninstaller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,16 @@ sub _unregisterConfig
{
my $self = shift;

for my $vhostFile('00_master.conf', '00_master_ssl.conf') {
next unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$vhostFile";

my $file = iMSCP::File->new(
filename => "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$vhostFile"
);

for ('00_master.conf', '00_master_ssl.conf') {
next unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$_";
my $file = iMSCP::File->new( filename => "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$_" );
my $fileContent = $file->get();
unless (defined $fileContent) {
error( sprintf( 'Could not read %s file', $file->{'filename'} ) );
return 1;
}

$fileContent =~ s/[\t ]*include imscp_pydio.conf;\n//;

my $rs = $file->set( $fileContent );
$rs ||= $file->save();
return $rs if $rs;
Expand All @@ -128,9 +123,7 @@ sub _removeFiles

my $rs = iMSCP::Dir->new( dirname => "$main::imscpConfig{'GUI_PUBLIC_DIR'}/tools/ftp" )->remove();
return $rs if $rs;

return 0 unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_CONF_DIR'}/imscp_pydio.conf";

iMSCP::File->new( filename => "$self->{'frontend'}->{'config'}->{'HTTPD_CONF_DIR'}/imscp_pydio.conf" )->delFile();
}

Expand Down
23 changes: 10 additions & 13 deletions engine/PerlLib/Package/FrontEnd/Uninstaller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,11 @@ sub _deconfigurePHP
return 1;
}

for my $pFormat('/etc/init.d/%s', '/etc/systemd/system/%s.service', '/etc/init/%s.conf', '/etc/init/%s.override') {
my $file = sprintf( $pFormat, 'imscp_panel' );
if (-f $file) {
my $rs = iMSCP::File->new( filename => $file )->delFile();
return $rs if $rs;
}
for ('/etc/init.d/%s', '/etc/systemd/system/%s.service', '/etc/init/%s.conf', '/etc/init/%s.override') {
my $file = sprintf( $_, 'imscp_panel' );
next unless -f $file;
my $rs = iMSCP::File->new( filename => $file )->delFile();
return $rs if $rs;
}

if (-f '/etc/default/imscp_panel') {
Expand Down Expand Up @@ -140,14 +139,12 @@ sub _deconfigureHTTPD
{
my $self = shift;

for my $vhost('00_master_ssl.conf', '00_master.conf') {
my $rs = $self->{'frontend'}->disableSites( $vhost );
for ('00_master_ssl.conf', '00_master.conf') {
my $rs = $self->{'frontend'}->disableSites( $_ );
return $rs if $rs;
next unless -f "$self->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$_";
$rs = iMSCP::File->new( filename => "$self->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$_" )->delFile();
return $rs if $rs;

if (-f "$self->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$vhost") {
$rs = iMSCP::File->new( filename => "$self->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$vhost" )->delFile();
return $rs if $rs;
}
}

if (-f "$self->{'config'}->{'HTTPD_CONF_DIR'}/imscp_fastcgi.conf") {
Expand Down
18 changes: 6 additions & 12 deletions engine/PerlLib/Package/PhpMyAdmin/Uninstaller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ sub _removeSqlUser
my $self = shift;

return 0 unless $self->{'config'}->{'DATABASE_USER'} && $main::imscpConfig{'DATABASE_USER_HOST'};
Servers::sqld->factory()->dropUser( $self->{'config'}->{'DATABASE_USER'},
$main::imscpConfig{'DATABASE_USER_HOST'} );
Servers::sqld->factory()->dropUser(
$self->{'config'}->{'DATABASE_USER'}, $main::imscpConfig{'DATABASE_USER_HOST'}
);
}

=item _removeSqlDatabase()
Expand Down Expand Up @@ -134,21 +135,16 @@ sub _unregisterConfig
{
my $self = shift;

for my $vhostFile('00_master.conf', '00_master_ssl.conf') {
next unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$vhostFile";

my $file = iMSCP::File->new(
filename => "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$vhostFile"
);

for ('00_master.conf', '00_master_ssl.conf') {
next unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$_";
my $file = iMSCP::File->new( filename => "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$_" );
my $fileContent = $file->get();
unless (defined $fileContent) {
error( sprintf( 'Could not read %s file', $file->{'filename'} ) );
return 1;
}

$fileContent =~ s/[\t ]*include imscp_pma.conf;\n//;

my $rs = $file->set( $fileContent );
$rs ||= $file->save();
return $rs if $rs;
Expand All @@ -173,9 +169,7 @@ sub _removeFiles
my $rs = iMSCP::Dir->new( dirname => "$main::imscpConfig{'GUI_PUBLIC_DIR'}/tools/pma" )->remove();
$rs ||= iMSCP::Dir->new( dirname => $self->{'cfgDir'} )->remove();
return $rs if $rs;

return 0 unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_CONF_DIR'}/imscp_pma.conf";

iMSCP::File->new( filename => "$self->{'frontend'}->{'config'}->{'HTTPD_CONF_DIR'}/imscp_pma.conf" )->delFile();
}

Expand Down
25 changes: 8 additions & 17 deletions engine/PerlLib/Package/Webmail/RainLoop/Uninstaller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,13 @@ sub _removeSqlUser
my $self = shift;

my $sqlServer = Servers::sqld->factory();

return 0 unless $self->{'rainloop'}->{'config'}->{'DATABASE_USER'};

for my $host(
for (
$main::imscpConfig{'DATABASE_USER_HOST'}, $main::imscpConfig{'BASE_SERVER_IP'}, 'localhost', '127.0.0.1', '%'
) {
next unless $host;
$sqlServer->dropUser( $self->{'rainloop'}->{'config'}->{'DATABASE_USER'}, $host );
$sqlServer->dropUser( $self->{'rainloop'}->{'config'}->{'DATABASE_USER'}, $_ );
}

0;
Expand Down Expand Up @@ -139,20 +138,17 @@ sub _unregisterConfig
{
my $self = shift;

for my $vhostFile('00_master.conf', '00_master_ssl.conf') {
next unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$vhostFile";
for ('00_master.conf', '00_master_ssl.conf') {
next unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$_";

my $file = iMSCP::File->new(
filename => "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$vhostFile"
);
my $file = iMSCP::File->new( filename => "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$_" );
my $fileContent = $file->get();
unless (defined $fileContent) {
error( sprintf( 'Could not read %s file', $file->{'filename'} ) );
return 1;
}

$fileContent =~ s/[\t ]*include imscp_rainloop.conf;\n//;

my $rs = $file->set( $fileContent );
$rs ||= $file->save();
return $rs if $rs;
Expand All @@ -177,15 +173,10 @@ sub _removeFiles
my $rs = iMSCP::Dir->new( dirname => "$main::imscpConfig{'GUI_PUBLIC_DIR'}/tools/rainloop" )->remove();
$rs ||= iMSCP::Dir->new( dirname => $self->{'rainloop'}->{'cfgDir'} )->remove();
return $rs if $rs;

if (-f "$self->{'frontend'}->{'config'}->{'HTTPD_CONF_DIR'}/imscp_rainloop.conf") {
$rs = iMSCP::File->new(
return 0 unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_CONF_DIR'}/imscp_rainloop.conf";
iMSCP::File->new(
filename => "$self->{'frontend'}->{'config'}->{'HTTPD_CONF_DIR'}/imscp_rainloop.conf"
)->delFile();
return $rs if $rs;
}

0;
)->delFile();
}

=back
Expand Down
24 changes: 9 additions & 15 deletions engine/PerlLib/Package/Webmail/Roundcube/Uninstaller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,13 @@ sub _removeSqlUser
my $self = shift;

my $sqlServer = Servers::sqld->factory();

return 0 unless $self->{'config'}->{'DATABASE_USER'};

for my $host(
for(
$main::imscpConfig{'DATABASE_USER_HOST'}, $main::imscpConfig{'BASE_SERVER_IP'}, 'localhost', '127.0.0.1', '%'
) {
next unless $host;
$sqlServer->dropUser( $self->{'config'}->{'DATABASE_USER'}, $host );
next unless $_;
$sqlServer->dropUser( $self->{'config'}->{'DATABASE_USER'}, $_ );
}

0;
Expand Down Expand Up @@ -143,20 +142,16 @@ sub _unregisterConfig
{
my $self = shift;

for my $vhostFile('00_master.conf', '00_master_ssl.conf') {
next unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$vhostFile";

my $file = iMSCP::File->new(
filename => "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$vhostFile"
);
for ('00_master.conf', '00_master_ssl.conf') {
next unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$_";
my $file = iMSCP::File->new( filename => "$self->{'frontend'}->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/$_" );
my $fileContent = $file->get();
unless (defined $fileContent) {
error( sprintf( 'Could not read %s file', $file->{'filename'} ) );
return 1;
}

$fileContent =~ s/[\t ]*include imscp_roundcube.conf;\n//;

my $rs = $file->set( $fileContent );
$rs ||= $file->save();
return $rs if $rs;
Expand All @@ -181,11 +176,10 @@ sub _removeFiles
my $rs = iMSCP::Dir->new( dirname => "$main::imscpConfig{'GUI_PUBLIC_DIR'}/tools/webmail" )->remove();
$rs ||= iMSCP::Dir->new( dirname => $self->{'cfgDir'} )->remove();
return $rs if $rs;

return 0 unless -f "$self->{'frontend'}->{'config'}->{'HTTPD_CONF_DIR'}/imscp_roundcube.conf";

iMSCP::File->new( filename =>
"$self->{'frontend'}->{'config'}->{'HTTPD_CONF_DIR'}/imscp_roundcube.conf" )->delFile();
iMSCP::File->new(
filename => "$self->{'frontend'}->{'config'}->{'HTTPD_CONF_DIR'}/imscp_roundcube.conf"
)->delFile();
}

=back
Expand Down
4 changes: 0 additions & 4 deletions engine/PerlLib/Package/Webstats/Awstats/Uninstaller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ sub _deleteFiles
}

return 0 unless -d $main::imscpConfig{'AWSTATS_CONFIG_DIR'};

my $rs = execute( "rm -f $main::imscpConfig{'AWSTATS_CONFIG_DIR'}/awstats.*.conf", \ my $stdout, \ my $stderr );
debug( $stdout ) if $stdout;
error( $stderr ) if $stderr && $rs;
Expand All @@ -116,7 +115,6 @@ sub _removeVhost
my $httpd = Servers::httpd->factory();

return 0 unless -f "$httpd->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/01_awstats.conf";

my $rs = $httpd->disableSites( '01_awstats.conf' );
$rs ||= iMSCP::File->new(
filename => "$httpd->{'config'}->{'HTTPD_SITES_AVAILABLE_DIR'}/01_awstats.conf"
Expand All @@ -142,9 +140,7 @@ sub _restoreDebianConfig
}

my $cronDir = Servers::cron->factory()->{'config'}->{'CRON_D_DIR'};

return 0 unless -f "$cronDir/awstats.disable";

iMSCP::File->new( filename => "$cronDir/awstats.disable" )->moveFile( "$cronDir/awstats" );
}

Expand Down
22 changes: 8 additions & 14 deletions engine/PerlLib/Servers/ftpd/proftpd/uninstaller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ package Servers::ftpd::proftpd::uninstaller;

use strict;
use warnings;
use iMSCP::Debug;
use iMSCP::Execute;
use File::Basename;
use iMSCP::File;
use Servers::ftpd::proftpd;
Expand Down Expand Up @@ -69,8 +67,9 @@ sub removeDB
{
my $self = shift;

Servers::sqld->factory()->dropUser( $self->{'config'}->{'DATABASE_USER'},
$main::imscpConfig{'DATABASE_USER_HOST'} );
Servers::sqld->factory()->dropUser(
$self->{'config'}->{'DATABASE_USER'}, $main::imscpConfig{'DATABASE_USER_HOST'}
);
}

=item restoreConfFile()
Expand All @@ -85,16 +84,11 @@ sub restoreConfFile
{
my $self = shift;

my ($filename, $directories, $suffix) = fileparse( $self->{'config'}->{'FTPD_CONF_FILE'} );

if (-f "$self->{bkpDir}/$filename$suffix.system") {
my $rs = iMSCP::File->new( filename => "$self->{'bkpDir'}/$filename$suffix.system" )->copyFile(
"$self->{bkpDir}/$filename$suffix.system"
);
return $rs if $rs;
}

0;
my $filename = basename( $self->{'config'}->{'FTPD_CONF_FILE'} );
return 0 unless -f "$self->{bkpDir}/$filename.system";
iMSCP::File->new( filename => "$self->{'bkpDir'}/$filename.system" )->copyFile(
"$self->{bkpDir}/$filename.system"
);
}

=back
Expand Down

0 comments on commit e73ba8b

Please sign in to comment.