Disclaimer first: this is not really fully tested - I haven't tried restoring from TimeMachine backup yet. So there's a chance that this won't really work in the end.
Described below is the (somewhat convoluted) steps I did to get this working. It would be really nice if someone can clean this up, submit the patch to netatalk, create an Optware netatalk package with proper configuration, and another Optware package for pogoplug/timemachine configuration example files... In theory, it should be possible to make "ipkg install pogoplug-timemachine" just "Do The Right Thing". Anyway, here goes the steps:
1) Install gcc, autoconf, automake, dbus, openssl, avahi, libgcrypt from Optware ipkg (it's possible I might have missed a few packages though).
2) Download berkeleydb source from
here, unzip/untar, and then build/install by:
$ cd db-4.7.25/build_unix
$ ./dist/configure --prefix=/opt --with-gnu-ld
$ make
$ make install
3) Download netatalk source package somehow. I used CVS following
this instruction but it looks like you can download the tarball from
sourceforge as well. Once you download/untar it, you can build/install it by:
$ cd netatalk
$ CFLAGS="-O -DSHADOWPW" CPPFLAGS="-I/opt/include" LDFLAGS="-L/opt/lib -Wl,-rpath,/opt/lib" ./configure --prefix=/opt --with-ssl-dir=/opt/ --with-bdb=/opt/ --with-shadow --with-cnid-cdb-backend --enable-afp3
$ make
$ make install
3-1) If your pogoplug mounted disk is formatted in FAT or NTFS, those disks are mounted as root by pogoplug's daemon (hbplug). So you need afpd to be able to run as root. By default, afpd does not allow this to happen. The patch below fixes that - by adding a new option "-[no]allowroot". If you want that, apply the following patch before doing "make" above (if you don't know what patch is, or what to do with the following file, you probably don't want to do this anyway), but understand that this increases the security exposure:
Index: afp_options.c
===================================================================
RCS file: /cvsroot/netatalk/netatalk/etc/afpd/afp_options.c,v
retrieving revision 1.45
diff -r1.45 afp_options.c
212a213,216
> if (strstr(buf, " -noallowroot"))
> options->flags &= ~OPTION_ALLOW_ROOT;
> if (strstr(buf, " -allowroot"))
> options->flags |= OPTION_ALLOW_ROOT;
Index: auth.c
===================================================================
RCS file: /cvsroot/netatalk/netatalk/etc/afpd/auth.c,v
retrieving revision 1.63
diff -r1.63 auth.c
255c255,256
< if ( pwd->pw_uid == 0 ) { /* don't allow root login */
---
> if (!(obj->options.flags & OPTION_ALLOW_ROOT)
> && pwd->pw_uid == 0 ) { /* don't allow root login */
Index: globals.h
===================================================================
RCS file: /cvsroot/netatalk/netatalk/etc/afpd/globals.h,v
retrieving revision 1.26
diff -r1.26 globals.h
39a40
> #define OPTION_ALLOW_ROOT (1 << 8)
cvs diff: Diffing nls
4) Set up dbus to use avahi, by creating a file /opt/etc/dbus-1/system.d/avahi-dbus.conf with the following content:
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- Only root or user avahi can own the Avahi service -->
<policy user="avahi">
<allow own="org.freedesktop.Avahi"/>
</policy>
<policy user="root">
<allow own="org.freedesktop.Avahi"/>
</policy>
<!-- Allow anyone to invoke methods on Avahi server, except SetHostName -->
<policy context="default">
<allow send_destination="org.freedesktop.Avahi"/>
<allow receive_sender="org.freedesktop.Avahi"/>
<deny send_interface="org.freedesktop.Avahi.Server" send_member="SetHostName"/>
</policy>
<!-- Allow everything, including access to SetHostName to users of the group "netdev"
<policy group="netdev">
<allow send_destination="org.freedesktop.Avahi"/>
<allow receive_sender="org.freedesktop.Avahi"/>
</policy>
-->
</busconfig>
5) Setup avahi to find aftpd by creating a file /opt/etc/avahi/services/aftpd.service with:
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_afpovertcp._tcp</type>
<port>548</port>
</service>
<service>
<type>_device-info._tcp</type>
<port>0</port>
<txt-record>model=Xserve</txt-record>
</service>
</service-group>
And edit /opt/etc/avahi/avahi-daemon.conf and set "host-name" to what you want (you probably want to use a different name than the hostname of pogoplug itself, as using the same would make it a bit more cubersome to use samba and afp simultanenously).
6) Now it's time to configure afpd. Edit /opt/etc/netatalk/afpd.conf and add the following line:
- -transall -uamlist uams_dhx2.so -nosavepassword -allowroot
The key part is "uams_dhx2.so" - as far as I tried, this and uams_guest.so were the only UAMS modules that worked with OSX 10.5.8. "-allowroot" would only work if you applied my patch above.
7) You need to set up with "directory" to be exported. Edit /opt/etc/netatalk/AppleVolumes.default, and add a line like (it's supposed to be in a single line):
/tmp/.cemnt/mnt_sda1/TimeMachine TimeMachine allow:root rwlist:root dbpath:/tmp/cdb.db cnidscheme:cdb options:usedots
This would export /tmp/.cemnt/mnt_sda1/TimeMachine directory as a volume named TimeMachine.
8) Create an empty file named ".com.apple.timemachine.supported" in the top directory of the exported volume you want to use as timemachine. e.g.:
$ touch /tmp/.cemnt/mnt_sda1/TimeMachine/.com.apple.timemachine.supported
9) Start all daemons if they haven't started yet.
$ /opt/etc/init.d/S20dbus start
$ /opt/etc/init.d/afpd start
10) Now you should see a Xserve icon in Finder's network view (Shared -> All). Click it, and it will ask for a login and a password - give it the login and the password for pogoplug. You can use root (if you used the patch above), or you can create your own user but in that case you need that user be able to write to the volume. Once you have mounted the TimeMachine volume (that has .com.apple.timemachine.supported file at the root), the system preference -> TimeMachine -> Change disk should display the pogoplug as a TimeMachine disk:
Now the TimeMachine backup should work, though no guarantee it will restore - my backup is still in progress :)
PS. I used the information from following pages:
and possibly some others which I forget.
There was one website that explained setting up avahi/netatalk very well (where I took some of the config files), but I can't remember or find that site now. So I might be missing a few things related to avahi above :(