require 'formula' class Pincaster < Formula url 'http://download.pureftpd.org/pincaster/releases/pincaster-0.5.tar.gz' homepage 'https://github.com/jedisct1/Pincaster' md5 'd2cba33470c1d23d381a2003b3986efe' def install system "./configure", "--prefix=#{prefix}" system "make install" inreplace "pincaster.conf" do |s| s.gsub! "/var/db/pincaster/pincaster.db", "#{var}/db/pincaster/pincaster.db" s.gsub! "# LogFileName /tmp/pincaster.log", "LogFileName #{var}/log/pincaster.log" end etc.install "pincaster.conf" (var+"db/pincaster/").mkpath (prefix+'com.github.pincaster.plist').write startup_plist end def caveats <<-EOS.undent Automatically load on login with: launchctl load -w #{prefix}/com.github.pincaster.plist To start pincaster manually: pincaster #{etc}/pincaster.conf EOS end def startup_plist return <<-EOPLIST KeepAlive Label com.github.pincaster ProgramArguments #{bin}/pincaster #{etc}/pincaster.conf RunAtLoad UserName #{`whoami`.chomp} WorkingDirectory #{var} StandardErrorPath #{var}/log/pincaster.log StandardOutPath #{var}/log/pincaster.log EOPLIST end end