#!/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
#@LICENSE@#
use strict;
use warnings;
use Socket;
use File::Basename;
use Data::Dumper;
my $inst = RVsitebuilder7Installer->new(programName => 'rvsitebuilder7', INSTALLTITLE => 'RVsitebuilder7 Installer');
#require reqPackage to call another
$inst->{'reqPackage'} = 'rvsitebuilder7-upgrade';
#setup reqPackage information
$inst->setInstallPackage("$inst->{'reqPackage'}.ProductName", 'RVsitebuilder7 Installer');
$inst->setInstallPackage("$inst->{'reqPackage'}.ProductCode", 'rvsitebuilder7_whmcpanel_plugin-upgrade');
$inst->setInstallPackage("$inst->{'reqPackage'}.SaveFilename", 'rvsitebuilder7_whmcpanel_pluginauto.tar.bz2');
#setup for installer
$inst->setInstallPackage("$inst->{'reqPackage'}.auto.installer", 'autorvsitebuilder7');
$inst->setInstallPackage("$inst->{'reqPackage'}.auto.real", 'real_autorvsitebuilder7');
$inst->startInstaller();
$inst->exitScript();
package RVsitebuilder7Installer;
use strict;
use warnings;
use File::Basename;
use Data::Dumper;
use IPC::Open3;
BEGIN {
push(@INC, dirname(__FILE__));
}
use base qw(RVSInstaller);
{
sub new {
my $class = shift;
my $self = $class->SUPER::new( @_ );
bless $self, $class;
return $self;
}
sub Process_SetupInstaller_uncompressFile {
my $self = shift;
my @logTarData = ();
#TODO uncompress solution
chdir($self->getInstallConfig('sourcePath'));
my $pid3 = open3(*CMD_IN, *CMD_OUT, *CMD_ERR, $self->{'cmd'}->{'tar'} . ' -jxvf ' . $self->getInstallPackage("$self->{'reqPackage'}.SaveFilename"));
waitpid($pid3, 0);
close(CMD_IN);
my @errs = <CMD_ERR>;
close(CMD_ERR);
if (@errs) {
my $errMsg = join("", @errs);
$errMsg=~s/\n$//;
$self->{ScreenControl}->DisplayMsg("<TAB>[ $self->{failedColor}");
$self->{ScreenControl}->DisplayMsg($self->{Language}->TranSlate('Failed'));
$self->{ScreenControl}->DisplayMsg("\e[0m ]", 1);
$self->{ScreenControl}->DisplayMsg('', 1);
$self->{ScreenControl}->DisplayMsg("$self->{failedColor}");
$self->{ScreenControl}->DisplayMsg($self->{Language}->TranSlate('Sorry') . ', '.$errMsg, 0, 'subMsg' . $self->{ACTION}, '', '#FF0000');
$self->{ScreenControl}->DisplayMsg("\e[0m", 1);
$self->{ScreenControl}->LogMsg('Uncompress the package has been uncompleted, ' . $errMsg . ".\n");
$self->exitScript();
} else {
while (my $pData = <CMD_OUT>) {
$pData=~s/\r|\n//gi;
$self->{ScreenControl}->DisplayMsg($pData , '1', 'subMsg' . $self->{ACTION});
$self->{ScreenControl}->LogMsg($pData . "\n");
push(@logTarData, $pData);
}
close(CMD_OUT);
}
my $chData = 1;
my $errorMsg = '';
foreach my $data ( @logTarData ) {
if ( $data =~ m/\/$/) {
if ( !-d $data) {
$errorMsg = sprintf("%s %s %s", $self->{Language}->TranSlate('the folder'), $data, $self->{Language}->TranSlate('cannot uncompressed'));
$chData = 0;
last;
}
}
else {
if ( !-e $data) {
$errorMsg = sprintf("%s %s %s", $self->{Language}->TranSlate('the file'), $data, $self->{Language}->TranSlate('cannot uncompressed'));
$chData = 0;
last;
}
}
}
chdir($self->getInstallConfig('thisPath'));
if ( !$chData ) {
$self->{ScreenControl}->DisplayMsg("<TAB>[ $self->{failedColor}");
$self->{ScreenControl}->DisplayMsg($self->{Language}->TranSlate('Failed'));
$self->{ScreenControl}->DisplayMsg("\e[0m ]", 1);
$self->{ScreenControl}->DisplayMsg('', 1);
$self->{ScreenControl}->DisplayMsg("$self->{failedColor}");
$self->{ScreenControl}->DisplayMsg($self->{Language}->TranSlate('Sorry') . ', ' . $errorMsg . '.', 1, 'subMsg' . $self->{ACTION}, '', '#FF0000');
$self->{ScreenControl}->DisplayMsg("\e[0m", 1);
$self->{ScreenControl}->LogMsg('Uncompress the package has been uncompleted, ' . $errorMsg . ".\n");
$self->exitScript();
}
else {
if ( -e $self->getInstallPackage("$self->{'reqPackage'}.SaveFilename")) {
unlink($self->getInstallPackage("$self->{'reqPackage'}.SaveFilename"));
}
if ( -e $self->getInstallPackage("$self->{'reqPackage'}.SaveFilename")) {
unlink($self->getInstallPackage("$self->{'reqPackage'}.SaveFilename"));
}
$self->{ScreenControl}->DisplayMsg("<TAB>[ $self->{completedColor}");
$self->{ScreenControl}->DisplayMsg($self->{Language}->TranSlate('Completed') , '', 'subMsg' . $self->{ACTION});
$self->{ScreenControl}->DisplayMsg("\e[0m ]", 1);
$self->{ScreenControl}->LogMsg('Uncompress the package has been completed' . "\n");
}
}
sub Process_SetupInstaller_rsyncFileAfterUncompress {
my $self = shift;
my $pid3 = open3(*CMD_IN, *CMD_OUT, *CMD_ERR, $self->{'cmd'}->{'rsync'} . ' -avz --timeout=60 ' . $self->getInstallConfig('sourcePath') . '/ ' . $self->getInstallConfig('thisPath'));
waitpid($pid3, 0);
close(CMD_IN);
my @errs = <CMD_ERR>;
close(CMD_ERR);
if (@errs) {
my $errMsg = join("", @errs);
$errMsg=~s/\n$//;
$self->{ScreenControl}->DisplayMsg("<TAB>[ $self->{failedColor}");
$self->{ScreenControl}->DisplayMsg($self->{Language}->TranSlate('Failed'));
$self->{ScreenControl}->DisplayMsg("\e[0m ]", 1);
$self->{ScreenControl}->DisplayMsg('', 1);
$self->{ScreenControl}->DisplayMsg("$self->{failedColor}");
$self->{ScreenControl}->DisplayMsg($self->{Language}->TranSlate('Sorry') . ', '.$errMsg, 0, 'subMsg' . $self->{ACTION}, '', '#FF0000');
$self->{ScreenControl}->DisplayMsg("\e[0m", 1);
$self->{ScreenControl}->LogMsg("Rsync the package has not completed, $errMsg.\n");
$self->exitScript();
} else {
while (my $rsyncData = <CMD_OUT>) {
$rsyncData=~s/\r|\n//gi;
$self->{ScreenControl}->DisplayMsg($rsyncData, 1, 'subMsg' . $self->{ACTION});
$self->{ScreenControl}->LogMsg($rsyncData . "\n");
}
close(CMD_OUT);
}
}
}
Copyright 2K16 - 2K18 Indonesian Hacker Rulez