Signs of Triviality

Opinions, mostly my own, on the importance of being and other things.
[homepage] [index] [jschauma@netmeister.org] [@jschauma] [RSS]

Mac OS X: amanda vs. launchd

In order to backup our Mac OS X server to our central backup host and tape library, we installed amanda via pkgsrc. Since pkgsrc needs a case-sensitive filesystem, it lives and installs into a separate volume from the root volume. That is, we have / and /Volumes/pkgsrc, with the amanda daemon installed in /Volumes/pkgsrc/pkg/libexec/amandad. The backup server is set to use tar(1) on this host, since apparently dump(8) does not actually work on OS X (resource forks?). (Note that tar(1) only supports resource forks on OS X since Tiger.) So far, so good.

Now we need to get the amanda daemon to start at boot time automatically. On all other hosts, this is done via inetd:

192.168.0.8:amanda          dgram   udp     wait    backup
/Volumes/pkgsrc/pkg/libexec/amandad amandad  

This can easily be converted into an xinetd(8) file:

service amanda {
	socket_type	= dgram
	protocol	= udp
	wait		= yes
	user		= backup
	group		= operator
	groups		= yes
	server		= /Volumes/pkgsrc/pkg/libexec/amandad
	bind		= 192.168.0.8
	only_from	= 192.168.0.1
}

So far, so good. Starting this manually by kill -HUPing xinetd works fine. However, after rebooting the machine, it no longer works. If I log in and restart xinetd manually, it works. Alright, so I think I'll go the way that Apple really wants me to anyway, and convert this to launchd(8). I create the following /System/Library/LaunchDaemons/amanda.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">
<dict>
	<key>Label</key>
	<string>org.amanda.amanda</string>
	<key>OnDemand</key>

	<true/>
	<key>ProgramArguments</key>
	<array>
		<string>/Volumes/pkgsrc/pkg/libexec/amandad</string>
	</array>

	<key>ServiceDescription</key>
	<string>Amanda Backup Daemon</string>
	<key>Sockets</key>
	<dict>

		<key>Listeners</key>
		<dict>
			<key>SockNodeName</key>
			<string>192.168.0.8</string>

			<key>SockServiceName</key>
			<string>amanda</string>
			<key>SockType</key>
			<string>dgram</string>

		</dict>
	</dict>
	<key>UserName</key>
	<string>backup</string>
	<key>GroupName</key>

	<string>operator</string>
	<key>InitGroups</key>
	<true/>
	<key>inetdCompatibility</key>

	<dict>
		<key>Wait</key>
		<true/>
	</dict>
	<key>StandardOutPath</key>

	<string>/var/amanda/logs/amandad.stdout.log</string>
	<key>StandardErrorPath</key>
	<string>/var/amanda/logs/amandad.stderr.log</string>
</dict>

</plist>
    

I launchctl load /Library/LaunchDaemons/amanda.plist. I see it's listed via launchctl list. I see it's listening via netstat(1). I think I'm golden.

I reboot, and launchd did not start amanda. launchctl list does show it, though. If I launchctl unload it and then launchctl load it again, everything's working.

So after toying around with this for a while, I realize that the problem is that executable (/Volumes/pkgsrc/pkg/libexec/amandad) is located on a different volume than the root volume. And apparently there is no way to tell launchd(8) to mount certain filesystems first the way one might do it using critical_filesystems_local under NetBSD.

So... to get around this, I created a short script called startamanda:

#!/bin/sh
/bin/launchctl unload /System/Library/LaunchDaemons/amanda.plist
/bin/launchctl load /System/Library/LaunchDaemons/amanda.plist
    
and add the following entry to root's crontab:
@reboot /var/root/bin/startamanda
    
This actually seems to work, even though it ain't pretty.

March 16, 2006


[Mac OS X NFS share vs. Garritan Personal Orchestra] [index] [Solaris 10 serial console]