From 88c4caddfc59fcd15576625620e872e0a8e0ed6b Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 5 Dec 2015 03:35:19 +0100 Subject: Add missing includes, fix service handling --- config/avahi/avahi.inc | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'config') diff --git a/config/avahi/avahi.inc b/config/avahi/avahi.inc index 04f3b343..cd7099cf 100644 --- a/config/avahi/avahi.inc +++ b/config/avahi/avahi.inc @@ -28,6 +28,11 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +require_once('config.inc'); +require_once('interfaces.inc'); +require_once('service-utils.inc'); +require_once('util.inc'); + $pfs_version = substr(trim(file_get_contents("/etc/version")), 0, 3); if ($pfs_version == "2.1" || $pfs_version == "2.2") { define('AVAHI_BASE', '/usr/pbi/avahi-' . php_uname("m")); @@ -63,8 +68,7 @@ function avahi_deinstall() { } function avahi_write_config() { - global $config, $avahi_config; - conf_mount_rw(); + global $config; // Pull some various values out of config.xml if (isset($config['installedpackages']['avahi']['config'][0])) { @@ -173,8 +177,16 @@ EOF; $fd = fopen(AVAHI_BASE . "/etc/avahi/avahi-daemon.conf", "w"); fwrite($fd, $avahiconfig); fclose($fd); +} + +function avahi_write_rcfile() { + global $config; + if (isset($config['installedpackages']['avahi']['config'][0])) { + $avahi_config = $config['installedpackages']['avahi']['config'][0]; + } else { + $avahi_config = array(); + } - /* Write out rc.d startup file */ $start = "/etc/rc.conf_mount_rw\n"; $start .= "if [ ! -d /proc/0 ]; then\n"; $start .= " /bin/mkdir -p /proc\n"; @@ -214,20 +226,26 @@ EOF; ) ); - conf_mount_ro(); } function avahi_sync() { global $config; + conf_mount_rw(); if (is_service_running("avahi")) { stop_service("avahi"); } avahi_write_config(); + // Is package enabled? if ($config['installedpackages']['avahi']['config'][0]['enable']) { + avahi_write_rcfile(); start_service("avahi"); + } else { + unlink_if_exists("/usr/local/etc/rc.d/avahi-daemon.sh"); } + + conf_mount_ro(); } function avahi_upgrade_config() { -- cgit v1.2.3