From cea4d4f8c50edcc79ef7f56818b895a1196aaa94 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 14 Nov 2015 00:52:55 +0100 Subject: 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 --- config/routed/routed.inc | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'config') 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"); } -- cgit v1.2.3 From 9b4e6ea4faf59347acafeee547f4c30e1bf10c65 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 14 Nov 2015 00:57:20 +0100 Subject: Add privileges configuration, cleanups --- config/routed/routed.xml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'config') diff --git a/config/routed/routed.xml b/config/routed/routed.xml index b38d7ee3..960cf83b 100644 --- a/config/routed/routed.xml +++ b/config/routed/routed.xml @@ -42,17 +42,23 @@ ]]> routed - 1.2 + 1.2.2 Services: RIP /usr/local/pkg/routed.inc + pkg_edit.php?xml=routed.xml + /usr/local/pkg/ https://packages.pfsense.org/packages/config/routed/routed.inc + + /etc/inc/priv/ + https://packages.pfsense.org/packages/config/routed/routed.priv.inc + RIP
Services
routed.xml - pkg_edit.php?xml=routed.xml&id=0 + pkg_edit.php?xml=routed.xml
routed @@ -117,13 +123,9 @@ checkbox - pkg_edit.php?xml=routed.xml&id=0 setup_routed(); - - routed_install_command(); - routed_deinstall_command(); -- cgit v1.2.3 From a0cbd7e38dca48e01e9b5e52c35fb0ea2e66e528 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 14 Nov 2015 01:00:41 +0100 Subject: Add privileges configuration to routed package --- config/routed/routed.priv.inc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 config/routed/routed.priv.inc (limited to 'config') diff --git a/config/routed/routed.priv.inc b/config/routed/routed.priv.inc new file mode 100644 index 00000000..f0068f81 --- /dev/null +++ b/config/routed/routed.priv.inc @@ -0,0 +1,38 @@ + -- cgit v1.2.3