Jump to content
dlmh

HOW-TO : Samba announced over Avahi with unRAID

54 posts in this topic Last Reply

Recommended Posts

I've spent the better part of two days trying to get Avahi (Zeroconf/Bonjour) to work on unRAID and I thought I'd share my experiences with all Mac users. The following walkthrough is a work in progress and will be updated as progress is being made.

 

[1] Packages

First of all you need to download the Avahi package:

 

avahi-0.6.25-i486-1as.tgz

 

And three important dependancy packages.

 

libcap-2.14-i486-1.tgz
dbus-1.2.6-i486-1.tgz
gcc-4.2.4-i486-1.tgz

 

You can find these packages by typing in the names of these files in your preferred search engine, Google did the trick for me. Install these packages, when in terminal, with the following command

 

installpkg [package_name]

 

in no specific order, but installing Avahi last seems most bulletproof to me.

 

[2] The Samba service

The standard Avahi installation will only give you announcements of SFTP/SSH services, not Samba. To get this done, you'll have to add a service for Samba to Avahi by creating a

.service

file in

/etc/avahi/services/

, e.g.

samba.service

, but you can change this freely as long as you respect the suffix. This file can be created by calling

 

vi /etc/avahi/services/[service_name].service

1

 

and should contain the following:

 

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<service-group>
   <name replace-wildcards="yes">%h</name>
   <service>
       <type>_smb._tcp</type>
       <port>139</port>
   </service>
   <service>
        <type>_device-info._tcp</type>
        <port>0</port>
        <txt-record>model=Xserve</txt-record>
   </service>
</service-group>

 

The second service described in this file will announce your server as an XServe and will show it's icon in Finder accordingly.

 

[3] The Daemon

 

The Avahi daemon uses the DBUS-daemon to operate so latter should be started with:

 

/usr/bin/dbus-daemon --system

 

Now (re)start the Avahi service to load the Samba service:

 

/etc/rc.d/rc.avahidaemon restart

 

If all went correctly your server should now show up in Finder as "Tower".

 

 

[4] Loading the service on startup and GO-script

 

The GO-script is run last, after the System, Single User and Multi-User scripts have been called and can be found at

/config/

when mounted over network, or

/boot/config/

when using the terminal on the server, and is simply called

GO

. This script is no different than any other unix script and as such uses the same syntax for declaring functions and calling methods and/or variables*.

 

On boot you'll have to copy the config files to their proper destination ("/etc/avahi/services" in this specific example) and restart the service or process if necessary3.

 

The GO script will look something like this:

 

#!/bin/bash^M
# Start the Management Utility^M
/usr/local/sbin/emhttp &^M

# Start Avahi
echo "Installing Avahi dependencies..."
installpkg /boot/packages/libcap-2.14-i486-1.tgz >null
installpkg /boot/packages/dbus-1.2.6-i486-1.tgz >null
installpkg /boot/packages/gcc-4.2.4-i486-1.tgz >null
installpkg /boot/packages/avahi-0.6.25-i486-1as.tgz >null

echo "Starting Avahi daemon..."
cp /boot/configfiles/samba.service /etc/avahi/services/
/usr/bin/dbus-daemon --system
/etc/rc.d/rc.avahidaemon restart >null

 

assuming you've created the folders

packages

and

configfiles

at the root of the flash drive 2 and copied the required packages and configuration files accordingly.

 

* I will not get into this subject as it's out of scope of this HOW-TO, even more so than the other footnotes on some of the actions required to install Avahi. Do some research on *nix scripts of your own if you wish to learn more about this or if you wish to beautify or simplify.

 

1: About editing files in terminal

 

I prefer using

vim

on OSX, but you can even use

TextEdit.app

as long as the file is saved in the proper format. For the ones unfamiliar with

vi

: after you have opened the file with above command press

i

(insert) to start editing and press

escape

to quit editing. Now type

:w

to write the file, then

:q

to exit to terminal, or simply

:wq

to do this immediately. If you made any changes to the file after invoking

:w

and wish to discard these, use

:q!

and the program will be exited, no questions asked (but don't forget to quit editing first by pressing

escape

).

 

2: Permanent storage of packages and configuration files

 

The only place you are able to store files permanently on the flash disk is

/boot

, assuming you are in the terminal of the unRAID server, or in the root

/

of the flash disk, including subfolders, if mounted directly or over network (the disk share called

flash

). You can save these files on the disk array as well, but you might want to keep these on the flash disk in the event something happens to the array.

 

As an example, I have two folders in the root of the flash drive called

packages

and

configfiles

, containing packages I need for SabNZBd and Avahi, respectively configuration files I need to get the latter going. These folders can be accessed by

/boot/packages

and

/boot/configfiles

respectively, when in terminal, or

