From: Bruce S. <bl...@us...> - 2005-05-02 14:04:45
|
Update of /cvsroot/devil-linux/build/scripts/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2041/scripts/scripts Modified Files: dhcpd dhcpd.conf setup Log Message: Include lease-file-name in dhcpd.conf Index: setup =================================================================== RCS file: /cvsroot/devil-linux/build/scripts/scripts/setup,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- setup 20 Feb 2005 03:47:40 -0000 1.22 +++ setup 2 May 2005 14:03:48 -0000 1.23 @@ -551,7 +551,9 @@ # Create a basic /etc/dhcpd.conf file writedhcpd() { - mod_config $NICDIR/ifcfg-eth1 DHCP server +# mod_config $NICDIR/ifcfg-eth1 DHCP server +# must be manually enabled in the corresponding NIC settings + DNS=$(echo "${DNS1},${DNS2},${DNS3}" | sed -e 's/ //g' -e 's/,,*$//') cat << EOF > $DHCPDCONF # to restart DNS on Devil Linux: @@ -561,6 +563,7 @@ authoritative; default-lease-time 14400; max-lease-time 14400; +lease-file-name "$DHCPDLEASES"; get-lease-hostnames false; use-host-decl-names on; ddns-update-style none; @@ -619,17 +622,20 @@ DNS3="$(echo "$DNS,," | cut -d',' -f3)" FIRST=$(grep '^ *range *' $DHCPDCONF | sed -e 's/^ *range *//' -e 's/ .*$//') LAST=$(grep '^ *range *' $DHCPDCONF | sed -e 's/^ *range * .* //' -e 's/ *; *$//') + DHCPDLEASES=$(grep '^ *lease-file-name *"' $DHCPDCONF | sed -e 's/^ *lease-file-name *"//' -e 's/" *; *$//') + [ -z "$DHCPDLEASES" ] && DHCPDLEASES="/etc/dhcpd.leases" else DOMAIN="" DNS="" DNS1="" DNS2="" DNS3="" + DHCPDLEASES="" fi DHCPMENU="Domain" while true do - [ -n "$IP" -a -n "$DNS1" -a -n "$FIRST" -a -n "$LAST" -a -n "$DOMAIN" ] \ + [ -n "$IP" -a -n "$DNS1" -a -n "$FIRST" -a -n "$LAST" -a -n "$DHCPDLEASES" -a -n "$DOMAIN" ] \ && SAVEBTN=" --extra-button --extra-label Save" \ || SAVEBTN="" $DIALOG --title "Configure DHCP Server" --backtitle "$BACKTITLE" \ @@ -642,6 +648,7 @@ '1stIP' "First IP address to assign [$FIRST] " \ '2ndIP' "Last IP address to assign [$LAST] " \ 'Gateway' "Default Gateway [$IP] " \ + 'LeasesFile' "Leases File [$DHCPDLEASES] "\ 2> $RESULT RETURN=$? DHCPMENU="$(cat $RESULT)" @@ -675,6 +682,10 @@ inputbox "Default Gateway" "Enter your default route" "$IP" && \ eval IP="$(cat $RESULT)" ;; + LeasesFile) + inputbox "Leases File" "Enter your leases file" "$DHCPDLEASES" && \ + eval DHCPDLEASES="$(cat $RESULT)" + ;; esac elif [ $RETURN -eq 3 ]; then writedhcpd @@ -872,7 +883,11 @@ setupnetworking ;; DHCP) - dhcpserver 1 +# dhcpserver 1 +# above only is valid, if dhcpd should be running on eth1. +# this should be determined dynamically. +# we will use the first occurrence of DHCP=server in the ifcfg-eth? files + dhcpserver $(grep '^ *DHCP=server' /etc/sysconfig/nic/ifcfg-eth* | sed -e '1!d' -e 's/^.*ifcfg-eth//' -e 's/\:.*//') ;; LoginPW) clear Index: dhcpd =================================================================== RCS file: /cvsroot/devil-linux/build/scripts/scripts/dhcpd,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- dhcpd 2 Aug 2004 13:13:20 -0000 1.11 +++ dhcpd 2 May 2005 14:03:48 -0000 1.12 @@ -41,29 +41,20 @@ fi done -leasearg="yes" -DHCPD_CONF=/etc/dhcpd.conf -if [ -f $DHCPD_CONF ]; then - if [ $(grep -ic lease-file-name $DHCPD_CONF) -gt 0 ]; then - leasearg="no" - fi -fi - if [ "$DEVICES" != "" ]; then case "$1" in start) - if [ ! -e /etc/dhcpd.leases ]; then - touch /etc/dhcpd.leases - fi + LF="$(grep '^ *lease-file-name *"' $DHCPDCONF | sed -e 's/^ *lease-file-name *"//' -e 's/" *; *$//')" + touch ${LF:-/etc/dhcpd.leases} || exit for DEVICE in $DEVICES; do route add -net 255.255.255.255 netmask 255.255.255.255 $DEVICE done echo -n "Starting $NAME on $DEVICES..." - if [ "$leasearg" = "no" ]; then - loadproc $DAEMON -q $DEVICES - else + if [ -z "$LF" ]; then loadproc $DAEMON -lf /etc/dhcpd.leases -q $DEVICES + else + loadproc $DAEMON -q $DEVICES fi ;; stop) Index: dhcpd.conf =================================================================== RCS file: /cvsroot/devil-linux/build/scripts/scripts/dhcpd.conf,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- dhcpd.conf 20 Jan 2002 19:32:43 -0000 1.1 +++ dhcpd.conf 2 May 2005 14:03:48 -0000 1.2 @@ -8,6 +8,7 @@ # declare the lease times (the time after which a client will renew its lease) default-lease-time 600; # 10 minutes max-lease-time 7200; # 2 hours +lease-file-name "/etc/dhcpd.leases"; # let's give the local domain a name # (which should correlate to your name server configuration) |