summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrafan <rafan@FreeBSD.org>2006-07-29 02:07:43 +0000
committerrafan <rafan@FreeBSD.org>2006-07-29 02:07:43 +0000
commitde7712e08dcc3c4c48911088e8b13686238bf954 (patch)
tree67e92c887bc8a91e812f73cea87646e3385f42d2
parent555e99ba9ec40b63d4fee491d402c40d4a85f172 (diff)
downloadFreeBSD-ports-de7712e08dcc3c4c48911088e8b13686238bf954.zip
FreeBSD-ports-de7712e08dcc3c4c48911088e8b13686238bf954.tar.gz
- rc.d scripts are changed to show error messages when some error
occurs. It didn't show error messages even if they are fatal. - Each rc.d script now logs all messages got at starting a daemon. - pkg-install is made to automatically make a user to execute dkfilter which is specified by Makefile. Register UIDs, GIDs. - pkg-deinstall is made to notice that an admin should remove the user made at install-time if they don't need him or her - Bump PORTREVISION for all these changes PR: ports/100978 Submitted by: Yoshisato YANAGISAWA (maintainer)
-rw-r--r--GIDs1
-rw-r--r--UIDs1
-rw-r--r--mail/dkfilter/Makefile15
-rw-r--r--mail/dkfilter/files/dkfilter_in.in23
-rw-r--r--mail/dkfilter/files/dkfilter_out.in23
-rw-r--r--mail/dkfilter/files/pkg-deinstall.in13
-rw-r--r--mail/dkfilter/files/pkg-install.in36
7 files changed, 99 insertions, 13 deletions
diff --git a/GIDs b/GIDs
index c61922c..fbc67ef 100644
--- a/GIDs
+++ b/GIDs
@@ -66,6 +66,7 @@ smxc:*:262:
smxm:*:263:
smx:*:264:
mrtg:*:279:
+dkfilter:*:325:
ldap:*:389:
drweb:*:426:
courier:*:465:
diff --git a/UIDs b/UIDs
index 3de0852..e918342 100644
--- a/UIDs
+++ b/UIDs
@@ -78,6 +78,7 @@ smxc:*:262:262:Sendmail X SMTPC:/nonexistent:/sbin/nologin
smxm:*:263:263:Sendmail X misc:/nonexistent:/sbin/nologin
smx:*:264:264:Sendmail X other:/nonexistent:/sbin/nologin
mrtg:*:279:279:MRTG daemon:/nonexistent:/sbin/nologin
+dkfilter:*:325:325:DK Filter Owner:/nonexistent:/sbin/nologin
ldap:*:389:389:OpenLDAP Server:/nonexistent:/sbin/nologin
drweb:*:426:426:Dr.Web Mail Scanner:/nonexistent:/sbin/nologin
courier:*:465:465:Courier Mail Server:/nonexistent:/sbin/nologin
diff --git a/mail/dkfilter/Makefile b/mail/dkfilter/Makefile
index b34f3fe..7db7db2 100644
--- a/mail/dkfilter/Makefile
+++ b/mail/dkfilter/Makefile
@@ -7,6 +7,7 @@
PORTNAME= dkfilter
PORTVERSION= 0.10
+PORTREVISION= 1
CATEGORIES= mail
MASTER_SITES= http://jason.long.name/dkfilter/
@@ -24,7 +25,16 @@ RUN_DEPENDS= ${BUILD_DEPENDS}
GNU_CONFIGURE= yes
USE_RC_SUBR= dkfilter_in dkfilter_out
-WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION}
+DKFILTER_USERNAME?= dkfilter
+DKFILTER_USERID?= 325
+DKFILTER_GROUPNAME?= ${DKFILTER_USERNAME}
+DKFILTER_GROUPID?= ${DKFILTER_USERID}
+
+SUB_FILES= pkg-install pkg-deinstall
+SUB_LIST= USER=${DKFILTER_USERNAME} \
+ UID=${DKFILTER_USERID} \
+ GROUP=${DKFILTER_GROUPNAME} \
+ GID=${DKFILTER_GROUPID}
.include <bsd.port.pre.mk>
@@ -32,4 +42,7 @@ WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION}
IGNORE= require Perl 5.8 or newer. Install lang/perl5.8 and try again
.endif
+pre-install:
+ ${SH} ${PKGINSTALL} ${PREFIX} PRE-INSTALL
+
.include <bsd.port.post.mk>
diff --git a/mail/dkfilter/files/dkfilter_in.in b/mail/dkfilter/files/dkfilter_in.in
index 1c76ea62..f52dc9b 100644
--- a/mail/dkfilter/files/dkfilter_in.in
+++ b/mail/dkfilter/files/dkfilter_in.in
@@ -20,10 +20,10 @@ rcvar=`set_rcvar`
# set defaults
-dkfilter_in_enable=${dkfilter_in_enable:-"NO"}
-dkfilter_in_flags=${dkfilter_in_flags:-"127.0.0.1:10025 127.0.0.1:10026"}
-dkfilter_in_pidfile=${dkfilter_in_pidfile:-"/var/run/dkfilter_in.pid"}
-dkfilter_in_user=${dkfilter_in_user:-"dkfilter"}
+: ${dkfilter_in_enable="NO"}
+: ${dkfilter_in_flags="127.0.0.1:10025 127.0.0.1:10026"}
+: ${dkfilter_in_pidfile="/var/run/dkfilter_in.pid"}
+: ${dkfilter_in_user="dkfilter"}
start_cmd="dkfilter_in_start"
stop_cmd="dkfilter_in_stop"
@@ -34,12 +34,23 @@ dkfilter_in_start()
echo "${name} already running?"
exit 1
fi
+ echo "Starting ${name}."
+ logger -t ${name} "Starting ${name}"
+ tmpfile=`mktemp /tmp/dkfilter.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`
touch ${dkfilter_in_pidfile}
chown ${dkfilter_in_user} ${dkfilter_in_pidfile}
su -m ${dkfilter_in_user} -c "daemon -p ${dkfilter_in_pidfile} \
%%PREFIX%%/bin/dkfilter.in ${dkfilter_in_flags}" \
- > /dev/null 2>&1
- echo "Starting ${name}"
+ > /dev/null 2> ${tmpfile}
+ sleep 1 # XXX: wait until dkfilter start.
+ logger -t ${name} `cat ${tmpfile}`
+ err=`grep Error ${tmpfile}`
+ if [ "${err}" ]; then
+ echo "Failed to start ${name}."
+ echo "${err}"
+ rm -f ${dkfilter_in_pidfile}
+ fi
+ rm -f ${tmpfile}
}
dkfilter_in_stop()
diff --git a/mail/dkfilter/files/dkfilter_out.in b/mail/dkfilter/files/dkfilter_out.in
index 70500db..9348768 100644
--- a/mail/dkfilter/files/dkfilter_out.in
+++ b/mail/dkfilter/files/dkfilter_out.in
@@ -23,13 +23,13 @@ rcvar=`set_rcvar`
# set defaults
-dkfilter_out_enable=${dkfilter_out_enable:-"NO"}
-dkfilter_out_flags=${dkfilter_out_flags:-" --header \
+: ${dkfilter_out_enable="NO"}
+: ${dkfilter_out_flags=" --header \
--keyfile=%%PREFIX%%/etc/dkfilter/private.key \
--selector=selector1 --domain=example.org --method=nofws \
127.0.0.1:10027 127.0.0.1:10028"}
-dkfilter_out_pidfile=${dkfilter_out_pidfile:-"/var/run/dkfilter_out.pid"}
-dkfilter_out_user=${dkfilter_out_user:-"dkfilter"}
+: ${dkfilter_out_pidfile="/var/run/dkfilter_out.pid"}
+: ${dkfilter_out_user="dkfilter"}
start_cmd="dkfilter_out_start"
stop_cmd="dkfilter_out_stop"
@@ -40,12 +40,23 @@ dkfilter_out_start()
echo "${name} already running?"
exit 1
fi
+ echo "Starting ${name}."
+ logger -t ${name} "Starting ${name}."
+ tmpfile=`mktemp /tmp/dkfilter.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`
touch ${dkfilter_out_pidfile}
chown ${dkfilter_out_user} ${dkfilter_out_pidfile}
su -m ${dkfilter_out_user} -c "daemon -p ${dkfilter_out_pidfile} \
%%PREFIX%%/bin/dkfilter.out ${dkfilter_out_flags}" \
- > /dev/null 2>&1
- echo "Starting ${name}."
+ > /dev/null 2> ${tmpfile}
+ sleep 1 # XXX: wait until dkfilter start.
+ logger -t ${name} `cat ${tmpfile}`
+ err=`grep Error ${tmpfile}`
+ if [ "${err}" ]; then
+ echo "Failed to start ${name}."
+ echo "${err}"
+ rm -f ${dkfilter_out_pidfile}
+ fi
+ rm -f ${tmpfile}
}
dkfilter_out_stop()
diff --git a/mail/dkfilter/files/pkg-deinstall.in b/mail/dkfilter/files/pkg-deinstall.in
new file mode 100644
index 0000000..65b9aec
--- /dev/null
+++ b/mail/dkfilter/files/pkg-deinstall.in
@@ -0,0 +1,13 @@
+#!/bin/sh
+# $FreeBSD$
+
+if [ "$2" != "POST-DEINSTALL" ]; then
+ exit 0
+fi
+
+USERNAME=%%USER%%
+
+if pw usershow "${USERNAME}" 2>/dev/null 1>&2; then
+ echo "To delete ${USERNAME} user permanently, use 'pw userdel \"${USERNAME}\"'"
+fi
+exit 0
diff --git a/mail/dkfilter/files/pkg-install.in b/mail/dkfilter/files/pkg-install.in
new file mode 100644
index 0000000..7504193
--- /dev/null
+++ b/mail/dkfilter/files/pkg-install.in
@@ -0,0 +1,36 @@
+#! /bin/sh
+#
+# $FreeBSD$
+
+PATH=/bin:/usr/bin:/usr/sbin
+
+case $2 in
+
+PRE-INSTALL)
+ echo "---> Starting install script:"
+
+ if [ -z "%%USER%%" -o -z "%%GROUP%%" -o \
+ -z "%%UID%%" -o -z "%%GID%%" ]; then
+ echo "ERROR: A required pragma was empty"
+ exit 1
+ fi
+
+ # Create group if required
+ if pw group show "%%GROUP%%" >/dev/null 2>&1; then
+ echo "---> Using existing group \"%%GROUP%%\""
+ else
+ echo "---> Adding group \"%%GROUP%%\" (%%GID%%)"
+ /usr/sbin/pw groupadd %%GROUP%% -g %%GID%% || exit 1
+ fi
+
+ # Create user if required
+ if pw user show "%%USER%%" >/dev/null 2>&1; then
+ echo "---> Using existing user \"%%USER%%\""
+ else
+ echo "---> Adding user \"%%USER%%\" (%%UID%%)"
+ pw useradd "%%USER%%" -u "%%UID%%" -g "%%GROUP%%" -h - \
+ -d "/nonexistent" -s "/sbin/nologin" -c "DK Filter Owner" || exit 1
+ fi
+ ;;
+
+esac
OpenPOWER on IntegriCloud