OpenWrt Forum Archive

Topic: Avahi XML file for Time Machine

The content of this topic has been archived on 15 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I just updated the OpenWRT Time Machine wiki, making corrections so that it is valid for the final release of Attitude Adjustment (r36088).  The previous version was written for Attitude Adjustment RC1, had a couple of sections that were just unnecessary, and referenced scripts and file locations that don't exist in the current release. 

One of the missing details was in the configuration of Avahi.  As far as I could gather, the best practice is to create an XML file in the /etc/avahi/services directory to allow avahi to advertise the AFP volume.  Based on https://dev.openwrt.org/ticket/12820 and https://dev.openwrt.org/ticket/10245, I created the file /etc/avahi/services/afpd.service with the following:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">Time Capsule</name>
  <service>
    <type>_afpovertcp._tcp</type>
    <port>548</port>
  </service>
  <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <txt-record>model=TimeCapsule</txt-record>
  </service>
  <service>
    <type>_adisk._tcp</type>
    <port>9</port>
    <txt-record>sys=waMA=XX:XX:XX:XX:XX:XX,adVF=0x100</txt-record>
    <txt-record>dk1=adVF=0x83,adVN=TimeMachine</txt-record>
  </service>
</service-group>

where XX:XX:XX:XX:XX:XX is the MAC address of the LAN interface.

Everything works just fine, but I'd like to confirm my approach so that I'm not contributing yet another bad example on how to set up Time Machine (there are enough bad ones already on the web). 

I've found many examples of the first two services of the service-group.  Looking at the code, it seems simple enough and I'm not too concerned about that part of the file.  But I was only able to find a few examples of the last service:

  <service>
    <type>_adisk._tcp</type>
    <port>9</port>
    <txt-record>sys=waMA=XX:XX:XX:XX:XX:XX,adVF=0x100</txt-record>
    <txt-record>dk1=adVF=0x83,adVN=TimeMachine</txt-record>
  </service>

This section of the XML file is required for the disk to show up under the "Select Disk" dialog in the Time Machine Preferences pane.  The MAC address is pretty straightforward, as is "TimeMachine" in the second line (which refers to the name of the volume defined in the netatalk afpd.conf and AppleVolumes.default files).  The "dk1" refers to the disk number, and I've seen "dk0" suggested in at least one example.  Only "dk1" works, so I left it that way.  I have also seen examples that specify the UUID of the disk on another line, but it seems to work just fine without it. 

My problem is that I could not find any documentation on Avahi XML files, much less any details into the "txt-record" lines.  What is required and what is just "nice to have"?  Can anyone point me to documentation on this?

Hi, rdibley:
    Great thanks for your post, i think this wiki is really good, and it could help lots of people who wants to set up a time capsule via OpenWRT.

     I am using a Mercury WM4530R, and the firmware version is OpenWrt Attitude Adjustment 12.09.1 r38621 by Haxc / LuCI 0.11 Branch (0.11+svn9933). I use a USB HUB to connect two usb hard disk to the router.(one is ext4, and the other one is in a GPT, with HFS+ filesystem)

     I just followed your wiki, and do it step by step, every step works fine, but unfortunately, the usb disk didn't work as a time capsule. but i think the usb disk was mounted.
http://www.godiy.net/attachments/month_1401/1401212234d18d9969760c4b41.png

and I will put my file contents below, could you pls help to check if there is any wrong with them?

file:fstab


config global 'automount'
    option from_fstab '1'
    option anon_mount '0'

config global 'autoswap'
    option from_fstab '1'
    option anon_swap '0'

config mount
    option enabled '1'
    option device '/dev/sda1'
    option uuid '3d5c438a-c23d-46bc-9882-37540380b7b1'
    option fstype 'ext4'
    option options 'noatime,data=writeback,barrier=0'
    option enabled_fsck '1'
    option label 'ShareDisk'
    option target '/mnt/sda1'

config mount
    option enabled '1'
    option device '/dev/sdb1'
    option uuid '67E3-17ED'
    option target '/mnt/sda2'
    option fstype 'vfat'
    option options 'iocharset=utf8,utf8=1,umask=000,dmask=000,fmask=000'

config mount
    option enabled '1'
    option device '/dev/sdb2'
    option uuid '9dc824ec-d6af-3079-bc42-551c60e424c3'
    option fstype 'hfsplus'
    option target '/mnt/TimeMachine'
    option label 'TimeMachine'
    option options 'force,rw,sync'
    option enabled_fsck '1'
file:afpd.conf
"TimeMachine" -uampath /usr/lib/uams -uamlist uams_dhx2.so -nodebug -nouservol -icon -nosavepassword -mimicmodel RackMac
file:AppleVolumes.default

/mnt/TimeMachine TimeMachine volsizelimit:74000 allow:@timemachine rwlist:@timemachine cnidscheme:dbd options:searchdb,usedots,invisibledots,tm 
file:avahi-daemon.conf

[server]
host-name=TimeMachine
#domain-name=local
use-ipv4=yes
use-ipv6=no
check-response-ttl=no
use-iff-running=no
enable-dbus=no

[publish]
publish-addresses=yes
publish-hinfo=yes
publish-workstation=no
publish-domain=yes
#publish-dns-servers=192.168.1.1
#publish-resolv-conf-dns-servers=yes

[reflector]
enable-reflector=no
reflect-ipv=no

[rlimits]
#rlimit-as=
rlimit-core=0
rlimit-data=4194304
rlimit-fsize=0
rlimit-nofile=30
rlimit-stack=4194304
rlimit-nproc=3
file:afpd.service

<?xml version="1.0" standalone="no"?> 
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">Time Capsule</name>
  <service>
      <type>_afpovertcp._tcp</type>
      <port>548</port>
  </service>
  <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <txt-record>model=TimeCapsule</txt-record>
  </service>
  <service>
    <type>_adisk._tcp</type>
    <port>9</port>
    <txt-record>sys=waMA=6C:E8:73:FC:CA:A2,adVF=0x100</txt-record> 
    <txt-record>dk1=adVF=0x83,adVN=TimeMachine</txt-record>
  </service>
</service-group>

is there anything wrong with me? why i couldn't get my time capsule work in my OSX Mavericks?

@rdibley, thanks for the wiki. It really helped me get a "time capsule" up & running on OpenWrt.

@w789y, your config looks good to me, except for one thing: The newer block mounting mechanism will not mount a hfsplus volume, so you will have to mount it manually in rc.local with the "mount" command.

If you run the command "block info", you will see all volumes that block-mount recognizes. Notice that your hfsplus volume is not in that list. I first noticed this bug in r38987, though it appears to go back at least 9 months. I still see the bug in r39972 but have not tested beyond that. The ticket is here https://dev.openwrt.org/ticket/14036.

I also posted somewhere here an addendum to my experience following the Time Machine wiki. Let's see... ah, here it is https://forum.openwrt.org/viewtopic.php?id=49137. It shines some light on the places where I got tripped up.

The discussion might have continued from here.