summaryrefslogtreecommitdiffstats
path: root/etc/inc/pkg-utils.inc
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@world.inf.org>2012-12-14 22:26:19 +0545
committerPhil Davis <phil.davis@world.inf.org>2012-12-14 22:26:19 +0545
commit75a01a7ca066a89f35b337e829c0c44468ea4da8 (patch)
tree5e847ac25767be48c399d15766193992f15d5976 /etc/inc/pkg-utils.inc
parent0d20a0409939738984e42256c7983bcc8f46d445 (diff)
downloadpfsense-75a01a7ca066a89f35b337e829c0c44468ea4da8.zip
pfsense-75a01a7ca066a89f35b337e829c0c44468ea4da8.tar.gz
Support different package internal name
Allow the package external name (e.g. Ipguard-dev or squid3) to be different from the internal name (ipguard or squid). In particular, this allows package start and stop code to know what the associated package service name and/or *.sh start/stop script name is when the external package name is different.
Diffstat (limited to 'etc/inc/pkg-utils.inc')
-rw-r--r--etc/inc/pkg-utils.inc28
1 files changed, 23 insertions, 5 deletions
diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc
index d667c12..87dd0ae 100644
--- a/etc/inc/pkg-utils.inc
+++ b/etc/inc/pkg-utils.inc
@@ -168,6 +168,24 @@ function get_pkg_id($pkg_name) {
return -1;
}
+/****f* pkg-utils/get_pkg_internal_name
+ * NAME
+ * get_pkg_internal_name - Find a package's internal name (e.g. squid3 internal name is squid)
+ * INPUTS
+ * $package - array of package data from config
+ * RESULT
+ * string - internal name (if defined) or default to package name
+ ******/
+function get_pkg_internal_name($package) {
+ if (isset($package['internal_name']) && ($package['internal_name'] != "")) {
+ /* e.g. name is Ipguard-dev, internal name is ipguard */
+ $pkg_internal_name = $package['internal_name'];
+ } else {
+ $pkg_internal_name = $package['name'];
+ }
+ return $pkg_internal_name;
+}
+
/****f* pkg-utils/get_pkg_info
* NAME
* get_pkg_info - Retrieve package information from pfsense.com.
@@ -240,7 +258,7 @@ function resync_all_package_configs($show_message = false) {
echo " " . $package['name'];
get_pkg_depends($package['name'], "all");
if($g['booting'] != true)
- stop_service($package['name']);
+ stop_service(get_pkg_internal_name($package));
sync_package($idx, true, true);
if($pkg_interface == "console")
echo "\n" . gettext("Syncing packages:");
@@ -356,10 +374,9 @@ function uninstall_package($pkg_name) {
}
}
- stop_service($pkg_name);
-
$id = get_pkg_id($pkg_name);
if ($id >= 0) {
+ stop_service(get_pkg_internal_name($config['installedpackages']['package'][$id]));
$pkg_depends =& $config['installedpackages']['package'][$id]['depends_on_package_pbi'];
$static_output .= "Removing package...\n";
update_output_window($static_output);
@@ -1281,8 +1298,9 @@ function stop_packages() {
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"]);
+ $internal_name = get_pkg_internal_name($package);
+ stop_service($internal_name);
+ unset($rcfiles[RCFILEPREFIX . strtolower($internal_name) . ".sh"]);
echo "done.\n";
}
}
OpenPOWER on IntegriCloud