#!/usr/bin/perl # upgrade.cgi # Upgrade usermin if possible require './usermin-lib.pl'; $access{'upgrade'} || &error($text{'acl_ecannot'}); &foreign_require("proc", "proc-lib.pl"); if ($ENV{'CONTENT_TYPE'} =~ /boundary=/) { &ReadParseMime(); } else { &ReadParse(); } &get_usermin_miniserv_config(\%miniserv); &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'})); $file = $in{'file'}; if (!(-r $file)) { &inst_error($text{'upgrade_efile'}); } } elsif ($in{'source'} == 1) { # from uploaded file &error_setup($text{'upgrade_err2'}); $file = &transname(); $need_unlink = 1; if ($no_upload) { &inst_error($text{'upgrade_ebrowser'}); } &open_tempfile(MOD, ">$file", 0, 1); &print_tempfile(MOD, $in{'upload'}); &close_tempfile(MOD); } elsif ($in{'source'} == 2) { # find latest version at www.webmin.com by looking at index page &error_setup($text{'upgrade_err3'}); $file = &transname(); &http_download('www.webmin.com', 80, '/index6.html', $file, \$error); $error && &inst_error($error); open(FILE, "<$file"); while(<FILE>) { if (/usermin-([0-9\.]+)-(\d+)\.tar\.gz/ || /usermin-([0-9\.]+)\.tar\.gz/) { $version = $1; $release = $2; last; } } close(FILE); unlink($file); if (!$in{'force'}) { if ($version == &get_usermin_version()) { &inst_error(&text('upgrade_elatest', $version)); } elsif ($version <= &get_usermin_version()) { &inst_error(&text('upgrade_eversion', $version)); } } # Work out the current Usermin type (webmail or regular) $product = "usermin"; if (&has_command("rpm") && $in{'mode'} eq 'rpm' && &execute_command("rpm -q usermin-webmail") == 0) { $product = "usermin-webmail"; } elsif (&has_command("dpkg") && $in{'mode'} eq 'deb' && &execute_command("dpkg --list usermin-webmail") == 0) { $product = "usermin-webmail"; } if ($in{'mode'} eq 'rpm') { $release ||= 1; $progress_callback_url = &convert_osdn_url( "http://$webmin::osdn_host/webadmin/${product}-${version}-${release}.noarch.rpm"); } elsif ($in{'mode'} eq 'deb') { $release = $release ? "-".$release : ""; $progress_callback_url = &convert_osdn_url( "http://$webmin::osdn_host/webadmin/${product}_${version}${release}_all.deb"); } else { $release = $release ? "-".$release : ""; $progress_callback_url = &convert_osdn_url( "http://$webmin::osdn_host/webadmin/${product}-${version}${release}.tar.gz"); } ($host, $port, $page, $ssl) = &parse_http_url($progress_callback_url); &http_download($host, $port, $page, $file, \$error, \&progress_callback, $ssl); $error && &inst_error($error); $need_unlink = 1; } elsif ($in{'source'} == 5) { # Download from some URL &error_setup(&text('upgrade_err5', $in{'url'})); $file = &transname(); $progress_callback_url = $in{'url'}; if ($in{'url'} =~ /^(http|https):\/\/([^\/]+)(\/.*)$/) { $ssl = $1 eq 'https'; $host = $2; $page = $3; $port = $ssl ? 443 : 80; if ($host =~ /^(.*):(\d+)$/) { $host = $1; $port = $2; } &http_download($host, $port, $page, $file, \$error, \&progress_callback, $ssl); } elsif ($in{'url'} =~ /^ftp:\/\/([^\/]+)(:21)?\/(.*)$/) { $host = $1; $ffile = $3; &ftp_download($host, $ffile, $file, \$error, \&progress_callback); } else { &inst_error($text{'upgrade_eurl'}); } $need_unlink = 1; $error && &inst_error($error); } $qfile = quotemeta($file); # gunzip the file if needed open(FILE, "<$file"); read(FILE, $two, 2); close(FILE); if ($two eq "\037\213") { if (!&has_command("gunzip")) { &inst_error($text{'upgrade_egunzip'}); } $newfile = &transname(); $out = `gunzip -c $file 2>&1 >$newfile`; if ($?) { unlink($newfile); &inst_error(&text('upgrade_egzip', "<tt>$out</tt>")); } unlink($file) if ($need_unlink); $need_unlink = 1; $file = $newfile; } $qfile = quotemeta($file); # Get list of updates $updatestemp = &transname(); &http_download($update_host, $update_port, $update_page, $updatestemp, \$updates_error); if ($in{'mode'} eq 'rpm') { # Check if it is an RPM package $out = `rpm -qp $qfile`; $out =~ /^usermin-(\d+\.\d+)/ || $out =~ /^usermin-webmail-(\d+\.\d+)/ || &inst_error($text{'upgrade_erpm'}); $version = $1; if ($version <= &get_usermin_version() && !$in{'force'}) { &inst_error(&text('upgrade_eversion', $version)); } # Install the RPM if ($in{'force'}) { $cmd = "rpm -Uv --force --nodeps $qfile"; } else { $cmd = "rpm -Uv --ignoreos --ignorearch --nodeps $qfile"; } print "<p>",&text($in{'install'} ? 'upgrade_setup2' : 'upgrade_setup', "<tt>$cmd</tt>"),"<br>\n"; print "<pre>"; &proc::safe_process_exec($cmd, 0, 0, STDOUT, undef, 1); print "</pre>"; unlink($file) if ($need_unlink); } elsif ($in{'mode'} eq 'deb') { # Check if it is a Debian package $out = `dpkg --info $qfile`; $out =~ /Package:\s+(\S+)/ && ($1 eq "usermin" || $1 eq "usermin-webmail") || &inst_error($text{'upgrade_edeb'}); $out =~ /Version:\s+(\S+)/ || &inst_error($text{'upgrade_edeb'}); $version = $1; if ($version <= &get_usermin_version() && !$in{'force'}) { &inst_error(&text('upgrade_eversion', $version)); } # Install the package $cmd = "dpkg --install $qfile"; print "<p>",&text($in{'install'} ? 'upgrade_setup2' : 'upgrade_setup', "<tt>$cmd</tt>"),"<br>\n"; print "<pre>"; &proc::safe_process_exec($cmd, 0, 0, STDOUT, undef, 1); print "</pre>"; unlink($file) if ($need_unlink); } else { # Check if it is a usermin tarfile open(TAR, "tar tf $file 2>&1 |"); while(<TAR>) { if (/^usermin-([0-9\.]+)\//) { $version = $1; } if (/^webmin-([0-9\.]+)\//) { $webmin_version = $1; } if (/^[^\/]+\/(\S+)$/) { $hasfile{$1}++; } } close(TAR); if ($webmin_version) { &inst_error(&text('upgrade_ewebmin', $webmin_version)); } if (!$version) { if ($hasfile{'module.info'}) { &inst_error(&text('upgrade_emod', 'edit_mods.cgi')); } else { &inst_error($text{'upgrade_etar'}); } } if (!$in{'force'}) { if ($version <= &get_usermin_version()) { &inst_error(&text('upgrade_eversion', $version)); } } $| = 1; local $cmd; if ($in{'install'}) { # Installing .. extract it in /usr/local and run setup.sh local $root = "/usr/local"; mkdir($root, 0755); $out = `cd $root ; tar xf $file 2>&1 >/dev/null`; if ($?) { &inst_error(&text('upgrade_euntar', "<tt>$out</tt>")); } unlink($file) if ($need_unlink); $ENV{'config_dir'} = $standard_usermin_dir; $ENV{'var_dir'} = "/var/usermin"; $perl = &get_perl_path(); $ENV{'perl'} = $perl; $ENV{'autoos'} = 3; $ENV{'port'} = 20000; $ENV{'ssl'} = 1; $ENV{'os_type'} = $gconfig{'os_type'}; $ENV{'os_version'} = $gconfig{'os_version'}; $ENV{'real_os_type'} = $gconfig{'real_os_type'}; $ENV{'real_os_version'} = $gconfig{'real_os_version'}; $cmd = "(cd $root/usermin-$version && ./setup.sh)"; print "<p>",&text('upgrade_setup2', "<tt>setup.sh</tt>"),"<br>\n"; } else { # Upgrading .. work out where to extract if ($indir) { # Since we are currently installed in a fixed directory, # just extract to a temporary location $extract = &transname(); mkdir($extract, 0755); } else { # Next to the current directory $extract = "$miniserv{'root'}/.."; } # Extract it next to the current directory and run setup.sh $out = `cd $extract ; tar xf $file 2>&1 >/dev/null`; if ($?) { &inst_error(&text('upgrade_euntar', "<tt>$out</tt>")); } unlink($file) if ($need_unlink); $ENV{'config_dir'} = $config{'usermin_dir'}; $ENV{'webmin_upgrade'} = 1; $ENV{'autothird'} = 1; $setup = $indir ? "./setup.sh '$indir'" : "./setup.sh"; if ($in{'delete'}) { $ENV{'deletedold'} = 1; $cmd = "(cd $extract/usermin-$version && $setup && rm -rf \"$miniserv{'root'}\")"; } else { $cmd = "(cd $extract/usermin-$version && $setup)"; } print "<p>",&text('upgrade_setup', "<tt>setup.sh</tt>"),"<br>\n"; } print "<pre>"; &proc::safe_process_exec($cmd, 0, 0, STDOUT, undef, 1); print "</pre>"; if ($indir) { # Can delete the temporary source directory system("rm -rf \"$extract\""); } } # Notify Webmin that this module might now be usable &foreign_require("webmin", "webmin-lib.pl"); ($inst, $changed) = &webmin::build_installed_modules(0, 'usermin'); if (@$changed && defined(&theme_post_change_modules)) { &theme_post_change_modules(); } &webmin_log($in{'install'} ? "uinstall" : "upgrade", undef, undef, { 'version' => $version, 'mode' => $in{'mode'} }); # Find out about any updates for this new version. if ($updates_error) { print "<br>",&text('upgrade_eupdates', $updates_error),"<p>\n"; } else { open(UPDATES, "<$updatestemp"); while(<UPDATES>) { if (/^([^\t]+)\t+([^\t]+)\t+([^\t]+)\t+([^\t]+)\t+(.*)/) { push(@updates, [ $1, $2, $3, $4, $5 ]); } } close(UPDATES); unlink($updatestemp); $bversion = &base_version($version); foreach $u (@updates) { next if ($u->[1] >= $bversion + .01 || $u->[1] <= $bversion || $u->[1] <= $version); local $osinfo = { 'os_support' => $u->[3] }; next if (!&check_usermin_os_support($osinfo)); $ucount++; } if ($ucount) { print "<br>",&text('upgrade_updates', $ucount, "update.cgi?source=0&show=0&missing=0"),"<p>\n"; } } &ui_print_footer("", $text{'index_return'}); sub inst_error { unlink($file) if ($need_unlink); &error($_[0]); exit; }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
images | Folder | 0755 |
|
|
lang | Folder | 0755 |
|
|
CHANGELOG | File | 3.94 KB | 0644 |
|
acl_security.pl | File | 1.37 KB | 0755 |
|
backup_config.pl | File | 2.17 KB | 0755 |
|
bootup.cgi | File | 1.12 KB | 0755 |
|
cgi_args.pl | File | 160 B | 0755 |
|
change_access.cgi | File | 783 B | 0755 |
|
change_advanced.cgi | File | 1.57 KB | 0755 |
|
change_anon.cgi | File | 758 B | 0755 |
|
change_bind.cgi | File | 2.96 KB | 0755 |
|
change_lang.cgi | File | 489 B | 0755 |
|
change_mobile.cgi | File | 989 B | 0755 |
|
change_os.cgi | File | 1.9 KB | 0755 |
|
change_referers.cgi | File | 462 B | 0755 |
|
change_session.cgi | File | 5.15 KB | 0755 |
|
change_ssl.cgi | File | 2.44 KB | 0755 |
|
change_theme.cgi | File | 675 B | 0755 |
|
change_twofactor.cgi | File | 1.07 KB | 0755 |
|
change_ui.cgi | File | 1.55 KB | 0755 |
|
change_users.cgi | File | 1.19 KB | 0755 |
|
change_web.cgi | File | 2.8 KB | 0755 |
|
clear_blocked.cgi | File | 126 B | 0755 |
|
clone_mod.cgi | File | 1.53 KB | 0755 |
|
config | File | 85 B | 0644 |
|
config.info | File | 242 B | 0644 |
|
config.info.ar | File | 315 B | 0644 |
|
config.info.ca | File | 287 B | 0644 |
|
config.info.cs | File | 287 B | 0644 |
|
config.info.de | File | 275 B | 0644 |
|
config.info.es | File | 298 B | 0644 |
|
config.info.fa | File | 221 B | 0644 |
|
config.info.fi | File | 273 B | 0644 |
|
config.info.fr | File | 300 B | 0644 |
|
config.info.hu | File | 0 B | 0644 |
|
config.info.it | File | 304 B | 0644 |
|
config.info.ja | File | 275 B | 0644 |
|
config.info.ms | File | 264 B | 0644 |
|
config.info.nl | File | 266 B | 0644 |
|
config.info.no | File | 244 B | 0644 |
|
config.info.pl | File | 290 B | 0644 |
|
config.info.pt_BR | File | 54 B | 0644 |
|
config.info.ru | File | 62 B | 0644 |
|
config.info.uk | File | 63 B | 0644 |
|
config.info.zh_TW | File | 34 B | 0644 |
|
copycert.cgi | File | 1.58 KB | 0755 |
|
defaultacl | File | 269 B | 0644 |
|
delete_mod.cgi | File | 2.14 KB | 0755 |
|
delete_session.cgi | File | 317 B | 0755 |
|
download_cert.cgi | File | 575 B | 0755 |
|
edit_access.cgi | File | 1.22 KB | 0755 |
|
edit_acl.cgi | File | 620 B | 0755 |
|
edit_advanced.cgi | File | 2.05 KB | 0755 |
|
edit_anon.cgi | File | 807 B | 0755 |
|
edit_assignment.cgi | File | 1.18 KB | 0755 |
|
edit_bind.cgi | File | 2.08 KB | 0755 |
|
edit_blocked.cgi | File | 892 B | 0755 |
|
edit_categories.cgi | File | 2.03 KB | 0755 |
|
edit_configs.cgi | File | 2.68 KB | 0755 |
|
edit_dav.cgi | File | 1.75 KB | 0755 |
|
edit_defacl.cgi | File | 692 B | 0755 |
|
edit_descs.cgi | File | 846 B | 0755 |
|
edit_ipkey.cgi | File | 1.62 KB | 0755 |
|
edit_lang.cgi | File | 1.79 KB | 0755 |
|
edit_logout.cgi | File | 1.16 KB | 0755 |
|
edit_mobile.cgi | File | 1.14 KB | 0755 |
|
edit_mods.cgi | File | 4.49 KB | 0755 |
|
edit_os.cgi | File | 3.04 KB | 0755 |
|
edit_referers.cgi | File | 937 B | 0755 |
|
edit_restrict.cgi | File | 2.05 KB | 0755 |
|
edit_session.cgi | File | 6.01 KB | 0755 |
|
edit_ssl.cgi | File | 6.24 KB | 0755 |
|
edit_themes.cgi | File | 3.28 KB | 0755 |
|
edit_twofactor.cgi | File | 1.65 KB | 0755 |
|
edit_ui.cgi | File | 2.67 KB | 0755 |
|
edit_upgrade.cgi | File | 4.05 KB | 0755 |
|
edit_users.cgi | File | 1.19 KB | 0755 |
|
edit_web.cgi | File | 3.08 KB | 0755 |
|
export_mod.cgi | File | 1.33 KB | 0755 |
|
feedback_files.pl | File | 137 B | 0755 |
|
index.cgi | File | 3.64 KB | 0755 |
|
install_check.pl | File | 530 B | 0755 |
|
install_mod.cgi | File | 2.68 KB | 0755 |
|
install_theme.cgi | File | 2.19 KB | 0755 |
|
list_configs.cgi | File | 780 B | 0755 |
|
list_restrict.cgi | File | 1.51 KB | 0755 |
|
list_sessions.cgi | File | 1.42 KB | 0755 |
|
log_parser.pl | File | 1.49 KB | 0755 |
|
module.info | File | 217 B | 0644 |
|
module.info.af | File | 0 B | 0644 |
|
module.info.af.auto | File | 130 B | 0644 |
|
module.info.ar | File | 133 B | 0644 |
|
module.info.ar.auto | File | 16 B | 0644 |
|
module.info.be | File | 0 B | 0644 |
|
module.info.be.auto | File | 229 B | 0644 |
|
module.info.bg | File | 0 B | 0644 |
|
module.info.bg.auto | File | 251 B | 0644 |
|
module.info.ca | File | 131 B | 0644 |
|
module.info.ca.auto | File | 16 B | 0644 |
|
module.info.cs | File | 29 B | 0644 |
|
module.info.cs.auto | File | 116 B | 0644 |
|
module.info.da | File | 0 B | 0644 |
|
module.info.da.auto | File | 129 B | 0644 |
|
module.info.de | File | 122 B | 0644 |
|
module.info.de.auto | File | 16 B | 0644 |
|
module.info.el | File | 0 B | 0644 |
|
module.info.el.auto | File | 212 B | 0644 |
|
module.info.es | File | 34 B | 0644 |
|
module.info.es.auto | File | 127 B | 0644 |
|
module.info.eu | File | 0 B | 0644 |
|
module.info.eu.auto | File | 164 B | 0644 |
|
module.info.fa | File | 0 B | 0644 |
|
module.info.fa.auto | File | 190 B | 0644 |
|
module.info.fi | File | 26 B | 0644 |
|
module.info.fi.auto | File | 103 B | 0644 |
|
module.info.fr | File | 33 B | 0644 |
|
module.info.fr.auto | File | 123 B | 0644 |
|
module.info.he | File | 0 B | 0644 |
|
module.info.he.auto | File | 182 B | 0644 |
|
module.info.hr | File | 0 B | 0644 |
|
module.info.hr.auto | File | 154 B | 0644 |
|
module.info.hu | File | 31 B | 0644 |
|
module.info.hu.auto | File | 120 B | 0644 |
|
module.info.it | File | 34 B | 0644 |
|
module.info.it.auto | File | 114 B | 0644 |
|
module.info.ja | File | 23 B | 0644 |
|
module.info.ja.auto | File | 135 B | 0644 |
|
module.info.ko | File | 0 B | 0644 |
|
module.info.ko.auto | File | 140 B | 0644 |
|
module.info.lt | File | 0 B | 0644 |
|
module.info.lt.auto | File | 162 B | 0644 |
|
module.info.lv | File | 0 B | 0644 |
|
module.info.lv.auto | File | 143 B | 0644 |
|
module.info.ms | File | 120 B | 0644 |
|
module.info.ms.auto | File | 16 B | 0644 |
|
module.info.mt | File | 0 B | 0644 |
|
module.info.mt.auto | File | 152 B | 0644 |
|
module.info.nl | File | 29 B | 0644 |
|
module.info.nl.auto | File | 103 B | 0644 |
|
module.info.no | File | 30 B | 0644 |
|
module.info.no.auto | File | 119 B | 0644 |
|
module.info.pl | File | 120 B | 0644 |
|
module.info.pl.auto | File | 16 B | 0644 |
|
module.info.pt | File | 0 B | 0644 |
|
module.info.pt.auto | File | 153 B | 0644 |
|
module.info.pt_BR | File | 37 B | 0644 |
|
module.info.pt_BR.auto | File | 125 B | 0644 |
|
module.info.ro | File | 0 B | 0644 |
|
module.info.ro.auto | File | 154 B | 0644 |
|
module.info.ru | File | 35 B | 0644 |
|
module.info.ru.auto | File | 200 B | 0644 |
|
module.info.sk | File | 0 B | 0644 |
|
module.info.sk.auto | File | 146 B | 0644 |
|
module.info.sl | File | 0 B | 0644 |
|
module.info.sl.auto | File | 155 B | 0644 |
|
module.info.sv | File | 0 B | 0644 |
|
module.info.sv.auto | File | 142 B | 0644 |
|
module.info.th | File | 0 B | 0644 |
|
module.info.th.auto | File | 258 B | 0644 |
|
module.info.tr | File | 0 B | 0644 |
|
module.info.tr.auto | File | 150 B | 0644 |
|
module.info.uk | File | 0 B | 0644 |
|
module.info.uk.auto | File | 258 B | 0644 |
|
module.info.ur | File | 0 B | 0644 |
|
module.info.ur.auto | File | 192 B | 0644 |
|
module.info.vi | File | 0 B | 0644 |
|
module.info.vi.auto | File | 163 B | 0644 |
|
module.info.zh | File | 0 B | 0644 |
|
module.info.zh.auto | File | 114 B | 0644 |
|
module.info.zh_TW | File | 25 B | 0644 |
|
module.info.zh_TW.auto | File | 98 B | 0644 |
|
move.cgi | File | 606 B | 0755 |
|
newkey.cgi | File | 2.64 KB | 0755 |
|
restart.cgi | File | 110 B | 0755 |
|
save_acl.cgi | File | 355 B | 0755 |
|
save_assignment.cgi | File | 588 B | 0755 |
|
save_categories.cgi | File | 1.05 KB | 0755 |
|
save_configs.cgi | File | 751 B | 0755 |
|
save_dav.cgi | File | 1019 B | 0755 |
|
save_defacl.cgi | File | 626 B | 0755 |
|
save_descs.cgi | File | 585 B | 0755 |
|
save_ipkey.cgi | File | 1.49 KB | 0755 |
|
save_logout.cgi | File | 1022 B | 0755 |
|
save_restrict.cgi | File | 1.31 KB | 0755 |
|
save_uconfigs.cgi | File | 1.38 KB | 0755 |
|
savekey.cgi | File | 2.4 KB | 0755 |
|
start.cgi | File | 200 B | 0755 |
|
stop.cgi | File | 203 B | 0755 |
|
switch.cgi | File | 317 B | 0755 |
|
syslog_logs.pl | File | 651 B | 0755 |
|
uninstall.pl | File | 350 B | 0755 |
|
update.cgi | File | 3.55 KB | 0755 |
|
update.pl | File | 3.71 KB | 0755 |
|
update_sched.cgi | File | 1.98 KB | 0755 |
|
upgrade.cgi | File | 9.81 KB | 0755 |
|
usermin-lib.pl | File | 26.86 KB | 0755 |
|