aboutsummaryrefslogtreecommitdiffstats
path: root/config/routed
diff options
context:
space:
mode:
authordoktornotor <notordoktor@gmail.com>2015-11-14 00:52:55 +0100
committerdoktornotor <notordoktor@gmail.com>2015-11-14 00:52:55 +0100
commitcea4d4f8c50edcc79ef7f56818b895a1196aaa94 (patch)
treefba60bc52765a028ac84aeba3c7a5be83f748a6d /config/routed
parent7c927243cda9c8cae152a8f51b7775eb65b2deb1 (diff)
downloadpfsense-packages-cea4d4f8c50edcc79ef7f56818b895a1196aaa94.tar.gz
pfsense-packages-cea4d4f8c50edcc79ef7f56818b895a1196aaa94.tar.bz2
pfsense-packages-cea4d4f8c50edcc79ef7f56818b895a1196aaa94.zip
Improve service handling
- Don't create rc script unless package is enabled - When RIP is disabled in configuration, remove the rc script so that it does not get restarted on reboot - Nuke /etc/gateways on uninstall
Diffstat (limited to 'config/routed')
-rw-r--r--config/routed/routed.inc30
1 files changed, 21 insertions, 9 deletions
diff --git a/config/routed/routed.inc b/config/routed/routed.inc
index 3bcef0aa..c83b0052 100644
--- a/config/routed/routed.inc
+++ b/config/routed/routed.inc
@@ -29,7 +29,6 @@
*/
function setup_routed() {
global $config;
- $gw = "";
if (!is_array($config['installedpackages']['routed'])) {
return;
@@ -37,6 +36,10 @@ function setup_routed() {
if (!is_array($config['installedpackages']['routed']['config'])) {
return;
}
+
+ $gw = "";
+ conf_mount_rw();
+
if (isset($config['installedpackages']['routed']['config'][0]['enable']) &&
$config['installedpackages']['routed']['config'][0]['enable'] == "on") {
/* if user selected individual interfaces */
@@ -55,21 +58,30 @@ function setup_routed() {
/* setup for all interfaces */
$gw = setup_etc_gateways();
}
- conf_mount_rw();
file_put_contents("/etc/gateways", $gw);
- conf_mount_ro();
- restart_service("routed");
+ routed_write_rcfile();
+ if (is_service_running("routed")) {
+ restart_service("routed");
+ } else {
+ start_service("routed");
+ }
} else {
- stop_service("routed");
+ if (is_service_running("routed")) {
+ stop_service("routed");
+ }
+ unlink_if_exists("/etc/gateways");
+ unlink_if_exists("/usr/local/etc/rc.d/routed.sh");
}
+
+ conf_mount_ro();
}
-function setup_etc_gateways($iface="", $mode="") {
+function setup_etc_gateways($iface = "", $mode = "") {
global $config;
$ret = "";
if ($iface != "") {
- $realif=convert_friendly_interface_to_real_interface_name($iface);
+ $realif = convert_friendly_interface_to_real_interface_name($iface);
if (!empty($realif)) {
$ret = "if={$realif} ";
}
@@ -104,7 +116,7 @@ function setup_etc_gateways($iface="", $mode="") {
return $ret;
}
-function routed_install_command() {
+function routed_write_rcfile() {
write_rcfile(array(
"file" => "routed.sh",
"start" => "/usr/bin/nohup /sbin/routed > /dev/null 2>&1 &",
@@ -114,7 +126,7 @@ function routed_install_command() {
}
function routed_deinstall_command() {
- stop_service("routed");
+ unlink_if_exists("/etc/gateways");
unlink_if_exists("/usr/local/etc/rc.d/routed.sh");
}