unifi headless macOS

Unifi is a great system. I’ve had a UniFi AP since about 2010 and they have been rock solid for my use. They are the go to recommendation when someone asks me about improving their wifi at their home.

The controller is great and I always like to run my headless on a Mac rather than run it when I need it. It’s just one less thing to think about.

Do this on a macOS is interesting, my favourite way to achieve this is through LaunchDaemons which means it will start before someone is logged in.

Ubiquiti used to bundle java with the installation but that changed and so I thought I’d document how I point to java with a plist and get it to run on startup.

<?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>KeepAlive</key>
	<true/>
	<key>Label</key>
	<string>com.unifi.controller.service.plist</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java</string>
		<string>-Djava.awt.headless=true</string>
		<string>-Xmx1024M</string>
		<string>-jar</string>
		<string>/Applications/UniFi.app/Contents/Resources/lib/ace.jar</string>
		<string>start</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>WorkingDirectory</key>
	<string>/Applications/UniFi.app/Contents/Resources</string>
</dict>
</plist>

The line below is the one that allows the plist to know where java. I used to have to go in here and change it each time the bundled version changed. This is so much easier!

<string>/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java</string>

Thanks to this website that is no longer available for helping with this.

Once you have saved this file. Place it in the /Library/LaunchDaemons folder.

You will have to change the owner to root:wheel

sudo chown root:wheel /Library/LaunchDaemons/com.unifi.controller.service.plist 

Then go ahead and launch it. Check out this website for information on launchctl.

sudo launchctl load -w /Library/LaunchDaemons/com.unifi.controller.service.plist 

If you ever need to stop it use this command.

sudo launchctl unload /Library/LaunchDaemons/com.unifi.controller.service.plist 

Now whenever your machine restarts the unifi controller will startup at boot up too and be available at https://localhost:8443


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.