Skip to content

Commit

Permalink
Merge pull request #7 from doktornotor/patch-5
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-p committed Dec 8, 2015
2 parents 98a4eee + 279c0d6 commit ba7c4ec
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 69 deletions.
2 changes: 1 addition & 1 deletion net/pfSense-pkg-Avahi/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# $FreeBSD$

PORTNAME= pfSense-pkg-Avahi
PORTVERSION= 1.10.3
PORTVERSION= 1.10.4
CATEGORIES= net
MASTER_SITES= # empty
DISTFILES= # empty
Expand Down
91 changes: 42 additions & 49 deletions net/pfSense-pkg-Avahi/files/usr/local/pkg/avahi.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,47 +28,21 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
$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"));
} else {
define('AVAHI_BASE', '/usr/local');
}

function avahi_install() {
if (!file_exists('/usr/local/etc/gnome.subr')) {
@symlink(AVAHI_BASE . '/etc/gnome.subr', '/usr/local/etc/gnome.subr');
}

// Add needed users and groups if they don't exist
if (!exec("/usr/sbin/pw usershow avahi")) {
exec("/usr/sbin/pw useradd avahi -u 558");
}
if (!exec("/usr/sbin/pw groupshow avahi")) {
exec("/usr/sbin/pw groupadd avahi -g 558");
}
}

function avahi_deinstall() {
// Remove created symlink
unlink_if_exists("/usr/local/etc/gnome.subr");

// Remove created users and groups if they exist
if (exec("/usr/sbin/pw groupshow avahi")) {
exec("/usr/sbin/pw groupdel avahi");
}
if (exec("/usr/sbin/pw usershow avahi")) {
exec("/usr/sbin/pw userdel avahi");
}
}
require_once('config.inc');
require_once('interfaces.inc');
require_once('service-utils.inc');
require_once('util.inc');

define('AVAHI_BASE', '/usr/local');

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])) {
$avahi_config = $config['installedpackages']['avahi']['config'][0];
} else {
$avahi_config = array();
}
// Server Options
$hostname = $config['system']['hostname'];
Expand Down Expand Up @@ -107,7 +81,7 @@ function avahi_write_config() {
}
}
}

// Process DNS servers and omit localhost if present in /etc/resolv.conf
$publishdns = '';
$dns = implode(" ", get_dns_servers());
Expand Down Expand Up @@ -174,27 +148,33 @@ EOF;
fwrite($fd, $avahiconfig);
fclose($fd);

/* Write out rc.d startup file */
}

function avahi_write_rcfile() {
global $config;
if (isset($config['installedpackages']['avahi']['config'][0])) {
$avahi_config = $config['installedpackages']['avahi']['config'][0];
} else {
$avahi_config = array();
}

$start = "/etc/rc.conf_mount_rw\n";
$start .= "if [ ! -d /proc/0 ]; then\n";
$start .= " /bin/mkdir -p /proc\n";
$start .= " /sbin/mount -t procfs procfs /proc\n";
$start .= "fi\n";
$start .= "if [ ! -f /usr/local/etc/gnome.subr ]; then\n";
$start .= " /bin/ln -sf " . AVAHI_BASE . "/etc/gnome.subr /usr/local/etc/gnome.subr\n";
$start .= "fi\n";
$start .= "/usr/bin/killall avahi-daemon >/dev/null 2>&1\n";
if (!$avahi_config['disable_dbus']) {
$start .= "if [ ! -d /var/run/dbus ]; then\n";
$start .= " /bin/mkdir /var/run/dbus\n";
$start .= " /usr/sbin/chown messagebus:messagebus /var/run/dbus\n";
$start .= "fi\n";
if (file_exists(AVAHI_BASE . "/etc/rc.d/dbus")) {
$start .= AVAHI_BASE . "/etc/rc.d/dbus onestop\n";
$start .= "/bin/rm /var/run/dbus/dbus.pid >/dev/null 2>&1\n";
$start .= AVAHI_BASE . "/etc/rc.d/dbus onestart\n";
$start .= "sleep 5\n";
}
if (file_exists(AVAHI_BASE . "/etc/rc.d/dbus")) {
$start .= AVAHI_BASE . "/etc/rc.d/dbus onestop\n";
$start .= "/bin/rm /var/run/dbus/dbus.pid >/dev/null 2>&1\n";
$start .= AVAHI_BASE . "/etc/rc.d/dbus onestart\n";
$start .= "sleep 5\n";
}
}
$start .= AVAHI_BASE . "/sbin/avahi-daemon -D\n";
$start .= "/etc/rc.conf_mount_ro\n";
Expand All @@ -213,25 +193,38 @@ EOF;
"stop" => $stop
)
);

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();
if (file_exists("/usr/local/etc/rc.d/dbus")) {
if (!$config['installedpackages']['avahi']['config'][0]['disable_dbus']) {
chmod("/usr/local/etc/rc.d/dbus", 0755);
}
}
start_service("avahi");
} else {
unlink_if_exists("/usr/local/etc/rc.d/avahi-daemon.sh");
if (file_exists("/usr/local/etc/rc.d/dbus")) {
chmod("/usr/local/etc/rc.d/dbus", 0644);
}
}

