2010-08-24 05:16:44 +00:00
|
|
|
require 'formula'
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class IscDhcp < Formula
|
2010-08-24 05:16:44 +00:00
|
|
|
homepage 'http://www.isc.org/software/dhcp'
|
2012-10-21 13:39:36 +00:00
|
|
|
url 'http://ftp.isc.org/isc/dhcp/4.2.4-P2/dhcp-4.2.4-P2.tar.gz'
|
|
|
|
sha256 '0f75170e323cd9573e6e09a5d9236725f3e56e3cac5a70a01fe2a9d76b436499'
|
|
|
|
version '4.2.4-P2'
|
2010-08-24 05:16:44 +00:00
|
|
|
|
|
|
|
def install
|
2011-06-03 05:27:21 +00:00
|
|
|
# use one dir under var for all runtime state.
|
|
|
|
dhcpd_dir = var+'dhcpd'
|
|
|
|
|
|
|
|
# Change the locations of various files to match Homebrew
|
|
|
|
# we pass these in through CFLAGS since some cannot be changed
|
|
|
|
# via configure args.
|
|
|
|
path_opts = {
|
|
|
|
'_PATH_DHCPD_CONF' => etc+'dhcpd.conf',
|
|
|
|
'_PATH_DHCLIENT_CONF' => etc+'dhclient.conf',
|
|
|
|
'_PATH_DHCPD_DB' => dhcpd_dir+'dhcpd.leases',
|
|
|
|
'_PATH_DHCPD6_DB' => dhcpd_dir+'dhcpd6.leases',
|
|
|
|
'_PATH_DHCLIENT_DB' => dhcpd_dir+'dhclient.leases',
|
|
|
|
'_PATH_DHCLIENT6_DB' => dhcpd_dir+'dhclient6.leases',
|
|
|
|
'_PATH_DHCPD_PID' => dhcpd_dir+'dhcpd.pid',
|
|
|
|
'_PATH_DHCPD6_PID' => dhcpd_dir+'dhcpd6.pid',
|
|
|
|
'_PATH_DHCLIENT_PID' => dhcpd_dir+'dhclient.pid',
|
|
|
|
'_PATH_DHCLIENT6_PID' => dhcpd_dir+'dhclient6.pid',
|
|
|
|
'_PATH_DHCRELAY_PID' => dhcpd_dir+'dhcrelay.pid',
|
|
|
|
'_PATH_DHCRELAY6_PID' => dhcpd_dir+'dhcrelay6.pid',
|
|
|
|
}
|
|
|
|
|
|
|
|
path_opts.each do |symbol,path|
|
|
|
|
ENV.append 'CFLAGS', "-D#{symbol}='\"#{path}\"'"
|
|
|
|
end
|
|
|
|
|
2011-12-22 00:51:06 +00:00
|
|
|
# See discussion at: https://gist.github.com/1157223
|
2012-09-04 23:15:31 +00:00
|
|
|
if MacOS.version >= :lion
|
2011-12-22 00:51:06 +00:00
|
|
|
ENV.append 'CFLAGS', "-D__APPLE_USE_RFC_3542"
|
|
|
|
end
|
|
|
|
|
2011-06-03 05:27:21 +00:00
|
|
|
system './configure', "--disable-dependency-tracking",
|
|
|
|
"--prefix=#{prefix}",
|
|
|
|
"--localstatedir=#{dhcpd_dir}"
|
|
|
|
|
|
|
|
# the 'bind' subdirectory doesn't like overly parallel builds
|
|
|
|
# so build it sequentially. deparallelizing the whole build
|
|
|
|
# can be slow.
|
|
|
|
previous_makeflags = ENV['MAKEFLAGS']
|
|
|
|
ENV.deparallelize
|
|
|
|
system 'make -C bind'
|
|
|
|
ENV['MAKEFLAGS'] = previous_makeflags
|
|
|
|
|
|
|
|
# build everything else
|
|
|
|
inreplace 'Makefile', 'SUBDIRS = bind', 'SUBDIRS = '
|
|
|
|
system 'make'
|
|
|
|
system 'make install'
|
|
|
|
|
|
|
|
# rename all the installed sample etc/* files so they don't clobber
|
|
|
|
# any existing config files at symlink time.
|
|
|
|
Dir.open(prefix+'etc') do |dir|
|
|
|
|
dir.each do |f|
|
|
|
|
file = "#{dir.path}/#{f}"
|
|
|
|
File.rename(file, "#{file}.sample") if File.stat(file).file?
|
|
|
|
end
|
2010-08-24 05:16:44 +00:00
|
|
|
end
|
|
|
|
|
2011-06-03 05:27:21 +00:00
|
|
|
# create the state dir and lease files else dhcpd will not start up.
|
|
|
|
dhcpd_dir.mkpath
|
|
|
|
%w(dhcpd dhcpd6 dhclient dhclient6).each do |f|
|
|
|
|
file = "#{dhcpd_dir}/#{f}.leases"
|
|
|
|
File.new(file, File::CREAT|File::RDONLY).close
|
|
|
|
end
|
|
|
|
|
2012-11-25 15:06:41 +00:00
|
|
|
# dhcpv6 plists
|
|
|
|
(prefix+'homebrew.mxcl.dhcpd6.plist').write plist_dhcpd6
|
2011-12-31 05:56:52 +00:00
|
|
|
(prefix+'homebrew.mxcl.dhcpd6.plist').chmod 0644
|
2011-06-03 05:27:21 +00:00
|
|
|
end
|
|
|
|
|
2012-11-25 15:06:41 +00:00
|
|
|
def caveats; <<-EOS.undent
|
2011-12-31 05:56:52 +00:00
|
|
|
This install of dhcpd expects config files to be in #{etc}.
|
|
|
|
All state files (leases and pids) are stored in #{var}/dhcpd.
|
2011-06-03 05:27:21 +00:00
|
|
|
|
|
|
|
Dhcpd needs to run as root since it listens on privileged ports.
|
|
|
|
|
|
|
|
There are two plists because a single dhcpd process may do either
|
|
|
|
DHCPv4 or DHCPv6 but not both. Use one or both as needed.
|
|
|
|
|
|
|
|
Note that you must create the appropriate config files before starting
|
|
|
|
the services or dhcpd will refuse to run.
|
2011-12-31 22:13:31 +00:00
|
|
|
DHCPv4: #{etc}/dhcpd.conf
|
|
|
|
DHCPv6: #{etc}/dhcpd6.conf
|
2011-06-03 05:27:21 +00:00
|
|
|
|
|
|
|
Sample config files may be found in #{etc}.
|
2012-11-25 15:06:41 +00:00
|
|
|
EOS
|
2011-06-03 05:27:21 +00:00
|
|
|
end
|
|
|
|
|
2012-11-25 15:06:41 +00:00
|
|
|
plist_options :startup => true
|
|
|
|
|
|
|
|
def plist
|
|
|
|
<<-EOS.undent
|
2011-06-03 05:27:21 +00:00
|
|
|
<?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>
|
2011-12-31 05:56:52 +00:00
|
|
|
<key>Label</key><string>#{plist_name}</string>
|
2011-06-03 05:27:21 +00:00
|
|
|
<key>ProgramArguments</key>
|
|
|
|
<array>
|
2012-11-25 15:06:41 +00:00
|
|
|
<string>#{opt_prefix}/sbin/dhcpd</string>
|
2011-06-03 05:27:21 +00:00
|
|
|
<string>-f</string>
|
|
|
|
</array>
|
|
|
|
<key>Disabled</key><false/>
|
|
|
|
<key>KeepAlive</key><true/>
|
|
|
|
<key>RunAtLoad</key><true/>
|
|
|
|
<key>LowPriorityIO</key><true/>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
2012-11-25 15:06:41 +00:00
|
|
|
EOS
|
2011-06-03 05:27:21 +00:00
|
|
|
end
|
|
|
|
|
2012-11-25 15:06:41 +00:00
|
|
|
def plist_dhcpd6
|
|
|
|
<<-EOS.undent
|
2011-06-03 05:27:21 +00:00
|
|
|
<?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>
|
2011-12-31 05:56:52 +00:00
|
|
|
<key>Label</key><string>#{plist_name}</string>
|
2011-06-03 05:27:21 +00:00
|
|
|
<key>ProgramArguments</key>
|
|
|
|
<array>
|
2012-11-25 15:06:41 +00:00
|
|
|
<string>#{opt_prefix}/sbin/dhcpd</string>
|
2011-06-03 05:27:21 +00:00
|
|
|
<string>-f</string>
|
|
|
|
<string>-6</string>
|
|
|
|
<string>-cf</string>
|
2011-12-31 22:13:31 +00:00
|
|
|
<string>#{etc}/dhcpd6.conf</string>
|
2011-06-03 05:27:21 +00:00
|
|
|
</array>
|
|
|
|
<key>Disabled</key><false/>
|
|
|
|
<key>KeepAlive</key><true/>
|
|
|
|
<key>RunAtLoad</key><true/>
|
|
|
|
<key>LowPriorityIO</key><true/>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
2012-11-25 15:06:41 +00:00
|
|
|
EOS
|
2010-08-24 05:16:44 +00:00
|
|
|
end
|
|
|
|
end
|