update dhcp

This commit is contained in:
Samir 2012-07-31 17:57:38 +00:00
parent 4649a98f6b
commit 07f9231d85
7 changed files with 195 additions and 91 deletions

View File

@ -1,40 +1,47 @@
#
# Chakra Packages for Chakra, part of chakra-project.org
# Platform Packages for Chakra, part of chakra-project.org
#
# maintainer (i686): Phil Miller <philm[at]chakra-project[dog]org>
# maintainer (x86_64): Manuel Tortosa <manutortosa[at]chakra-project[dot]org>
# include global config
source ../_buildscripts/${current_repo}-${_arch}-cfg.conf
# maintainer: Samir Benmendil <ram-z[at]chakra-project[dot]org>
pkgbase=dhcp
pkgname=('dhcp'
'dhclient')
# separate patch levels with a period to maintain proper versioning.
pkgver=4.2.0
_pkgver=4.2.0
pkgver=4.2.4.1
_pkgver=4.2.4-P1
pkgrel=1
arch=('i686' 'x86_64')
license=('custom:isc-dhcp')
url="https://www.isc.org/software/dhcp"
source=(http://ftp.isc.org/isc/${pkgname}/${pkgname}-${_pkgver}.tar.gz
dhcpd dhcp.conf.d dhcp-4.1.1-missing-ipv6-not-fatal.patch dhclient-script-pathFixes.patch)
md5sums=('83abd7c4f9c24d8dd024ca5a71380c0a'
'df22cffa7d7415ece7bb025b7bf774dd'
'49da3192e5c885e3c7d02f447c2dea5e'
source=(ftp://ftp.isc.org/isc/${pkgbase}/${_pkgver}/${pkgbase}-${_pkgver}.tar.gz
dhcp4 dhcp6 dhcp.conf.d
dhcp-4.1.1-missing-ipv6-not-fatal.patch
dhclient-script-pathFixes.patch)
md5sums=('0ca7181024651f6323951d5498c8020b'
'c49b1497837ba56c54e401a66e1bab9b'
'12c2f3ae47ed23eb698eb7f1bfd80f20'
'8f357e46e1efcbb746f38737a3f977a2'
'fd64aeb4f399dcc41ea43089a3811094'
'ddcc5cd576ec631ade6c4da21952b50b')
'0fc1241ef7879d8be0fe140deb8ae48d')
build() {
cd ${srcdir}/${pkgname}-${_pkgver}
# Define _GNU_SOURCE to fix IPV6.
sed '/^CFLAGS="$CFLAGS/ s/INGS"/INGS -D_GNU_SOURCE"/' -i configure
# Make not having ipv6 non-fatal.
patch -Np0 -i ${srcdir}/dhcp-4.1.1-missing-ipv6-not-fatal.patch
patch -p0 -i ${srcdir}/dhcp-4.1.1-missing-ipv6-not-fatal.patch
./configure --prefix=/usr --sysconfdir=/etc \
--with-srv-lease-file=/var/state/dhcp/dhcpd.leases \
--with-srv6-lease-file=/var/state/dhcp/dhcpd6.leases
make || return 1
--with-srv6-lease-file=/var/state/dhcp/dhcpd6.leases \
--with-cli-lease-file=/var/state/dhclient/dhclient.leases \
--with-cli6-lease-file=/var/state/dhclient/dhclient6.leases
make
patch -i "${srcdir}/dhclient-script-pathFixes.patch" client/scripts/linux
}
package_dhcp(){
@ -43,42 +50,36 @@ package_dhcp(){
backup=('etc/dhcpd.conf' 'etc/conf.d/dhcp')
install=dhcp.install
cd ${srcdir}/${pkgname}-${_pkgver}
make DESTDIR=${pkgdir} install
install -D -m755 ${srcdir}/dhcpd ${pkgdir}/etc/rc.d/dhcpd
install -D -m644 ${srcdir}/dhcp.conf.d ${pkgdir}/etc/conf.d/${pkgbase}
mkdir -p ${pkgdir}/var/state/dhcp
rm -f ${pkgdir}/etc/dhclient.conf
rm -f ${pkgdir}/usr/sbin/dhclient
rm -f ${pkgdir}/usr/share/man/man{5,8}/dhclient*
cd "${srcdir}/${pkgname}-${_pkgver}"
make DESTDIR="${pkgdir}" install
install -D -m755 "${srcdir}/dhcp4" "${pkgdir}/etc/rc.d/dhcp4"
install -D -m755 "${srcdir}/dhcp6" "${pkgdir}/etc/rc.d/dhcp6"
install -D -m644 "${srcdir}/dhcp.conf.d" "${pkgdir}/etc/conf.d/${pkgbase}"
mkdir -p "${pkgdir}/var/state/dhcp"
# Remove dhclient
make -C client DESTDIR="${pkgdir}" uninstall
# install licenses
install -m644 -D ${srcdir}/${pkgbase}-${_pkgver}/LICENSE \
${pkgdir}/usr/share/licenses/dhcp/LICENSE
install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/dhcp/LICENSE"
}
package_dhclient(){
pkgdesc="dhclient is standalone client from the dhcp package"
depends=('bash')
depends=('bash' 'iproute2' 'net-tools')
cd ${srcdir}/${pkgname}-${_pkgver}/client/scripts
patch -Np1 -i ${srcdir}/dhclient-script-pathFixes.patch linux || return 1
cd ${srcdir}/${pkgname}-${_pkgver}/client
make DESTDIR=${pkgdir} install
install -m755 -d ${startdir}/pkg/var/lib/dhclient
#not needed after fresh install
rm -f ${pkgdir}/var/lib/dhclient/dhcpd.leases
cd "${srcdir}/${pkgname}-${_pkgver}"
make -C client DESTDIR="${pkgdir}" install
#move dhclient.conf to dhclient.conf.example
mv ${pkgdir}/etc/dhclient.conf ${pkgdir}/etc/dhclient.conf.example
mv "${pkgdir}"/etc/dhclient.conf{,.example}
install -d "${pkgdir}/var/state/dhclient"
# install dhclient linux script
mkdir ${pkgdir}/sbin
install -m755 -D ${srcdir}/${pkgname}-${_pkgver}/client/scripts/linux \
${pkgdir}/sbin/dhclient-script
install -Dm755 client/scripts/linux "${pkgdir}/sbin/dhclient-script"
# install licenses
install -m644 -D ${srcdir}/${pkgname}-${_pkgver}/LICENSE \
${pkgdir}/usr/share/licenses/dhclient/LICENSE
install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/dhclient/LICENSE"
}

View File

@ -1,5 +1,5 @@
--- linux 2009-04-21 16:21:09.000000000 +0200
+++ linux_new 2010-06-30 19:06:20.000000000 +0200
--- linux 2011-05-18 20:01:54.000000000 +0000
+++ linux_new 2011-12-21 18:45:41.487171012 +0000
@@ -23,7 +23,7 @@
# of the $1 in its args.
@ -9,7 +9,7 @@
make_resolv_conf() {
if [ x"$new_domain_name_servers" != x ]; then
@@ -112,9 +112,9 @@
@@ -122,9 +122,9 @@
if [ x$reason = xPREINIT ]; then
if [ x$alias_ip_address != x ]; then
# Bring down alias interface. Its routes will disappear too.
@ -21,7 +21,7 @@
# We need to give the kernel some time to get the interface up.
sleep 1
@@ -141,32 +141,32 @@
@@ -151,25 +151,25 @@
if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
[ x$alias_ip_address != x$old_ip_address ]; then
# Possible new alias. Remove old alias.
@ -50,6 +50,24 @@
- route add default gw $router $metric_arg dev $interface
+ /sbin/route add default gw $router $metric_arg dev $interface
done
else
# we haven't changed the address, have we changed other options
@@ -177,21 +177,21 @@
if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then
# if we've changed routers delete the old and add the new.
for router in $old_routers; do
- route del default gw $router
+ /sbin/route del default gw $router
done
for router in $new_routers; do
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
- route add -host $router dev $interface
+ /sbin/route add -host $router dev $interface
fi
- route add default gw $router $metric_arg dev $interface
+ /sbin/route add default gw $router $metric_arg dev $interface
done
fi
fi
if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
then
@ -62,7 +80,7 @@
fi
make_resolv_conf
exit_with_hooks 0
@@ -176,42 +176,42 @@
@@ -201,42 +201,42 @@
|| [ x$reason = xSTOP ]; then
if [ x$alias_ip_address != x ]; then
# Turn off alias interface.

View File

@ -2,5 +2,9 @@
# Arguments to be passed to the DHCP server daemon
#
DHCP_ARGS="-q"
# ipv4 runtime parameters
DHCP4_ARGS="-q"
# ipv6 runtime parameters
DHCP6_ARGS="-q"

View File

@ -1,7 +1,14 @@
# arg 1: the new package version
post_install() {
[ -f var/state/dhcp/dhcpd.leases ] || : >var/state/dhcp/dhcpd.leases
[ -f var/state/dhcp/dhcpd6.leases ] || : >var/state/dhcp/dhcpd6.leases
#echo "If dhcpd doesn't start, ensure the ipv6 kernel module is loaded."
echo
echo "==> The dhcp server has now two rc.d scripts."
echo "==> Use '/etc/rc.d/dhcp6' to use IPv6 dhcp server or"
echo "==> '/etc/rc.d/dhcp4' to use IPv4 dhcp server."
echo "==> Make sure that you change your DAEMONS array in '/etc/rc.conf'!"
}
# arg 1: the new package version

57
dhcp/dhcp4 Executable file
View File

@ -0,0 +1,57 @@
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
. /etc/conf.d/dhcp
PIDFILE="/var/run/dhcpd.pid"
if [[ -f $PIDFILE ]]; then
read -r PID < "$PIDFILE"
# prevent stale pidfiles from hanging around
if [[ ! -d /proc/$PID ]]; then
echo 'pid not found. deleteing stale pidfile'
unset PID
rm -f "$PIDFILE"
fi
fi
case "$1" in
start)
stat_busy "Starting DHCPv4 Server"
if [[ $PID ]]; then
stat_fail
exit 1
fi
if /usr/sbin/dhcpd -4 -pf "$PIDFILE" $DHCP4_ARGS; then
add_daemon dhcp4
stat_done
else
stat_fail
exit 1
fi
;;
stop)
stat_busy "Stopping DHCPv4 Server"
if [[ ! $PID ]]; then
stat_fail
exit 1
fi
if { kill $PID && rm -f "$PIDFILE"; } &>/dev/null; then
rm_daemon dhcp4
stat_done
else
stat_fail
exit 1
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac

