Skip to content

Instantly share code, notes, and snippets.

@breiter
Last active March 20, 2024 11:57
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save breiter/da58235158106f12d999 to your computer and use it in GitHub Desktop.
Save breiter/da58235158106f12d999 to your computer and use it in GitHub Desktop.
OpenVPN client launchd for OS X and MacPorts
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/opt/local/var/log/openvpn2/*.log 644 3 1000 * J
/opt/local/var/log/openvpn2/*/*.log 644 3 1000 * J
<?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>Disabled</key>
<true/>
<key>Label</key>
<string>org.macports.openvpn2.wr-vpc-us-east</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/sbin/openvpn2</string>
<string>--config</string>
<string>/opt/local/etc/openvpn2/wr-vpc-us-east/client.conf</string>
<string>--log-append</string>
<string>/opt/local/var/log/openvpn2/wr-vpc-us-east.log</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/opt/local/etc/openvpn2/wr-vpc-us-east/</string>
<key>KeepAlive</key>
<!-- NetworkState key is no longer implemented in OS X 10.10 Yosemite.
<dict>
<key>NetworkState</key>
<true/>
</dict> -->
<true/>
</dict>
</plist>
@breiter
Copy link
Author

breiter commented Sep 5, 2014

  • openvpn2.conf goes in /etc/newsyslog.d/
  • plist goes in /Library/LaunchDaemons.
    • change following the Label to match file name for each vpn client plist or launchd will be confused.

Also if you want the logs to appear in Console.app, create /var/log/openvpn2 and symlink log files there or alternatively put the logs in /var/log/openvpn2.

# start and autoload on reboot
sudo launchctl load -w /Library/LaunchDaemons/org.macports.openvpn2.wr-vpc-us-east.plist

# stop and disable
sudo launchctl unload -w /Library/LaunchDaemons/org.macports.openvpn2.wr-vpc-us-east.plist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment