From 95295ac86170e99aa559ef59ab5d23baff68f12e Mon Sep 17 00:00:00 2001 From: jim-p Date: Tue, 6 Oct 2009 23:15:48 -0400 Subject: More changes to avahi to hopefully make it more nanobsd-friendly. --- config/avahi/avahi.inc | 61 ++++++++++++++++++++++++++++++++------------------ config/avahi/avahi.xml | 59 +++++++++++++++++++++++++----------------------- pkg_config.7.xml | 2 +- pkg_config.8.xml | 2 +- 4 files changed, 72 insertions(+), 52 deletions(-) diff --git a/config/avahi/avahi.inc b/config/avahi/avahi.inc index 2c1ce25f..a89b5da2 100644 --- a/config/avahi/avahi.inc +++ b/config/avahi/avahi.inc @@ -4,7 +4,7 @@ $Id$ avahi.inc part of pfSense (http://www.pfSense.com) - Copyright (C) 2009 Scott Ullrich + Copyright (C) 2009 Scott Ullrich, Jim Pingle All rights reserved. Redistribution and use in source and binary forms, with or without @@ -29,24 +29,24 @@ POSSIBILITY OF SUCH DAMAGE. */ -function start_avahi() { - mwexec_bg("sh /usr/local/etc/rc.d/avahi-daemon.sh start"); +function avahi_start() { + mwexec_bg("/usr/local/etc/rc.d/avahi-daemon.sh start"); } -function stop_avahi() { - mwexec_bg("sh /usr/local/etc/rc.d/avahi-daemon.sh stop"); +function avahi_stop() { + mwexec_bg("/usr/local/etc/rc.d/avahi-daemon.sh stop"); } -function setup_avahi() { +function avahi_install() { global $g, $config; - - // Make image RW conf_mount_rw(); + exec("mkdir -p /usr/local/etc/avahi/services/"); + exec("mv /usr/local/etc/avahi/*.service /usr/local/etc/avahi/services/"); // Extract out libraries and avahi-daemon - if(file_exists("/tmp/avahi.tgz")) { - exec("/usr/bin/tar xzPf /tmp/avahi.tgz -C /"); - unlink("/tmp/avahi.tgz"); + if(file_exists("/root/avahi.tgz")) { + exec("/usr/bin/tar xzPUf /root/avahi.tgz -C /"); + unlink("/root/avahi.tgz"); } // Make sure everthing was extracted @@ -55,6 +55,19 @@ function setup_avahi() { return; } + // Add needed users and groups + exec("/usr/sbin/pw useradd avahi"); + exec("/usr/sbin/pw groupadd avahi"); + + // Make image RO + conf_mount_ro(); +} + +function avahi_write_config() { + global $g, $config; + // Make image RW + conf_mount_rw(); + // Pull some various values out of config.xml $hostname = $config['system']['hostname']; $domain = $config['system']['domain']; @@ -62,16 +75,6 @@ function setup_avahi() { $browsedomains = $config['installedpackages']['avahi']['config'][0]['browsedomains']; $denyif = $config['installedpackages']['avahi']['config'][0]['denyinterfaces']; - // Is package disabled? - if ((!$enable) && file_exists("/usr/local/etc/rc.d/avahi-daemon.sh")) { - stop_avahi(); - return; - } - - // Add needed users and groups - exec("/usr/sbin/pw useradd avahi"); - exec("/usr/sbin/pw groupadd avahi"); - // No supplied domains? Use the defaults. if(!$browsedomains) $browsedomains = "local, 0pointer.de, zeroconf.org"; @@ -162,7 +165,21 @@ EOF; ); // Make image RO conf_mount_ro(); - start_avahi(); + +} + +function avahi_sync() { + global $g, $config; + + avahi_stop(); + + avahi_write_config(); + + // Is package enabled? + if (isset($config['installedpackages']['avahi']['config'][0]['enable']) + && file_exists("/usr/local/etc/rc.d/avahi-daemon.sh")) { + avahi_start(); + } } ?> diff --git a/config/avahi/avahi.xml b/config/avahi/avahi.xml index 21d60576..da0e05fb 100644 --- a/config/avahi/avahi.xml +++ b/config/avahi/avahi.xml @@ -1,7 +1,8 @@ + + Services: Avahi avahi 1.0 - Services: Avahi + Save + /usr/local/pkg/avahi.inc Avahi Modify avahi settings. @@ -42,29 +45,9 @@ avahi - avahi.sh - avahi + avahi-daemon.sh + avahi-daemon - - /tmp/ - 0755 - http://www.pfsense.org/packages/config/avahi/binaries/avahi.tgz - - - /usr/local/pkg/ - 0755 - http://www.pfsense.org/packages/config/avahi/avahi.inc - - - /usr/local/etc/avahi/ - 0755 - http://www.pfsense.org/packages/config/avahi/services/ssh.service - - - /usr/local/etc/avahi/ - 0755 - http://www.pfsense.org/packages/config/avahi/services/sftp-ssh.service - Enable @@ -86,14 +69,34 @@ true + + /tmp/ + 0755 + http://www.pfsense.org/packages/config/avahi/binaries/avahi.tgz + + + /usr/local/pkg/ + 0755 + http://www.pfsense.org/packages/config/avahi/avahi.inc + + + /usr/local/etc/avahi/ + 0755 + http://www.pfsense.org/packages/config/avahi/services/ssh.service + + + /usr/local/etc/avahi/ + 0755 + http://www.pfsense.org/packages/config/avahi/services/sftp-ssh.service + + + avahi_sync(); + - exec("mkdir -p /usr/local/etc/avahi/services/"); - exec("mv /usr/local/etc/avahi/*.service /usr/local/etc/avahi/services/"); - setup_avahi(); + avahi_install(); unlink_if_exists("/usr/local/etc/rc.d/avahi-daemon.sh"); exec("killall avahi-daemon"); - /usr/local/pkg/avahi.inc diff --git a/pkg_config.7.xml b/pkg_config.7.xml index e2d2790f..2af136bf 100755 --- a/pkg_config.7.xml +++ b/pkg_config.7.xml @@ -57,7 +57,7 @@ Avahi is a system which facilitates service discovery on a local network. This means that you can plug your laptop or computer into a network and instantly be able to view other people who you can chat with, find printers to print to or find files being shared. This kind of technology is already found in Apple MacOS X (branded Rendezvous, Bonjour and sometimes Zeroconf) and is very convenient. Avahi is mainly based on Lennart Poettering's flexmdns mDNS implementation for Linux which has been discontinued in favour of Avahi. Network Management http://files.pfsense.org/packages/7/All/ - 0.6.25 + 0.6.25_1 ALPHA 1.2.3 http://www.pfsense.com/packages/config/avahi/avahi.xml diff --git a/pkg_config.8.xml b/pkg_config.8.xml index b71d6280..d4d9c00f 100755 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -59,7 +59,7 @@ Avahi is a system which facilitates service discovery on a local network. This means that you can plug your laptop or computer into a network and instantly be able to view other people who you can chat with, find printers to print to or find files being shared. This kind of technology is already found in Apple MacOS X (branded Rendezvous, Bonjour and sometimes Zeroconf) and is very convenient. Avahi is mainly based on Lennart Poettering's flexmdns mDNS implementation for Linux which has been discontinued in favour of Avahi. Network Management http://files.pfsense.org/packages/7/All/ - 0.6.25 + 0.6.25_1 ALPHA 1.2.3 http://www.pfsense.com/packages/config/avahi/avahi.xml -- cgit v1.2.3