Fix to consider initial install directory upon upgrading

This commit is contained in:
iliajie
2023-03-22 20:15:49 +02:00
parent 43159eef0c
commit 03606c8214
2 changed files with 29 additions and 7 deletions

View File

@@ -15,6 +15,17 @@ else {
&ui_print_unbuffered_header(undef, $in{'install'} ? $text{'upgrade_title2'} : $text{'upgrade_title'}, "");
# Do we have an install dir?
my $indir = $in{'dir'};
if (!$indir) {
my $install_dir = "$config_directory/install-dir";
if (-e $install_dir) {
$indir = &read_file_contents($install_dir);
$indir = &trim($indir);
$indir = undef if (!-d $indir);
}
}
if ($in{'source'} == 0) {
# from local file
&error_setup(&text('upgrade_err1', $in{'file'}));
@@ -245,7 +256,7 @@ else {
}
else {
# Upgrading .. work out where to extract
if ($in{'dir'}) {
if ($indir) {
# Since we are currently installed in a fixed directory,
# just extract to a temporary location
$extract = &transname();
@@ -265,7 +276,7 @@ else {
$ENV{'config_dir'} = $config{'usermin_dir'};
$ENV{'webmin_upgrade'} = 1;
$ENV{'autothird'} = 1;
$setup = $in{'dir'} ? "./setup.sh '$in{'dir'}'" : "./setup.sh";
$setup = $indir ? "./setup.sh '$indir'" : "./setup.sh";
if ($in{'delete'}) {
$ENV{'deletedold'} = 1;
$cmd = "(cd $extract/usermin-$version && $setup && rm -rf \"$miniserv{'root'}\")";
@@ -278,7 +289,7 @@ else {
print "<pre>";
&proc::safe_process_exec($cmd, 0, 0, STDOUT, undef, 1);
print "</pre>";
if ($in{'dir'}) {
if ($indir) {
# Can delete the temporary source directory
system("rm -rf \"$extract\"");
}

View File

@@ -11,6 +11,17 @@ $| = 1;
$theme_no_table = 1;
&ui_print_header(undef, $text{'upgrade_title'}, "");
# Do we have an install dir?
my $indir = $in{'dir'};
if (!$indir) {
my $install_dir = "$config_directory/install-dir";
if (-e $install_dir) {
$indir = &read_file_contents($install_dir);
$indir = &trim($indir);
$indir = undef if (!-d $indir);
}
}
# Save this CGI from being killed by the upgrade
$SIG{'TERM'} = 'IGNORE';
@@ -361,7 +372,7 @@ elsif ($in{'mode'} eq 'solaris-pkg' || $in{'mode'} eq 'sun-pkg') {
$dir = $1;
}
$setup = $in{'dir'} ? "./setup.sh '$in{'dir'}'" : "./setup.sh";
$setup = $indir ? "./setup.sh '$indir'" : "./setup.sh";
print "Package Directory: $dir<br>";
print "cd $dir && ./setup.sh<br>";
&proc::safe_process_exec(
@@ -439,7 +450,7 @@ else {
}
# Work out where to extract
if ($in{'dir'}) {
if ($indir) {
# Since we are currently installed in a fixed directory,
# just extract to a temporary location
$extract = &transname();
@@ -498,7 +509,7 @@ else {
$ENV{'deletedold'} = 1 if ($in{'delete'});
print "<p>",$text{'upgrade_setup'},"<p>\n";
print "<pre>";
$setup = $in{'dir'} ? "./setup.sh '$in{'dir'}'" : "./setup.sh";
$setup = $indir ? "./setup.sh '$indir'" : "./setup.sh";
&proc::safe_process_exec(
"cd $extract/webmin-$version && $setup", 0, 0,
STDOUT, undef, 1, 1);
@@ -508,7 +519,7 @@ else {
# Can delete the old root directory
system("rm -rf ".quotemeta($root_directory));
}
elsif ($in{'dir'}) {
elsif ($indir) {
# Can delete the temporary source directory
system("rm -rf ".quotemeta($extract));
}