From cb01726c5a6b7572a36d3552ca4e4e1bc50dfc12 Mon Sep 17 00:00:00 2001 From: jim-p Date: Mon, 30 Apr 2012 15:32:47 -0400 Subject: Move the stop_packages code to a function, and call the function from the shell script, and call the function directly for a reboot. Fixes #2402 and ticket #1564 --- etc/inc/pkg-utils.inc | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'etc/inc/pkg-utils.inc') diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc index feb0fab..69fdab2 100644 --- a/etc/inc/pkg-utils.inc +++ b/etc/inc/pkg-utils.inc @@ -1247,4 +1247,48 @@ function pkg_reinstall_all() { } } +function stop_packages() { + require_once("config.inc"); + require_once("functions.inc"); + require_once("filter.inc"); + require_once("shaper.inc"); + require_once("captiveportal.inc"); + require_once("pkg-utils.inc"); + require_once("pfsense-utils.inc"); + require_once("service-utils.inc"); + + global $config, $g, $rcfileprefix; + + log_error("Stopping all packages."); + + $rcfiles = glob("{$rcfileprefix}*.sh"); + if (!$rcfiles) + $rcfiles = array(); + else { + $rcfiles = array_flip($rcfiles); + if (!$rcfiles) + $rcfiles = array(); + } + + if (is_array($config['installedpackages']['package'])) { + foreach($config['installedpackages']['package'] as $package) { + echo " Stopping package {$package['name']}..."; + stop_service($package['name']); + unset($rcfiles["{$rcfileprefix}{$package['name']}.sh"]); + echo "done.\n"; + } + } + + $shell = @popen("/bin/sh", "w"); + if ($shell) { + foreach ($rcfiles as $rcfile => $number) { + echo " Stopping {$rcfile}..."; + fwrite($shell, "{$rcfile} stop >>/tmp/bootup_messages 2>&1"); + echo "done.\n"; + } + + pclose($shell); + } +} + ?> -- cgit v1.1