conf_mount_ro();
}

function avahi_upgrade_config() {
global $config, $avahi_config;
global $config;

$avahi_config =& $config['installedpackages']['avahi']['config'][0];
if (!is_array($avahi_config)) {
Expand Down
12 changes: 3 additions & 9 deletions net/pfSense-pkg-Avahi/files/usr/local/pkg/avahi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,18 @@
</copyright>
<title>Services: Avahi</title>
<name>avahi</name>
<version>1.10.1</version>
<savetext>Save</savetext>
<version>1.10.4</version>
<include_file>/usr/local/pkg/avahi.inc</include_file>
<menu>
<name>Avahi</name>
<tooltiptext>Modify avahi settings.</tooltiptext>
<section>Services</section>
<url>pkg_edit.php?xml=avahi.xml</url>
<url>/pkg_edit.php?xml=avahi.xml</url>
</menu>
<service>
<name>avahi</name>
<rcfile>avahi-daemon.sh</rcfile>
<executable>avahi-daemon</executable>
<description>Avahi zeroconf/mDNS daemon</description>
<description>Avahi Zeroconf/mDNS Daemon</description>
</service>
<additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
Expand Down Expand Up @@ -307,11 +305,7 @@
</custom_php_resync_config_command>
<custom_php_install_command>
avahi_upgrade_config();
avahi_install();
</custom_php_install_command>
<custom_php_deinstall_command>
avahi_deinstall();
</custom_php_deinstall_command>
<custom_php_validation_command>
avahi_validate_input($_POST, $input_errors);
</custom_php_validation_command>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,10 @@
In addition it supports some nifty things that have never been seen elsewhere like correct mDNS reflection across LAN segments.&lt;br/&gt;
Compatible technology is found in Apple MacOS X (branded ​Bonjour and sometimes Zeroconf).]]></descr>
<category>Network Management</category>
<lib_depends>libavahi-core.so:net/avahi-app</lib_depends>
<port_category>net</port_category>
<build_options>avahi_UNSET_FORCE=GTK;cairo_UNSET_FORCE=X11 XCB</build_options>
<build_pbi>
<port>net/avahi</port>
<ports_after>net/avahi-app devel/dbus</ports_after>
</build_pbi>
<depends_on_package_pbi>avahi-0.6.31-##ARCH##.pbi</depends_on_package_pbi>
<version>1.10.3</version>
<version>1.10.4</version>
<status>BETA</status>
<required_version>2.2</required_version>
<config_file>https://packages.pfsense.org/packages/config/avahi/avahi.xml</config_file>
<required_version>2.3</required_version>
<configurationfile>avahi.xml</configurationfile>
<after_install_info>Please visit Services - Avahi menu, enable the service and select which interfaces you do NOT wish Avahi to listen on. Save settings to start the service.</after_install_info>
</package>
Expand Down

0 comments on commit ba7c4ec

Please sign in to comment.