aboutsummaryrefslogtreecommitdiffstats
path: root/config/avahi/avahi.inc
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2012-07-05 12:03:58 -0400
committerjim-p <jimp@pfsense.org>2012-07-05 12:03:58 -0400
commitb012ea0f60785020b8f697300fe8e78da2e5e45d (patch)
treef8a6620e87f436a5367a8418e8b55918865ddc2d /config/avahi/avahi.inc
parent1cf2a9f705284e474d721cb31e13db9c67708cad (diff)
downloadpfsense-packages-b012ea0f60785020b8f697300fe8e78da2e5e45d.tar.gz
pfsense-packages-b012ea0f60785020b8f697300fe8e78da2e5e45d.tar.bz2
pfsense-packages-b012ea0f60785020b8f697300fe8e78da2e5e45d.zip
Various fixes for Avahi on 2.1. Fixes #2535
Diffstat (limited to 'config/avahi/avahi.inc')
-rw-r--r--config/avahi/avahi.inc41
1 files changed, 32 insertions, 9 deletions
diff --git a/config/avahi/avahi.inc b/config/avahi/avahi.inc
index 76264ff2..df56cd06 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, Jim Pingle
+ Copyright (C) 2009-2012 Scott Ullrich, Jim Pingle
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -29,6 +29,16 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+$pfs_version = substr(trim(file_get_contents("/etc/version")),0,3);
+switch ($pfs_version) {
+ case "1.2":
+ case "2.0":
+ define('AVAHI_BASE','/usr/local');
+ break;
+ default:
+ define('AVAHI_BASE', '/usr/pbi/avahi-' . php_uname("m"));
+}
+
function avahi_start() {
mwexec_bg("/usr/local/etc/rc.d/avahi-daemon.sh start");
}
@@ -41,17 +51,17 @@ function avahi_install() {
global $g, $config;
conf_mount_rw();
+ // This old hacky install code should only happen on 1.x
if (php_uname("m") == "i386")
$archive = (substr(trim(file_get_contents("/etc/version")),0,1) == "2") ? "" : "avahi.tar.gz";
-
// Extract out libraries and avahi-daemon
if(!empty($archive) && file_exists("/root/{$archive}")) {
- exec("mkdir -p /usr/local/etc/avahi/services/");
- exec("mv /usr/local/etc/avahi/*.service /usr/local/etc/avahi/services/");
+ exec("mkdir -p " . AVAHI_BASE . "/etc/avahi/services/");
+ exec("mv " . AVAHI_BASE . "/etc/avahi/*.service " . AVAHI_BASE . "/etc/avahi/services/");
exec("/usr/bin/tar xzPUf /root/{$archive} -C /");
unlink("/root/{$archive}");
// Make sure everthing was extracted
- if(!file_exists("/usr/local/sbin/avahi-daemon")) {
+ if(!file_exists(AVAHI_BASE . "/sbin/avahi-daemon")) {
log_error("Sorry, something went wrong while extract avahi binaries. Please try the operation again");
return;
}
@@ -146,8 +156,8 @@ rlimit-nproc=3
EOF;
/* Write out .conf file */
- safe_mkdir("/usr/local/etc/avahi");
- $fd = fopen("/usr/local/etc/avahi/avahi-daemon.conf", "w");
+ safe_mkdir(AVAHI_BASE . "/etc/avahi");
+ $fd = fopen(AVAHI_BASE . "/etc/avahi/avahi-daemon.conf", "w");
fwrite($fd, $avahiconfig);
fclose($fd);
/* Write out rc.d startup file */
@@ -156,9 +166,22 @@ EOF;
$start .= " mkdir -p /proc\n";
$start .= " mount -t procfs procfs /proc\n";
$start .= "fi\n";
- $start .= "/usr/local/sbin/avahi-daemon -D\n";
+ $start .= "/usr/bin/killall avahi-daemon\n";
+ if (file_exists(AVAHI_BASE . "/etc/rc.d/dbus")) {
+ $start .= "/usr/bin/killall dbus-daemon\n";
+ $start .= "rm /var/run/dbus/dbus.pid\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";
- $stop = "/usr/bin/killall avahi-daemon";
+
+ $stop = "/usr/bin/killall avahi-daemon\n";
+ if (file_exists(AVAHI_BASE . "/etc/rc.d/dbus")) {
+ $stop .= AVAHI_BASE . "/etc/rc.d/dbus onestop\n";
+ $stop .= "rm /var/run/dbus/dbus.pid\n";
+ }
+
write_rcfile(array(
"file" => "avahi-daemon.sh",
"start" => $start,