summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2010-03-26 17:38:44 +0000
committerErmal <eri@pfsense.org>2010-03-26 17:38:44 +0000
commit2ccd84994757cfd34de746bdf74ed2b42b2e906e (patch)
tree06ec32b6364182ddbcae82f00cd734f6e9dc03c0
parent4b7981025b664bdadafd66ba3922becbbbe09985 (diff)
downloadpfsense-2ccd84994757cfd34de746bdf74ed2b42b2e906e.zip
pfsense-2ccd84994757cfd34de746bdf74ed2b42b2e906e.tar.gz
Use the new tool to monitor active leases.
-rw-r--r--etc/inc/services.inc9
-rw-r--r--etc/pfSense.obsoletedfiles1
-rwxr-xr-xetc/rc.parse-isc-dhcpd67
3 files changed, 5 insertions, 72 deletions
diff --git a/etc/inc/services.inc b/etc/inc/services.inc
index 08f57ce..b11114f 100644
--- a/etc/inc/services.inc
+++ b/etc/inc/services.inc
@@ -39,13 +39,12 @@
*/
function services_parse_dhcpd_hostnames() {
- global $config;
- $ps = `/bin/pgrep -f rc.parse-isc-dhcpd`;
- if($ps)
- exec("kill {$ps}");
+ global $g, $config;
+ mwexec("/bin/pkill dhcpleases");
// Launch if option enabled
if (isset($config['dnsmasq']['regdhcp'])) {
- mwexec_bg("sh /etc/rc.parse-isc-dhcpd");
+ mwexec("/bin/ln /etc/hosts /var/etc/hosts");
+ mwexec_bg("/usr/local/sbin/dhcpleases {$g['dhcpd_chroot_path']}/var/db/dhcpd.leases {$config['system']['domain']} {$g['varrun_path']}/dnsmasq.pid");
}
}
diff --git a/etc/pfSense.obsoletedfiles b/etc/pfSense.obsoletedfiles
index 6737386..b1be7b0 100644
--- a/etc/pfSense.obsoletedfiles
+++ b/etc/pfSense.obsoletedfiles
@@ -1,3 +1,4 @@
+/etc/rc.parse-isc-dhcpd
/etc/phpshellsessions/cvssync
/etc/inc/regdomain.inc
/etc/inc/sysctl.inc
diff --git a/etc/rc.parse-isc-dhcpd b/etc/rc.parse-isc-dhcpd
deleted file mode 100755
index d7e465f..0000000
--- a/etc/rc.parse-isc-dhcpd
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/sh
-
-# This script will monitor dhcpd.leases and parse
-# out active leases and ensure they are present
-# in /var/etc/hosts
-SEARCH_DOMAIN=`grep ^domain /etc/resolv.conf | cut -f 2 -d ' '`
-
-update_hosts_file() {
- # $1 = host
- # $2 = ip
- cat /var/etc/hosts | grep -v "$1" > /tmp/hosts.tmp
- if [ "$3" != "" ]; then
- echo "$2 $1.$SEARCH_DOMAIN $1 # dynamic entry created by rc.parse-isc-dhcpd" >> /tmp/hosts.tmp
- fi
- mv /tmp/hosts.tmp /var/etc/hosts
- killall -HUP dnsmasq
-}
-
-# Parse file on initial run
-cat /var/dhcpd/var/db/dhcpd.leases | grep "lease" -A8 | while read LINE
-do
- HOSTNAMEA=`echo "$LINE" | grep client-hostname | awk '{ print $2 }' | cut -d'"' -f2`
- ACTIVEA=`echo "$LINE" | grep active`
- IPADDRA=`echo "$LINE" | grep "^lease" | awk '{ print $2 }'`
- if [ "$HOSTNAMEA" != "" ]; then
- HOSTNAME="$HOSTNAMEA"
- fi
- if [ "$ACTIVEA" != "" ]; then
- ACTIVE="$ACTIVEA"
- fi
- if [ "$IPADDRA" != "" ]; then
- IPADDR="$IPADDRA"
- fi
- if [ "$HOSTNAME" != "" ]; then
- if [ "$IPADDR" != "" ]; then
- update_hosts_file "$HOSTNAME" "$IPADDR" "$ACTIVE"
- HOSTNAME=""
- ACTIVE=""
- IPADDR=""
- fi
- fi
-done
-
-# After processed go ahead and tail file looking for changes.
-tail -F /var/dhcpd/var/db/dhcpd.leases | grep "lease" -A8 | while read LINE
-do
- HOSTNAMEA=`echo "$LINE" | grep client-hostname | awk '{ print $2 }' | cut -d'"' -f2`
- ACTIVEA=`echo "$LINE" | grep active`
- IPADDRA=`echo "$LINE" | grep "^lease" | awk '{ print $2 }'`
- if [ "$HOSTNAMEA" != "" ]; then
- HOSTNAME="$HOSTNAMEA"
- fi
- if [ "$ACTIVEA" != "" ]; then
- ACTIVE="$ACTIVEA"
- fi
- if [ "$IPADDRA" != "" ]; then
- IPADDR="$IPADDRA"
- fi
- if [ "$HOSTNAME" != "" ]; then
- if [ "$IPADDR" != "" ]; then
- update_hosts_file "$HOSTNAME" "$IPADDR" "$ACTIVE"
- HOSTNAME=""
- ACTIVE=""
- IPADDR=""
- fi
- fi
-done
OpenPOWER on IntegriCloud