57
dhcp/dhcp6 Normal file
View File

@ -0,0 +1,57 @@
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
. /etc/conf.d/dhcp
PIDFILE="/var/run/dhcp6.pid"
if [[ -f $PIDFILE ]]; then
read -r PID < "$PIDFILE"
# prevent stale pidfiles from hanging around
if [[ ! -d /proc/$PID ]]; then
echo 'pid not found. deleteing stale pidfile'
unset PID
rm -f "$PIDFILE"
fi
fi
case "$1" in
start)
stat_busy "Starting DHCPv6 Server"
if [[ $PID ]]; then
stat_fail
exit 1
fi
if /usr/sbin/dhcpd -6 -pf "$PIDFILE" $DHCP6_ARGS; then
add_daemon dhcp6
stat_done
else
stat_fail
exit 1
fi
;;
stop)
stat_busy "Stopping DHCPv6 Server"
if [[ ! $PID ]]; then
stat_fail
exit 1
fi
if { kill $PID && rm -f "$PIDFILE"; } &>/dev/null; then
rm_daemon dhcp6
stat_done
else
stat_fail
exit 1
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac

View File

@ -1,40 +0,0 @@
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
. /etc/conf.d/dhcp
PIDFILE="/var/run/dhcpd.pid"
PID=`cat $PIDFILE 2>/dev/null`
case "$1" in
start)
stat_busy "Starting DHCP Server"
if [ "$PID" = "" ]; then
/usr/sbin/dhcpd $DHCP_ARGS
fi
if [ "$PID" != "" -o $? -gt 0 ]; then
stat_fail
else
add_daemon dhcpd
stat_done
fi
;;
stop)
stat_busy "Stopping DHCP Server"
[ ! -z "$PID" ] && kill $PID &> /dev/null
rm -f $PIDFILE
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon dhcpd
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac