2010-03-12 01:17:21 +00:00
|
|
|
require 'formula'
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Ddclient < Formula
|
2010-03-12 01:17:21 +00:00
|
|
|
homepage 'http://sourceforge.net/apps/trac/ddclient'
|
2012-03-11 03:33:16 +00:00
|
|
|
url 'http://sourceforge.net/projects/ddclient/files/ddclient/ddclient-3.8.1/ddclient-3.8.1.tar.bz2'
|
2011-12-29 20:39:26 +00:00
|
|
|
md5 '7fa417bc65f8f0e6ce78418a4f631988'
|
2010-03-12 01:17:21 +00:00
|
|
|
|
|
|
|
def install
|
|
|
|
# Adjust default paths in script
|
|
|
|
inreplace 'ddclient' do |s|
|
2012-03-11 03:33:16 +00:00
|
|
|
s.gsub! "/etc/ddclient", "#{etc}/ddclient"
|
|
|
|
s.gsub! "/var/cache/ddclient", "#{var}/run/ddclient"
|
2010-03-12 01:17:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
sbin.install "ddclient"
|
|
|
|
|
|
|
|
# Install sample files
|
2010-10-21 14:54:17 +00:00
|
|
|
inreplace 'sample-ddclient-wrapper.sh',
|
2012-03-11 03:33:16 +00:00
|
|
|
"/etc/ddclient", "#{etc}/ddclient"
|
2010-10-21 14:54:17 +00:00
|
|
|
|
|
|
|
inreplace 'sample-etc_cron.d_ddclient',
|
2012-03-11 03:33:16 +00:00
|
|
|
"/usr/sbin/ddclient", "#{sbin}/ddclient"
|
2010-10-21 14:54:17 +00:00
|
|
|
|
|
|
|
inreplace 'sample-etc_ddclient.conf',
|
2012-03-11 03:33:16 +00:00
|
|
|
"/var/run/ddclient.pid", "#{var}/run/ddclient/pid"
|
2010-10-21 14:54:17 +00:00
|
|
|
|
2012-03-11 03:33:16 +00:00
|
|
|
(share+'doc/ddclient').install %w(
|
2010-10-21 14:54:17 +00:00
|
|
|
sample-ddclient-wrapper.sh
|
|
|
|
sample-etc_cron.d_ddclient
|
|
|
|
sample-etc_ddclient.conf
|
|
|
|
)
|
2010-03-12 01:17:21 +00:00
|
|
|
|
|
|
|
# Create etc & var paths
|
2012-03-11 03:33:16 +00:00
|
|
|
(etc+'ddclient').mkpath
|
|
|
|
(var+'run/ddclient').mkpath
|
2010-03-12 01:17:21 +00:00
|
|
|
|
|
|
|
# Write the launchd script
|
2011-12-31 05:56:52 +00:00
|
|
|
plist_path.write startup_plist
|
|
|
|
plist_path.chmod 0644
|
2010-03-12 01:17:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def caveats; <<-EOS
|
|
|
|
For ddclient to work, you will need to do the following:
|
|
|
|
|
2011-04-19 19:51:16 +00:00
|
|
|
1) Create configuration file in #{etc}/ddclient, a sample
|
|
|
|
configuration can be found in #{HOMEBREW_PREFIX}/share/doc/ddclient.
|
|
|
|
|
|
|
|
Note: don't enable daemon mode in the configuration file; see
|
|
|
|
additional information below.
|
2010-03-12 01:17:21 +00:00
|
|
|
|
|
|
|
2) Install the launchd item in /Library/LaunchDaemons, like so:
|
|
|
|
|
2011-12-31 05:56:52 +00:00
|
|
|
sudo cp -vf #{plist_path} /Library/LaunchDaemons/
|
|
|
|
sudo chown -v root:wheel /Library/LaunchDaemons/#{plist_path.basename}
|
2010-03-12 01:17:21 +00:00
|
|
|
|
|
|
|
3) Start the daemon using:
|
|
|
|
|
2011-12-31 05:56:52 +00:00
|
|
|
sudo launchctl load /Library/LaunchDaemons/#{plist_path.basename}
|
2011-04-19 19:51:16 +00:00
|
|
|
|
|
|
|
The next reboot of the system will automatically start ddclient.
|
2010-03-12 01:17:21 +00:00
|
|
|
|
2011-04-19 19:51:16 +00:00
|
|
|
You can adjust the execution interval by changing the value of
|
2011-12-31 05:56:52 +00:00
|
|
|
StartInterval (in seconds) in /Library/LaunchDaemons/#{plist_path.basename},
|
2011-04-19 19:51:16 +00:00
|
|
|
and then
|
|
|
|
|
2011-12-31 05:56:52 +00:00
|
|
|
sudo launchctl unload /Library/LaunchDaemons/#{plist_path.basename}
|
|
|
|
sudo launchctl load /Library/LaunchDaemons/#{plist_path.basename}
|
2010-03-12 01:17:21 +00:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def startup_plist
|
|
|
|
return <<-EOS
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
|
|
<plist version="1.0">
|
|
|
|
<dict>
|
2010-10-21 14:54:17 +00:00
|
|
|
<key>Label</key>
|
2011-12-31 05:56:52 +00:00
|
|
|
<string>#{plist_name}</string>
|
2010-10-21 14:54:17 +00:00
|
|
|
<key>ProgramArguments</key>
|
|
|
|
<array>
|
2011-12-31 22:13:31 +00:00
|
|
|
<string>#{HOMEBREW_PREFIX}/sbin/ddclient</string>
|
2010-10-21 14:54:17 +00:00
|
|
|
<string>-file</string>
|
|
|
|
<string>#{etc}/ddclient/ddclient.conf</string>
|
|
|
|
</array>
|
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
2011-04-19 19:51:16 +00:00
|
|
|
<key>StartInterval</key>
|
|
|
|
<integer>300</integer>
|
2010-10-21 14:54:17 +00:00
|
|
|
<key>WatchPaths</key>
|
|
|
|
<array>
|
|
|
|
<string>#{etc}/ddclient</string>
|
|
|
|
</array>
|
|
|
|
<key>WorkingDirectory</key>
|
|
|
|
<string>#{etc}/ddclient</string>
|
2010-03-12 01:17:21 +00:00
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|