Skip to content

Instantly share code, notes, and snippets.

@agrlh
Last active March 27, 2024 08:52
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save agrlh/7618ed3e46fb02388022 to your computer and use it in GitHub Desktop.
Save agrlh/7618ed3e46fb02388022 to your computer and use it in GitHub Desktop.
Compiling and installing netatalk 3.1.2 on Debian (used for my RaspberryPi TimeCapsule)

Building and setting up netatalk 3.1.2 on Debian

1. Build

Install dependencies

sudo apt-get install automake libtool build-essential pkg-config checkinstall git-core avahi-daemon libavahi-client-dev libssl-dev libdb5.1-dev db-util db5.1-util libgcrypt11 libgcrypt11-dev libcrack2-dev libpam0g-dev libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev libwrap0-dev systemtap-sdt-dev libacl1-dev libldap2-dev

Download and unpack netatalk 3.1.2

wget http://downloads.sourceforge.net/project/netatalk/netatalk/3.1.2/netatalk-3.1.2.tar.bz2
tar xvf netatalk-3.1.2.tar.bz2

Configure and make

cd netatalk-3.1.2
./configure --with-init-style=debian --with-zeroconf --with-cracklib --with-pam-confdir=/etc/pam.d --with-dbus-sysconf-dir=/etc/dbus-1/system.d

After successfull configuration the configure summary should look like this

Configure summary:
    INIT STYLE:
         debian
    AFP:
         Extended Attributes: ad | sys
         ACL support: yes
         Spotlight: no
    CNID:
         backends:  dbd last tdb
    UAMS:
         DHX     (PAM SHADOW)
         DHX2    (PAM SHADOW)
         RANDNUM (afppasswd)
         clrtxt  (PAM SHADOW)
         guest
    Options:
         Zeroconf support:        yes
         tcp wrapper support:     yes
         quota support:           yes
         admin group support:     yes
         valid shell check:       yes
         cracklib support:        yes
         ACL support:             auto
         Kerberos support:        auto
         LDAP support:            yes
         AFP stats via dbus:      yes
         dtrace probes:           yes
    Paths:
         Netatalk lockfile:       /var/lock/netatalk
         init directory:          /etc/init.d
         dbus system directory:   /etc/dbus-1/system.d
         pam config directory:    /etc/pam.d
    Documentation:
         Docbook:                 no

make

Install

Use the option --fstrans=no to prevent failing of mkdir -p commands during the install.

sudo checkinstall --fstrans=no

2. Setup

Install HFS packages

I am using a USB HDD, which was formatted on my Mac as a HFS+ (journaled) volume. In order to mount and use this drive we have to install the necessary HFS packages:

sudo apt-get install hfsplus hfsutils hfsprogs

Mount the drive

Create the mount destination folder

sudo mkdir /mnt/Backup

Get the drive's UUID

sudo blkid

Add the drive to /etc/fstab

UUID=<UUID from blkid>    /mnt/Backup    hfsplus    force,defaults    0 0

Mount it

sudo mount /mnt/Backup

Set appropriate permissions

sudo chown backup:backup /mnt/Backup
sudo chmod 2775 /mnt/Backup

Netatalk configuration file

The configuration file is found under /usr/local/etc/afp.conf. Make sure to create the folders specified in the path of each volume.

;
; Netatalk 3.x configuration file
;

[Global]
; Global configuration
hostname = Backup
log file = /var/log/netatalk.log
log level = default:info
zeroconf = yes
valid users = @backup
save password = yes
mimic model = TimeCapsule
hosts allow = 192.168.178.0/24

[Backup]
; Backup folder for every user in group 'backup'
path = /mnt/Backup/Backup
valid users = @backup

[TimeMachine A]
; Time Machine folder for user A - limited to 400GB
path = /mnt/Backup/TM-userA
valid users = userA
vol size limit = 381470
time machine = yes

[TimeMachine B]
; Time Machine folder for user B - limited to 200GB
path = /mnt/Backup/TM-userB
valid users = userB
vol size limit = 190735
time machine = yes

Restart netatalk

sudo service netatalk restart

Autostart script

#!/bin/bash
### BEGIN INIT INFO
# Provides:          TimeMachine
# Required-Start:    
# Required-Stop:     
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start TimeMachine.
# Description:       Enable TimeMachine service and mount the drive.
### END INIT INFO

DUUID="<UUID from blkid>"
MNTP="/mnt/Backup"

if [ "$(id -u)" != "0" ]; then
        echo "This script must be run as root" 1>&2
        exit 1
fi
case "$1" in   
   start)
        service netatalk stop
        service avahi-daemon stop
        umount -l $MNTP
        sudo fsck.hfsplus -f `blkid -U $DUUID`
        mount -t hfsplus -o force `blkid -U $DUUID` $MNTP
        service avahi-daemon start
        service netatalk start
      ;;
   stop)
        service netatalk stop
        service avahi-daemon stop
        umount -l $MNTP
      ;;
   *)
        echo "Usage: /etc/init.d/TimeMachine {start|stop}"
        exit 1
    ;;
esac
exit 0
@NucleaPeon
Copy link

NucleaPeon commented Feb 3, 2024

With Debian 12 Bookworm, I used this command to install dependencies:

apt-get install automake libtool build-essential pkg-config checkinstall git-core avahi-daemon libavahi-client-dev libssl-dev libdb5.3-dev db-util db5.3-util libgcrypt20 libgcrypt20-dev libcrack2-dev libpam0g-dev libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev libwrap0-dev systemtap-sdt-dev libacl1-dev libldap2-dev libevent-dev

To configure:

./configure --with-init-style=debian-systemd --enable-zeroconf --with-cracklib --with-pam-confdir=/etc/pam.d --with-dbus-sysconf-dir=/etc/dbus-1/system.d

(Note: -enable-zeroconf and --with-init-style parameters)

I was able to make and make install successfully with no errors.

I'll also note that with systemd, enabling the service is:

systemctl enable netatalk
systemctl start netatalk

and to restart:
systemctl restart netatalk once config file has been edited (same place)

@rwb196884
Copy link

This didn't work for me. make all fails:

root@calleva:~/netatalk# make all
make  all-recursive
make[1]: Entering directory '/root/netatalk'
Making all in include
make[2]: Entering directory '/root/netatalk/include'
Making all in atalk
make[3]: Entering directory '/root/netatalk/include/atalk'
make  all-am
make[4]: Entering directory '/root/netatalk/include/atalk'
make[4]: Nothing to be done for 'all-am'.
make[4]: Leaving directory '/root/netatalk/include/atalk'
make[3]: Leaving directory '/root/netatalk/include/atalk'
make[3]: Entering directory '/root/netatalk/include'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/root/netatalk/include'
make[2]: Leaving directory '/root/netatalk/include'
Making all in libatalk
make[2]: Entering directory '/root/netatalk/libatalk'
Making all in acl
make[3]: Entering directory '/root/netatalk/libatalk/acl'
  CCLD     libacl.la
ar: /root/netatalk/libatalk/acl/.libs/libacl.a: No such file or directory
make[3]: *** [Makefile:482: libacl.la] Error 9
make[3]: Leaving directory '/root/netatalk/libatalk/acl'
make[2]: *** [Makefile:633: all-recursive] Error 1
make[2]: Leaving directory '/root/netatalk/libatalk'
make[1]: *** [Makefile:524: all-recursive] Error 1
make[1]: Leaving directory '/root/netatalk'
make: *** [Makefile:456: all] Error 2
root@calleva:~/netatalk#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment