Reply
Emerging Member
Falcon
Posts: 46
Registered: ‎09-15-2010
Posts: 46
Registered: 09-15-2010

How to run AirControl as a service under Mac OS X

After my previous linux based OpenNMS/Aircontrol machine bit the dust recently I ended up using a Mac Mini running Mac OS X 10.6.7 as my new stats-gathering/monitoring server.
However I did not want to be manually running Aircontrol whenever the system restarts, I wanted it to start up as a service when the machine boots, including when I do not log in as a user! Using this page about running tomcat as a template this is how I got it working:
1) Download the generic tarball for AirControl, unzip and move the aircontrol folder to the location of your choice. I decided to stick it in "/Applications/AirControl", the more traditional location would probably be "/usr/share/aircontrol". Both should work.
2) Check conf/catalina.properties to ensure the AirControl settings are sane (just as the README file tells you to do!). Edit: As pointed out by Paetur if you are using OS X server in order to avoid a conflict with iCal server you should change the HTTPS port from default to port 9443 (change the line to read "ubnt.https.port=9443").
3) Edit bin/catalina.sh and add the following lines just under the commented out section near the top.
CATALINA_OPTS="-Xmx1024M -server"
JAVA_HOME=`/usr/libexec/java_home`
JAVA_OPTS="-Djava.awt.headless=true"

- The first line, as per the README, is to limit the memory java will use. I do not have very many devices so I have it set to 512M rather then 1024M.
- The second line is the proper way to set the JAVA_HOME environment variable under Mac OS X 10.6 (and possibly 10.5). It runs the application "java_home" that then outputs the correct directory of the currently installed JVM. This means your JAVA_HOME setting will survive software update moving things! :manhappy:
- The third line makes sure the bootstrap.jar process does not try and create a (totally useless) GUI frontend. This is needed or AirControl is unable run at system boot.
4) Create a LaunchDaemon descriptor so launchd will properly run AirControl on system boot.
a) Open up TextEdit with new blank document, go to the Format menu and select Make Plain Text.
b) Into the blank text file insert the following:




Disabled

Label
com.ubiquity.aircontrol
ProgramArguments

/Applications/AirControl/bin/catalina.sh
run

RunAtLoad

ServiceDescription
Ubiquity AirControl Server


Note this text assumes you installed aircontrol in the same place I did, if you did not edit accordingly!!
c) Save the file to your desktop with the name "com.ubiquity.aircontrol.plist". Quit TextEdit
d) open up Terminal and run the following two commands to put the file in the correct place with the correct permissions:
sudo mv ~/Desktop/com.ubiquity.aircontrol.plist /Library/LaunchDaemons/
sudo chown root:wheel /Library/LaunchDaemons/com.ubiquity.aircontrol.plist

Reboot and you should now have AirControl running properly at startup. This works even if you do not have the system auto-login.
Let me know if you spot any errors/improvements or have questions. :manhappy:
Emerging Member
Falcon
Posts: 46
Registered: ‎09-15-2010
Posts: 46
Registered: 09-15-2010

Re: How to run AirControl as a service under Mac OS X

BTW - in my instructions above I went the GUI way using TextEdit. Personally I found it easier to use touch and vim to edit the plist directly in /Library/LaunchDaemons, but figured TextEdit would be easier to describe for less unix-y OS X users.
Question for Ubiquity: My big troubleshooting problem getting this working was figuring out the headless mode flag. Perhaps in future releases of AirControl that could be explicitly set headless both so bootstrap does brake remote/automated running on OSX and so it does not create a useless dock icon for those running it manually under OS X?
Previous Employee
UBNT-Thomas
Posts: 783
Registered: ‎10-01-2009
Posts: 783
Kudos: 32
Registered: 10-01-2009

Re: How to run AirControl as a service under Mac OS X

Thanks for sharing. Added as link to the Wiki and will include the default JVM setting.
Emerging Member
Falcon
Posts: 46
Registered: ‎09-15-2010
Posts: 46
Registered: 09-15-2010

Re: How to run AirControl as a service under Mac OS X

Thomas: I did not look too closely for the ideal JVM setting to ensure headless operation, I just used the first solution google searching the error message presented to me. It could be there is a better way to do the same trick. :shrug:
BTW, something I forgot to mention. If you need to disable auto-start of aircontrol on boot all you have to do is go in and edit /Library/LaunchDaemons/com.ubiqyity.aircontrol.plist and change the under the "Disabled" key to . In other words you can enable or disable loading aircontrol as a service without undoing everything.
Established Member
Paetur
Posts: 1,648
Registered: ‎06-30-2010
Posts: 1648
Kudos: 394
Solutions: 59
Contributions: 8
Registered: 06-30-2010

Re: How to run AirControl as a service under Mac OS X

If you use OS-X server, I advice you to use port 9443 for https and NOT 8443 as this is used by ical.
edit conf/catalina.properties
ubnt.https.port=9443
Emerging Member
Falcon
Posts: 46
Registered: ‎09-15-2010
Posts: 46
Registered: 09-15-2010

Re: How to run AirControl as a service under Mac OS X

Thanks Paetur - good catch. My instance is running on regular Mac OS X, not OS X Server so I should not have any conflict, but I added a note to the original post recommending people change to 9443. :manhappy:
Previous Employee
UBNT-Thomas
Posts: 783
Registered: ‎10-01-2009
Posts: 783
Kudos: 32
Registered: 10-01-2009

Re: How to run AirControl as a service under Mac OS X

If you use OS-X server, I advice you to use port 9443 for https and NOT 8443 as this is used by ical.
edit conf/catalina.properties
ubnt.https.port=9443

Thanks for pointing this out. I changed the default port for the tarball installation to 9443 for future releases.
Member
sirthor
Posts: 270
Registered: ‎12-13-2008
Posts: 270
Kudos: 8
Solutions: 1
Registered: 12-13-2008

Re: How to run AirControl as a service under Mac OS X

What are the changes that need to be made to get this working in Lion OSX?
Emerging Member
Falcon
Posts: 46
Registered: ‎09-15-2010
Posts: 46
Registered: 09-15-2010

Re: How to run AirControl as a service under Mac OS X

sirthor: Good question. I have not yet upgraded any of my systems to Lion so I do not really a direct answer. My suspicion is that the same procedure that worked under 10.6 should work fine under 10.7.
If anyone else does give this method a try under 10.7 I would be interested to hear of their results!
Member
sirthor
Posts: 270
Registered: ‎12-13-2008
Posts: 270
Kudos: 8
Solutions: 1
Registered: 12-13-2008

Re: How to run AirControl as a service under Mac OS X

sudo mv ~/Desktop/com.ubiquity.aircontrol.plist /Library/LaunchDaemons/
this directory doesn't appear to exist any more.
Member
sirthor
Posts: 270
Registered: ‎12-13-2008
Posts: 270
Kudos: 8
Solutions: 1
Registered: 12-13-2008

Re: How to run AirControl as a service under Mac OS X

3 things
1)Java is not installed by default. Here's the link support.apple.com/kb/DL1421
2)After installing in default location I used this in the catalina.sh file JAVA_HOME=`/Library/Java/java_home`
3)LaunchDaemons are located at /System/Library/LaunchDaemons/
Works great again
Newbie
minh
Posts: 1
Registered: ‎10-13-2011
Posts: 1
Registered: 10-13-2011

No AirControl

Hello Falcon,

First off thanks for the clear instructions.

Unfortunately after following the procedure and restarting my AirControl does not launch.

Having come from a Windows OS I also tried in the browser localhost:9080 but to no avail.

I did everything the same as you as I also have OSX 10.6.8.

Any suggestions?

Regards,
Minh
New Member
Bottacco
Posts: 11
Registered: ‎10-12-2009
Posts: 11
Kudos: 3
Registered: 10-12-2009

LaunchDaemons

sudo mv ~/Desktop/com.ubiquity.aircontrol.plist /Library/LaunchDaemons/

this directory doesn't appear to exist any more.


The directory does exists and can exist at least in two locations:

/Library/LaunchDaemons
/System/Library/LaunchDaemons

The directory is created only if an actual LaunchDaemon has been installed and activated. If not, you can create it manually. It is the future proof way to create services that run without user login.
New Member
Bottacco
Posts: 11
Registered: ‎10-12-2009
Posts: 11
Kudos: 3
Registered: 10-12-2009

Re: How to run AirControl as a service under Mac OS X

3 things
1)Java is not installed by default. Here's the link support.apple.com/kb/DL1421
2)After installing in default location I used this in the catalina.sh file JAVA_HOME=`/Library/Java/java_home`
3)LaunchDaemons are located at /System/Library/LaunchDaemons/

Works great again


1) Java now is maintained by Oracle directly, so now you should download it directly from them.
2) The path '/Library/Java/java_home' does not exist in my 10.8.2 installation. Instead '/Library/Java/Home' is the path that appears with that operating system version and Java 7 Update 10.
3) The '/System/Library/LaunchDaemons/' should not be used because it could be overwritten in an OS update. Instead you should always use '/Library/LaunchDaemons/'. As I wrote above, if the directory does not exist you can create it but watch out the case in the name and name it just like we wrote it here.
Reply