/packages

and

/configfiles

when mounted directly or over network.

 

3: Services

Some of the services I've encountered so far will create a executable in

/etc/rc.d/

with the prefix

RC.

in their respective filename, and can be started by calling

/etc/rc.d/RC.[service_name] start

and restarted by

/etc/rc.d/RC.[service_name] restart

. Restarting the service will sometimes be necessary to have changes made in the configuration take effect. In this case, the Avahi daemon will have to be restarted to load the service declared by

samba.service

.

 

Share this post


Link to post

Okay I followed the instructions....

 

echo "Installing Avahi dependencies..."
installpkg /boot/packages/libcap-2.14-i486-1.tgz >null
installpkg /boot/packages/dbus-1.2.6-i486-1.tgz >null
installpkg /boot/packages/gcc-4.2.4-i486-1.tgz >null
installpkg /boot/packages/avahi-0.6.25-i486-62.1.tgz >null

echo "Starting Avahi daemon..."
cp /boot/configfiles/samba.service /etc/avahi/services/
/usr/bin/dbus-daemon --system
/etc/rc.d/rc.avahidaemon restart >null

 

but after running /usr/bin/dbus-daemon --system it returns the following error Failed to start message bus: Could not get UID and GID for username "messagebus"

Share this post


Link to post

Looking for some assistance.

 

AVAHI working as promised using the instructions above. Thank you everyone.

 

Here's the rub. When I turn on User Level Sharing the AVAHI services stop. I can no longer access the Tower shares in the Finder. Turn off User Level Sharing, and then Tower is visible.

 

Any thoughts out there?

Share this post


Link to post

Okay I followed the instructions....

 

echo "Installing Avahi dependencies..."
installpkg /boot/packages/libcap-2.14-i486-1.tgz >null
installpkg /boot/packages/dbus-1.2.6-i486-1.tgz >null
installpkg /boot/packages/gcc-4.2.4-i486-1.tgz >null
installpkg /boot/packages/avahi-0.6.25-i486-62.1.tgz >null

echo "Starting Avahi daemon..."
cp /boot/configfiles/samba.service /etc/avahi/services/
/usr/bin/dbus-daemon --system
/etc/rc.d/rc.avahidaemon restart >null

 

but after running /usr/bin/dbus-daemon --system it returns the following error Failed to start message bus: Could not get UID and GID for username "messagebus"

 

Something probably went wrong when trying to create the user in the

/etc/passwd

file. Remove the

>null

at the end of every line and check the log.

 

You could try and create the messagebus user yourself and see if this fixes the problem.

Share this post


Link to post

Looking for some assistance.

 

AVAHI working as promised using the instructions above. Thank you everyone.

 

Here's the rub. When I turn on User Level Sharing the AVAHI services stop. I can no longer access the Tower shares in the Finder. Turn off User Level Sharing, and then Tower is visible.

 

Any thoughts out there?

 

Please elaborate. Do you see the share in Finder, but you're unable to access it? Or does it disappear from the sidebar?

Share this post


Link to post

Okay I followed the instructions....

 

echo "Installing Avahi dependencies..."
installpkg /boot/packages/libcap-2.14-i486-1.tgz >null
installpkg /boot/packages/dbus-1.2.6-i486-1.tgz >null
installpkg /boot/packages/gcc-4.2.4-i486-1.tgz >null
installpkg /boot/packages/avahi-0.6.25-i486-62.1.tgz >null

echo "Starting Avahi daemon..."
cp /boot/configfiles/samba.service /etc/avahi/services/
/usr/bin/dbus-daemon --system
/etc/rc.d/rc.avahidaemon restart >null

 

but after running /usr/bin/dbus-daemon --system it returns the following error Failed to start message bus: Could not get UID and GID for username "messagebus"

 

Something probably went wrong when trying to create the user in the

/etc/passwd

file. Remove the

>null

at the end of every line and check the log.

 

You could try and create the messagebus user yourself and see if this fixes the problem.

Actually, you have a small syntax error in your set of commands.  If you wanted to throw away the output of the installpkg commands, the output should be sent to

/dev/null

 

Sending it to "null" will simply create a file in the current directory named "null"  Since you used a single ">" for the redirection of the output, the file will contain the output of the /etc/rc.d/rc.avahidaemon restart command.

Share this post


Link to post

Actually, you have a small syntax error in your set of commands.   If you wanted to throw away the output of the installpkg commands, the output should be sent to

/dev/null

 

Sending it to "null" will simply create a file in the current directory named "null"   Since you used a single ">" for the redirection of the output, the file will contain the output of the /etc/rc.d/rc.avahidaemon restart command.

 

You're right... as usual... still doesn't fix the problem though ;)

Share this post


Link to post

