LaunchDaemons and Mac OS X – OpenVPN as an example

LaunchDaemons and Mac OS X – OpenVPN as an example

April 19th, 2007 // 10:26 pm @

LaunchDaemons are the new “init” for Mac OS X 10.4 onward.

I have successfully used it to start and run OpenVPN on Mac OS X 10.4 Server.

Below is the .plist file I created to start and run OpenVPN on Mac OS X 10.4






        Label
        org.openvpn
        OnDemand
        
        Program
        /usr/local/sbin/openvpn
        ProgramArguments
        
                openvpn
                --config
                openvpn.conf
        
        RunAtLoad
        
        TimeOut
        90
        WorkingDirectory
        /etc/openvpn



Once you have created the .plist file, you are ready to install and configure it with “launchctl”.

Just typing “sudo launchctl” on the command-line will take you into an interactive session with launchd!

Type “help” for instructions and a list of commands.

The following were the most helpful that I found… you can also use them on the command-line like the examples below. Assuming you have put the file about into /Library/LaunchDaemons/org.openvpn.plist, you can do the following:

“sudo launchctl load /Library/LaunchDaemons/org.openvpn.plist” to tell launchd about your new daemon.

“sudo launchctl unload /Library/LaunchDaemons/org.openvpn.plist” to uninstall your daemon.

“sudo launchctl start org.openvpn” to start the daemon.

“sudo launchctl stop org.openvpn” to cause launchd to stop being obsessive about the daemon and let it die.

With the .plist file shown above, launchd automatically restarts OpenVPN when it crashes and the process is no longer running.

Hope that helps someone!


Category : Mac OS X

Comments are closed.

Latest News

Certifications