mac os x default svn server startup on boot

On My Mac…Mac OS X have svnserve by default.

However, execute svnserve everytime when booted is really tedious job.

Here’s how to.

1. Creating Launch Daemons and Launching Custom Daemons Using launchd
1.1 make text files on /Library/LaunchDaemons/somefile.plist
1.2 edit somefile.plist . Here’s my real example. I named plist file “com.sk.svnserve.plist”

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
		<string>com.sk.svnserve</string>
	<key>ProgramArguments</key>
		<array>
			<string>/usr/bin/svnserve</string>
			<string>-i</string>
			<string>--root=/svnHomeFolder</string>
		</array>
	<key>KeepAlive</key>
		<true/>
	<key>Sockets</key>
  		<dict>
   			<key>Listeners</key>
   			<array>
			<dict>
	 			<key>SockFamily</key>
	 			<string>IPv4</string>
	 			<key>SockServiceName</key>
	 			<string>svn</string>
	 			<key>SockType</key>
	 			<string>stream</string>
			</dict>
			<dict>
	 			<key>SockFamily</key>
	 			<string>IPv6</string>
	 			<key>SockServiceName</key>
	 			<string>svn</string>
	 			<key>SockType</key>
	 			<string>stream</string>
			</dict>
   			</array>
  		</dict>
  	<key>RunAtLoad</key>
  		<true/>
	<key>inetdCompatibility</key>
        <dict>
            <key>Wait</key>
            <false/>
        </dict>
</dict>
</plist>

1.3 Most Important part : do not omit this process

sudo chown root /Library/LaunchDaemons/com.sk.svnserve.plist

 

1.4 Almost done. However, you have to wait until next time you boot up. So, just start the svnserve to check there are any errors

sudo launchctl load /Library/LaunchDaemons/com.sk.svnserve.plist
sudo launchctl start com.sk.svnserve

and also, if there is error. just unload and edit plist file. and repeat 1.4 step.

sudo launchctl unload /Library/LaunchDaemons/com.sk.svnserve.plist

 

2. That’s it.

 

Further reading

Daemons and Services Programming Guide
launchd.plist(5) OS X Manual Page
svnserve(8) OS X Manual Page
How to install a stand-alone SVN Server on Mac OS X 10.6 (Snow Leopard)
Subversion With Mac OS X Tutorial
Subversion server (svnserve) on Mac OS X
Installing SVNserve on Mac OS X
Subversion Scripts for Mac OS X Finder

Some tips

Check if svnserve is working great. Of course you have to unload plist first.

svnserve -d --root=/svnHomeFolder
svnserve -d -r /svnHomeFolder