Any new version for avahi and the required packages or are the mentioned above still the latest/recommended for unRAID 4.5? Thanks!

Share this post


Link to post

Any new version for avahi and the required packages or are the mentioned above still the latest/recommended for unRAID 4.5? Thanks!

Avahi hasn't been updated since april 2009, Netatalk just released an update to 2.0.5. However, there's no package available for Slackware, so you'll either have to compile it yourself or wait for Slackware to build one.

 

But it works as it is, why fix it? ;)

 

Edit: the new Netatalk release now supports TimeMachine by default. That's a nice feature for some... :)

 

Edit2: Ow, I'm sorry... this wasn't the AFP tutorial  ::)

Share this post


Link to post

I also have the following error:

 

WARNING: No NSS support for mDNS detected, consider installing nss-mdns!

Jan  6 13:48:26 Nas avahi-daemon[12966]: dbus_bus_get_private(): Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory

Jan  6 13:48:26 Nas avahi-daemon[12966]: WARNING: Failed to contact D-Bus daemon.

 

Do you know what might be the cause?

Share this post


Link to post

I also have the following error:

 

WARNING: No NSS support for mDNS detected, consider installing nss-mdns!

Jan  6 13:48:26 Nas avahi-daemon[12966]: dbus_bus_get_private(): Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory

Jan  6 13:48:26 Nas avahi-daemon[12966]: WARNING: Failed to contact D-Bus daemon.

 

Do you know what might be the cause?

 

Did you install the DBUS package and started it with

/usr/bin/dbus-daemon --system

?

 

The mDNS error is nothing to worry about, everything works perfectly without it.

Share this post


Link to post

yes, dbus is installed and started with /usr/bin/dbus-daemon --system.

As you can see in my GO script, the Avahi daemon should also be restarted:

/etc/rc.d/rc.avahidaemon restart

Share this post


Link to post

I disabled dbus in avahi-daemon.conf and now it seems to work. Should the individual user shares show up in the sidebar or only "Tower" under Shared?

Share this post


Link to post

I disabled dbus in avahi-daemon.conf and now it seems to work. Should the individual user shares show up in the sidebar or only "Tower" under Shared?

 

Yes, that works too... . In your sidebar, you will only find the name of your unRAID box. If you select it you will be asked for your credentials and then the flash drive and every disk and user share that are exported should be listed.

Share this post


Link to post

Tower shows without having avahi. What avahi does is making available (showing or listing on the left in finder) all the shares Tower provides.

 

Edit: This is with Leopard, no idea about Snow Leopard.

Share this post


Link to post

Tower shows without having avahi. What avahi does is making available (showing or listing on the left in finder) all the shares Tower provides.

 

 

I find this to be hit and miss in Snow Leopard. Sometimes Tower would be in the sidebar, other times it would be missing. With Avahi it seems more reliable. My shares don't show up in the sidebar though, only Tower so I have to click on Tower then I see the shares.

 

Roland

Share this post


Link to post

Tower shows without having avahi. What avahi does is making available (showing or listing on the left in finder) all the shares Tower provides.

 

 

I find this to be hit and miss in Snow Leopard. Sometimes Tower would be in the sidebar, other times it would be missing. With Avahi it seems more reliable. My shares don't show up in the sidebar though, only Tower so I have to click on Tower then I see the shares.

 

Roland

 

Really? For me, it never showed up in Finder... the other perk with using Avahi is that you now have a great XServe icon next to your unRAID box! :D And it also announces (S)FTP and SSH ;)

Share this post


Link to post

Looking for some assistance.

 

AVAHI working as promised using the instructions above. Thank you everyone.

 

Here's the rub. When I turn on User Level Sharing the AVAHI services stop. I can no longer access the Tower shares in the Finder. Turn off User Level Sharing, and then Tower is visible.

 

Any thoughts out there?

 

Please elaborate. Do you see the share in Finder, but you're unable to access it? Or does it disappear from the sidebar?

 

To be more concise, I can still access the share in the Finder using Command + K to connect to the samba share. The issue is the XRAID icon in the sidebar disappears from the window.

Share this post


Link to post

I followed the instructions for installing Avahi and Netatalk to the letter. Everything seems to have started up fine, yet I cannot use the unRaid server for Time Machine.

 

It just doesn't show up as an available drive. Has anyone else been able to get Time Machine working, and if so, could post some screen caps of it?

 

Thank you.

Share this post


Link to post

I followed the instructions for installing Avahi and Netatalk to the letter. Everything seems to have started up fine, yet I cannot use the unRaid server for Time Machine.

 

It just doesn't show up as an available drive. Has anyone else been able to get Time Machine working, and if so, could post some screen caps of it?

 

Thank you.

 

Here is another way to do it.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.