aboutsummaryrefslogtreecommitdiff
path: root/net/isc-dhcp31-server
diff options
context:
space:
mode:
authorPav Lucistnik <pav@FreeBSD.org>2004-07-06 00:57:13 +0000
committerPav Lucistnik <pav@FreeBSD.org>2004-07-06 00:57:13 +0000
commit4ac742785c1f15fa75a4166c2d434124c2f0980f (patch)
treeba17c625ac89acb7b2bbb06ad22e76084c9d3ec6 /net/isc-dhcp31-server
parentdcda0e48ce593c25fcbf9913a0a6cfb4e4c8e95d (diff)
downloadports-4ac742785c1f15fa75a4166c2d434124c2f0980f.tar.gz
ports-4ac742785c1f15fa75a4166c2d434124c2f0980f.zip
- minor changes:
Makefile configure-package added to post-install .ORDER added files/isc-dhcpd.sh.sample some debug() added precious() test inverted lsmod() added safe_chmod() fixed (don't chown .../dev if mounted) safe_mkdir() fixed (don't create .../dev if mounted) check_chuser() fixed (-z "${var}" instead of -z ${var}) setup_umask() fixed (dhcpd_umask -> dhcpd_withumask) dhcpd_stop() fixed (sh $0 force... instead of $0 ...) _dhcpd__uninstall() added dhcpd_uninstall() recursively called to handle all the combinations of dhcpd_chuser_enable and dhcpd_chroot_enable $__dhcpd_uninstall added $_dhcpd_piddir and $_dhcpd_leaddir -> $__dhcpd_* Closes PR: ports/68647 Submitted by: Cyrille Lefevre <cyrille.lefevre@laposte.net> (maintainer)
Notes
Notes: svn path=/head/; revision=113018
Diffstat (limited to 'net/isc-dhcp31-server')
-rw-r--r--net/isc-dhcp31-server/Makefile18
-rw-r--r--net/isc-dhcp31-server/files/isc-dhcpd.sh.sample122
2 files changed, 111 insertions, 29 deletions
diff --git a/net/isc-dhcp31-server/Makefile b/net/isc-dhcp31-server/Makefile
index e31d9f68e0d5..e939a10c3e9c 100644
--- a/net/isc-dhcp31-server/Makefile
+++ b/net/isc-dhcp31-server/Makefile
@@ -8,7 +8,7 @@
PORTNAME= dhcp
PORTVERSION= 3.0.1.r14
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= net
MASTER_SITES= ${MASTER_SITE_ISC}
MASTER_SITE_SUBDIR= dhcp dhcp/dhcp-3.0-history
@@ -42,6 +42,7 @@ HAS_CONFIGURE= yes
CONFIGURE_ARGS= --subsys ${SUBSYS}
ALL_TARGET= all.${SUBSYS}
INSTALL_TARGET= install.${SUBSYS}
+SCRIPTS_ENV+= PKG_PREFIX=${PREFIX}
.if ${SUBSYS} == client
MAN5= dhclient.conf.5 dhclient.leases.5
@@ -209,10 +210,14 @@ patch-pkgmessage:
# Post-install
#
-post-install: strip-binary-files install-startup-files \
- install-doc-files install-sample-files \
- create-conf-files create-data-files \
- display-message
+POST-INSTALL= parallel-post-install configure-package display-message
+.ORDER: ${POST-INSTALL}
+post-install: ${POST-INSTALL}
+
+parallel-post-install: \
+ strip-binary-files install-startup-files \
+ install-doc-files install-sample-files \
+ create-conf-files create-data-files
strip-binary-files:
.for f in ${BIN_FILES}
@@ -256,6 +261,9 @@ create-data-files:
.endif
.endfor
+configure-package:
+ @${SETENV} ${SCRIPTS_ENV} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
+
display-message:
.if ${SUBSYS} != devel
@${ECHO_MSG}
diff --git a/net/isc-dhcp31-server/files/isc-dhcpd.sh.sample b/net/isc-dhcp31-server/files/isc-dhcpd.sh.sample
index 876237f3d6c8..de948e1d265b 100644
--- a/net/isc-dhcp31-server/files/isc-dhcpd.sh.sample
+++ b/net/isc-dhcp31-server/files/isc-dhcpd.sh.sample
@@ -44,7 +44,10 @@ safe_run () # rc command [args...]
shift
if [ "${_rc}" -eq 0 ]; then
+ debug safe_run: "$@"
"$@" || _rc=1
+ else
+ warn safe_run: "$@"
fi
return ${_rc}
}
@@ -53,11 +56,30 @@ precious () # entry...
{
local _entry _rc
- _rc=1
+ _rc=0
for _entry; do
# do nothing if /var/run or /var/db
- echo ${_entry} | egrep -q '^//*(var//*(run|db)/*)?$' && _rc=0
+ echo ${_entry} | egrep -q '^//*(var//*(run|db)/*)?$' || _rc=1
done
+ debug precious: "$@" rc=${_rc}
+ return ${_rc}
+}
+
+lsmod () # user group file...
+{
+ local _entry _user _group _rc
+
+ _user=$1 _group=$2
+ shift 2
+
+ _rc=0
+ for _entry; do
+ ls -ld ${_entry} 2> /dev/null |
+ awk -v u=${_user} -v g=${_group} '{
+ exit ((u && $3 != u) || (g && $4 != g))
+ }' || _rc=1
+ done
+ debug lsmod: "$@" rc=${_rc}
return ${_rc}
}
@@ -72,12 +94,12 @@ safe_chmog () # entry...
if [ -n "${_user}" -o -n "${_group}" ]; then
_usergroup=${_user}${_group:+:${_group}}
for _entry; do
+ if [ -d ${_entry} ] && mounted ${_entry}; then
+ continue
+ fi
if [ -e ${_entry} ] &&
! precious ${_entry} &&
- ! ls -ld ${_entry} 2> /dev/null |
- awk -v u=${_user} -v g=${_group} '{
- exit ((u && $3 != u) || (g && $4 != g))
- }' &&
+ ! lsmod ${_user} ${_group} ${_entry} &&
! safe_run ${_rc} chown ${_usergroup} ${_entry}; then
warn "unable to change permissions of ${_entry}"
_rc=1
@@ -111,7 +133,8 @@ safe_rmdir () # dir...
_rc=0
for _dir; do
if [ -d ${_dir} ] &&
- ! precious ${_dir}; then
+ ! precious ${_dir} &&
+ ! mounted ${_dir}; then
if safe_run ${_rc} rmdir ${_dir}; then
safe_run ${_rc} safe_rmdir ${_dir%/*} || _rc=1
else
@@ -179,6 +202,7 @@ mounted () # dir...
BEGIN { n = ARGC; ARGC = 2 }
{ for (i = 2; i != n; i++) if ($3 == ARGV[i]) exit 1 }
' - "$@" || _rc=0
+ debug mounted: "$@" rc=${_rc}
return ${_rc}
}
@@ -250,7 +274,7 @@ check_chuser ()
{
if checkyesno paranoia; then
if checkyesno dhcpd_chuser_enable &&
- [ -z ${dhcpd_withuser} -a -z ${dhcpd_withgroup} ]; then
+ [ -z "${dhcpd_withuser}" -a -z "${dhcpd_withgroup}" ]; then
err 1 "one of dhcpd_withuser and dhcpd_withgroup" \
"must be set if dhcpd_chuser_enable is enabled"
fi
@@ -303,8 +327,8 @@ check_chroot ()
rcvar_chuser ()
{
if checkyesno paranoia && checkyesno dhcpd_chuser_enable; then
- dhcpd_piddir=${_dhcpd_piddir}/${name}
- dhcpd_leasesdir=${_dhcpd_leasesdir}/${name}
+ dhcpd_piddir=${__dhcpd_piddir}/${name}
+ dhcpd_leasesdir=${__dhcpd_leasesdir}/${name}
else
dhcpd_withuser= dhcpd_withgroup=
fi
@@ -328,8 +352,8 @@ rcvar_chroot ()
rcvar_pidnleases ()
{
if ! checkyesno dhcpd_chuser_enable; then
- dhcpd_piddir=${_dhcpd_piddir}
- dhcpd_leasesdir=${_dhcpd_leasesdir}
+ dhcpd_piddir=${__dhcpd_piddir}
+ dhcpd_leasesdir=${__dhcpd_leasesdir}
fi
dhcpd_pidfile=${dhcpd_piddir}/${name}.pid
dhcpd_leasesfile=${dhcpd_leasesdir}/${name}.leases
@@ -372,8 +396,8 @@ setup_compat ()
setup_umask ()
{
- if [ -n "${dhcpd_umask}" ]; then
- umask ${dhcpd_umask}
+ if [ -n "${dhcpd_withumask}" ]; then
+ umask ${dhcpd_withumask}
fi
}
@@ -435,8 +459,8 @@ cleanup_chroot ()
dhcpd_stop ()
{
- if $0 status; then
- $0 stop
+ if sh $0 forcestatus; then
+ sh $0 forcestop
fi
}
@@ -515,21 +539,71 @@ dhcpd_install ()
fi
}
+_dhcpd_uninstall () # user group root
+{
+ local _user _group _root
+
+ _user=$1 _group=$2 _root=$3
+
+ if [ -n "${_user}" -o -n "${_group}" ]; then
+ dhcpd_chuser_enable=YES
+ dhcpd_withuser=${_user}
+ dhcpd_withgroup=${_group}
+ else
+ dhcpd_chuser_enable=NO
+ fi
+ if [ -n "${_root}" ]; then
+ dhcpd_chroot_enable=YES
+ dhcpd_rootdir=${_root}
+ else
+ dhcpd_chroot_enable=NO
+ fi
+ dhcpd_check
+ dhcpd_rcvar
+ dhcpd_uninstall
+}
+
dhcpd_uninstall ()
{
- dhcpd_stop
- remove_pid
- remove_leases
- remove_chuser
- remove_chroot
+ if checkyesno __dhcpd_uninstall; then
+ dhcpd_stop
+ remove_pid
+ remove_leases
+ remove_chuser
+ remove_chroot
+ else
+ local _user _group _root
+
+ __dhcpd_uninstall=YES
+
+ _user=${dhcpd_withuser}
+ _group=${dhcpd_withgroup}
+ _root=${dhcpd_rootdir}
+
+ _dhcpd_uninstall "" "" ""
+
+ if checkyesno paranoia; then
+ if [ -n "${_user}" -o -n "${_group}" ]; then
+ _dhcpd_uninstall "${_user}" "${_group}" ""
+ fi
+ if [ -n "${_root}" ]; then
+ _dhcpd_uninstall "" "" "${_root}"
+ fi
+ if [ -n "${_user}" -o -n "${_group}" ] &&
+ [ -n "${_root}" ]; then
+ _dhcpd_uninstall "${_user}" "${_group}" "${_root}"
+ fi
+ fi
+ fi
}
rcvar=$(set_rcvar)
load_rc_config ${name}
-_dhcpd_piddir=/var/run # pid file directory
-_dhcpd_leasesdir=/var/db # leases file directory
-#_dhcpd_rootdir=/var/db/${name} # root directory
+__dhcpd_uninstall="NO" # internal use only
+__dhcpd_piddir=/var/run # pid file directory
+__dhcpd_leasesdir=/var/db # leases file directory
+#__dhcpd_rootdir=/var/db/${name} # root directory
dhcpd_check
dhcpd_rcvar