From 2749c8cffca3da0f4fdb57b482ba116ed8ad67bc Mon Sep 17 00:00:00 2001 From: Robert Shaw Date: Thu, 11 Mar 2010 17:17:46 -0800 Subject: New formula: openvpn Formula for OpenVPN version 2.1.1 Recommended dependency on LZO, but not required. Signed-off-by: Adam Vandenberg Tweaked path concatenation. --- Library/Formula/openvpn.rb | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Library/Formula/openvpn.rb (limited to 'Library/Formula') diff --git a/Library/Formula/openvpn.rb b/Library/Formula/openvpn.rb new file mode 100644 index 000000000..9336ff80f --- /dev/null +++ b/Library/Formula/openvpn.rb @@ -0,0 +1,87 @@ +require 'formula' + +class Openvpn :recommended + + def skip_clean? path + path == etc or path == var + end + + def install + # Build and install binary + system "./configure", "--prefix=#{prefix}", "--disable-debug", "--disable-dependency-tracking" + system "make install" + + # Adjust sample file paths + inreplace ["sample-config-files/openvpn-startup.sh", "sample-scripts/openvpn.init"] do |s| + s.gsub! "/etc/openvpn", (etc + 'openvpn') + s.gsub! "/var/run/openvpn", (var + 'run/openvpn') + end + + # Install sample files + Dir['sample-*'].each do |d| + (share + 'doc/openvpn' + d).install Dir[d+'/*'] + end + + # Create etc & var paths + (etc + 'openvpn').mkpath + (var + 'run/openvpn').mkpath + + # Write the launchd script + (prefix + 'org.openvpn.plist').write startup_plist + end + + def caveats; <<-EOS +For OpenVPN to work as a server, you will need to do the following: + +1) Create configuration file in #{etc}/openvpn, samples can be + found in #{share}/doc/openvpn + +2) Install the launchd item in /Library/LaunchDaemons, like so: + + sudo cp -vf #{prefix}/org.openvpn.plist /Library/LaunchDaemons/. + sudo chown -v root:wheel /Library/LaunchDaemons/org.openvpn.plist + +3) Start the daemon using: + + sudo launchctl load /Library/LaunchDaemons/org.openvpn.plist + +Next boot of system will automatically start OpenVPN. +EOS + end + + def startup_plist + return <<-EOS + + + + + Label + org.openvpn + ProgramArguments + + #{sbin}/openvpn + --config + #{etc}/openvpn/openvpn.conf + + OnDemand + + RunAtLoad + + TimeOut + 90 + WatchPaths + + #{etc}/openvpn + + WorkingDirectory + #{etc}/openvpn + + +EOS + end +end -- cgit v1.2.3