summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Beaver <sbeaver@netgate.com>2015-10-15 13:03:15 -0400
committerStephen Beaver <sbeaver@netgate.com>2015-10-15 13:04:08 -0400
commitf16d76c399001ddc75fc6d72e37a8e1b64c05594 (patch)
tree3f45fb0d473a3960e2e56fa8dc38517cce5d795d
parentd1867dd2884a900cbe8abc7278e383ce4f6ea477 (diff)
downloadpfsense-f16d76c399001ddc75fc6d72e37a8e1b64c05594.zip
pfsense-f16d76c399001ddc75fc6d72e37a8e1b64c05594.tar.gz
Added "reinstall all packages" functionality (accessed via diag_backup.php)
-rwxr-xr-xsrc/usr/local/sbin/pfSense-upgrade18
-rw-r--r--src/usr/local/www/pkg_mgr_install.php53
2 files changed, 53 insertions, 18 deletions
diff --git a/src/usr/local/sbin/pfSense-upgrade b/src/usr/local/sbin/pfSense-upgrade
index 280baeb..b314e64 100755
--- a/src/usr/local/sbin/pfSense-upgrade
+++ b/src/usr/local/sbin/pfSense-upgrade
@@ -549,6 +549,17 @@ pkg_delete() {
_exec "pkg autoremove" "Removing stale packages" mute ignore_result
}
+pkg_reinstall_all() {
+ for _pkg in $(pkg query -e '%a == 0' %n); do
+ case "${_pkg}" in
+ "${platform}"-pkg-* )
+ echo reinstalling ${_pkg}
+ pkg_install ${_pkg} 1
+ ;;
+ esac
+ done
+}
+
pid_file="/var/run/$(basename $0).pid"
last_update_file="/var/run/$(basename $0)-last-update"
logfile="/cf/conf/upgrade_log.txt"
@@ -679,7 +690,12 @@ case "${action}" in
pkg_update force
;;
install)
- pkg_install ${action_pkg} ${force}
+ if [ ${action_pkg} == "ALL_PACKAGES" ] && [ -n ${force} ]; then
+ echo "Reinstalling every single package"
+ pkg_reinstall_all
+ else
+ pkg_install ${action_pkg} ${force}
+ fi
;;
delete)
pkg_delete ${action_pkg}
diff --git a/src/usr/local/www/pkg_mgr_install.php b/src/usr/local/www/pkg_mgr_install.php
index c482a79..aaf8a73 100644
--- a/src/usr/local/www/pkg_mgr_install.php
+++ b/src/usr/local/www/pkg_mgr_install.php
@@ -108,13 +108,20 @@ if ($_REQUEST['ajax']) {
// Check to see if our process is still running
$pidfile = $g['varrun_path'] . '/' . $g['product_name'] . '-upgrade.pid';
+ $running = "running";
+ // When we do a reinstallall, it is technically possible that we might catch the system in-between
+ // packages, hence the de-bounce here
if (!isvalidpid($pidfile)) {
- $running = "stopped";
- // The log files may not be complete when the process terminates so we need wait
- waitfor_string_in_file($_REQUEST['logfilename'] . '.txt', "__RC=", 10);
- } else {
- $running = "running";
+ usleep(100000);
+ if (!isvalidpid($pidfile)) {
+ $running = "stopped";
+ // The log files may not be complete when the process terminates so we need wait until we see the
+ // exit status (__RC=x)
+ waitfor_string_in_file($_REQUEST['logfilename'] . '.txt', "__RC=", 10);
+ filter_configure();
+ send_event("service restart packages");
+ }
}
$pidarray = array('pid' => $running);
@@ -303,7 +310,7 @@ if ($_POST['mode'] == 'delete') {
$modetxt = gettext("installation");
}
-if (!empty($_POST['id']) || $_GET['mode'] == 'showlog' || ($_GET['mode'] == 'installedinfo' && !empty($_GET['pkg']))):
+if (!empty($_POST['id']) || $_POST['mode'] == "reinstallall" || $_GET['mode'] == 'showlog' || ($_GET['mode'] == 'installedinfo' && !empty($_GET['pkg']))):
// What if the user navigates away from this page and then come back via his/her "Back" button?
$pidfile = $g['varrun_path'] . '/' . $g['product_name'] . '-upgrade.pid';
@@ -365,25 +372,31 @@ if ($_GET) {
/* Write out configuration to create a backup prior to pkg install. */
write_config(gettext("Creating restore point before package installation."));
+ $progbar = true;
+
switch ($_POST['mode']) {
case 'delete':
- $pid = mwexec('/usr/local/sbin/pfSense-upgrade -l /tmp/webgui-log.txt -p /tmp/webgui-log.sock -r ' . $pkgid, false, false, true);
+ mwexec('/usr/local/sbin/pfSense-upgrade -l /tmp/webgui-log.txt -p /tmp/webgui-log.sock -r ' . $pkgid, false, false, true);
$start_polling = true;
- filter_configure();
break;
case 'reinstallall':
+ if (is_array($config['installedpackages']) && is_array($config['installedpackages']['package'])) {
+ $progbar = false; // We don't show the progress bar for reinstallall. It would be far too confusing
+ mwexec('/usr/local/sbin/pfSense-upgrade -l /tmp/webgui-log.txt -p /tmp/webgui-log.sock -i ' . "ALL_PACKAGES" . ' -f', false, false, true);
+ $start_polling = true;
+ }
+
+ break;
case 'reinstallpkg':
- $pid = mwexec('/usr/local/sbin/pfSense-upgrade -l /tmp/webgui-log.txt -p /tmp/webgui-log.sock -i ' . $pkgid . ' -f', false, false, true);
- filter_configure();
+ mwexec('/usr/local/sbin/pfSense-upgrade -l /tmp/webgui-log.txt -p /tmp/webgui-log.sock -i ' . $pkgid . ' -f', false, false, true);
$start_polling = true;
break;
case 'installed':
default:
- $pid = mwexec('/usr/local/sbin/pfSense-upgrade -l /tmp/webgui-log.txt -p /tmp/webgui-log.sock -i ' . $pkgid, false, false, true);
+ mwexec('/usr/local/sbin/pfSense-upgrade -l /tmp/webgui-log.txt -p /tmp/webgui-log.sock -i ' . $pkgid, false, false, true);
$start_polling = true;
- filter_configure();
break;
}
@@ -413,7 +426,11 @@ function setProgress(barName, percent) {
// Display a success banner
function show_success() {
$('#final').removeClass("alert-info").addClass("alert-success");
- $('#final').html("<?=$pkgid?>" + " " + "<?=$modetxt?>" + " " + "<?=gettext(' successfully completed')?>");
+ if("<?=$progbar?>")
+ $('#final').html("<?=$pkgid?>" + " " + "<?=$modetxt?>" + " " + "<?=gettext(' successfully completed')?>");
+ else
+ $('#final').html("<?=gettext('Reinstallation of all packages successfully completed')?>");
+
$('#final').show();
}
@@ -461,11 +478,13 @@ function getLogsStatus() {
// Update the progress bar
progress = 0;
- if (json.data) {
- setProgress('progressbar', ((json.data.current * 100) / json.data.total));
- progress = json.data.total - json.data.current
- }
+ if("<?=$progbar?>") {
+ if (json.data) {
+ setProgress('progressbar', ((json.data.current * 100) / json.data.total));
+ progress = json.data.total - json.data.current
+ }
+ }
// Now we need to determine if the installation/removal was successful, and tell the user. Not as easy as it sounds :)
if ((json.pid == "stopped") && (progress == 0) && (json.exitstatus == 0)) {
show_success();
OpenPOWER on IntegriCloud