summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorErmal Luçi <ermal.luci@gmail.com>2012-08-07 03:50:26 -0700
committerErmal Luçi <ermal.luci@gmail.com>2012-08-07 03:50:26 -0700
commit9f310a6384bf636e75e8eeae658e321ef4829bba (patch)
tree9ab342bb2d5934607f2f65ba07304cd60fb5f100 /etc/inc
parentb0c5dd87fd3574b90796c453803cea2d9f721f94 (diff)
parente9d66ed41ee92b139381c70a2dcfe5cf229cd63e (diff)
downloadpfsense-9f310a6384bf636e75e8eeae658e321ef4829bba.zip
pfsense-9f310a6384bf636e75e8eeae658e321ef4829bba.tar.gz
Merge pull request #208 from phildd/master
Change rcfileprefix to a constant
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/pkg-utils.inc10
-rw-r--r--etc/inc/service-utils.inc23
2 files changed, 16 insertions, 17 deletions
diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc
index d8dbdae..d667c12 100644
--- a/etc/inc/pkg-utils.inc
+++ b/etc/inc/pkg-utils.inc
@@ -960,7 +960,7 @@ function delete_package($pkg) {
}
function delete_package_xml($pkg) {
- global $g, $config, $static_output, $pkg_interface, $rcfileprefix;
+ global $g, $config, $static_output, $pkg_interface;
conf_mount_rw();
@@ -1033,7 +1033,7 @@ function delete_package_xml($pkg) {
if($g['booting'] != true)
stop_service($service['name']);
if($service['rcfile']) {
- $prefix = $rcfileprefix;
+ $prefix = RCFILEPREFIX;
if (!empty($service['prefix']))
$prefix = $service['prefix'];
if (file_exists("{$prefix}{$service['rcfile']}"))
@@ -1265,11 +1265,11 @@ function stop_packages() {
require_once("pfsense-utils.inc");
require_once("service-utils.inc");
- global $config, $g, $rcfileprefix;
+ global $config, $g;
log_error("Stopping all packages.");
- $rcfiles = glob("{$rcfileprefix}*.sh");
+ $rcfiles = glob(RCFILEPREFIX . "*.sh");
if (!$rcfiles)
$rcfiles = array();
else {
@@ -1282,7 +1282,7 @@ function stop_packages() {
foreach($config['installedpackages']['package'] as $package) {
echo " Stopping package {$package['name']}...";
stop_service($package['name']);
- unset($rcfiles["{$rcfileprefix}{$package['name']}.sh"]);
+ unset($rcfiles[RCFILEPREFIX . $package['name'] . ".sh"]);
echo "done.\n";
}
}
diff --git a/etc/inc/service-utils.inc b/etc/inc/service-utils.inc
index 01230a1..2a9ca99 100644
--- a/etc/inc/service-utils.inc
+++ b/etc/inc/service-utils.inc
@@ -38,15 +38,15 @@
pfSense_MODULE: utils
*/
-$rcfileprefix = "/usr/local/etc/rc.d/";
+define("RCFILEPREFIX", "/usr/local/etc/rc.d/");
function write_rcfile($params) {
global $g;
- global $rcfileprefix;
- if (!file_exists("{$rcfileprefix}{$params['file']}") && !touch("{$rcfileprefix}{$params['file']}"))
+ $rcfile_fullname = RCFILEPREFIX . $params['file'];
+ if (!file_exists($rcfile_fullname) && !touch($rcfile_fullname))
return false;
- if (!is_writable("{$rcfileprefix}{$params['file']}") || empty($params['start']))
+ if (!is_writable($rcfile_fullname) || empty($params['start']))
return false;
$towrite = "#!/bin/sh\n";
@@ -72,15 +72,14 @@ function write_rcfile($params) {
/* begin rcfile logic */
$towrite .= "case \$1 in\n\tstart)\n\t\trc_start\n\t\t;;\n\tstop)\n\t\trc_stop\n\t\t;;\n\trestart)\n\t\trc_stop\n\t\trc_start\n\t\t;;\nesac\n\n";
- file_put_contents("{$rcfileprefix}{$params['file']}", $towrite);
- @chmod("{$rcfileprefix}{$params['file']}", 0755);
+ file_put_contents($rcfile_fullname, $towrite);
+ @chmod("{$rcfile_fullname}", 0755);
return;
}
function start_service($name) {
global $config;
- global $rcfileprefix;
if (empty($name))
return;
@@ -89,15 +88,16 @@ function start_service($name) {
stop_service($name);
sleep(2);
- if(file_exists("{$rcfileprefix}{$name}.sh")) {
- mwexec_bg("/bin/sh {$rcfileprefix}{$name}.sh start");
+ $rcfile_fullname = RCFILEPREFIX . $name . '.sh';
+ if(file_exists($rcfile_fullname)) {
+ mwexec_bg("/bin/sh {$rcfile_fullname} start");
return;
}
if($config['installedpackages']['service']) {
foreach($config['installedpackages']['service'] as $service) {
if(strtolower($service['name']) == strtolower($name)) {
if($service['rcfile']) {
- $prefix = $rcfileprefix;
+ $prefix = RCFILEPREFIX;
if (!empty($service['prefix'])) {
$prefix =& $service['prefix'];
}
@@ -115,7 +115,6 @@ function start_service($name) {
function stop_service($name) {
global $config;
- global $rcfileprefix;
if (empty($name))
return;
@@ -124,7 +123,7 @@ function stop_service($name) {
foreach($config['installedpackages']['service'] as $service) {
if(strtolower($service['name']) == strtolower($name)) {
if($service['rcfile']) {
- $prefix = $rcfileprefix;
+ $prefix = RCFILEPREFIX;
if(!empty($service['prefix'])) {
$prefix =& $service['prefix'];
}
OpenPOWER on IntegriCloud