Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Mar 2001 04:02:28 +0800
From:      Clive Lin <clive@CirX.ORG>
To:        Sybolt de Boer <bolt@xs4all.nl>
Cc:        ports@FreeBSD.org
Subject:   Nullmailer diff to support make package and other stuffs (was Re: nullmailer (again!))
Message-ID:  <20010304040228.A85073@cartier.cirx.org>
In-Reply-To: <20010225223042.A26095@holy.xs4all.nl>; from bolt@xs4all.nl on Sun, Feb 25, 2001 at 10:30:42PM %2B0100
References:  <20010225223042.A26095@holy.xs4all.nl>

next in thread | previous in thread | raw e-mail | index | archive | help

--bp/iNruPH9dso1Pn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

[Cc'd to -ports for other people's review]

Hi,

    Okay, I finally come up with an evil diff. Coudl you test if it
works properly in

      a) ordinary 'make install deinstall' case and
      b) 'env BATCH=t make package deinstall' case
         This is the bento (FreeBSD's package builder) way.
      c) pkg_add the_package_you_made_in_case_b
      d) pkg_delete the_package_you_installed_in_case_c

    And.. don't forget to create your own remotes config file.

On Sun, Feb 25, 2001 at 10:30:42PM +0100, Sybolt de Boer wrote:
> Hello again!
> 
> I hadn't realized user nullmail was 'someone' created by the author of
> nullmailer. Let's keep it that way. I still prefer /var/nullmailer over
> ${PREFIX}/var/nullmailer though.
> 
> Attached is a patch that does the following:

In the diff I attached:

> 1) nullmail's ${HOME} == /var/nullmailer.

If in BATCH mode, it would still be ${PREFIX}/var/nullmailer, for
a neat packaging problem I can't solve :> But anyway, I think if it
will be a precompiled package, it has to be prefix clean.

> 2) makes sure nullmail's ${HOME} is created.
> 3) makes sure ${PREFIX}/etc/rc.d/nullmail.sh is deinstalled.

Heh, actually these won't happen except for typos (but I made it
before, sigh)

> 4) notifies user about the remaining files (/var/nullmailer/*).

Please test if this works properly.

-- 
pub  1024D/F8D2B472 2000-08-05 Clive Lin <clive@CirX.ORG>
     Key fingerprint = 7F9D 57A8 55C7 AA18 49B5  3820 570B 27F6 F8D2 B472

--bp/iNruPH9dso1Pn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="nullmailer.diff"

diff -ruN nullmailer~/Makefile nullmailer/Makefile
--- nullmailer~/Makefile	Wed Feb 21 10:25:56 2001
+++ nullmailer/Makefile	Sun Mar  4 03:32:42 2001
@@ -8,6 +8,7 @@
 PORTNAME=	nullmailer
 # PORTVERSION=	1.00RC5
 PORTVERSION=	1.00r5
+PORTREVISION=	1
 CATEGORIES=	mail
 MASTER_SITES=	http://www.em.ca/~bruceg/nullmailer/archive/%SUBDIR%/
 # MASTER_SITE_SUBDIR=	${PORTVERSION}
@@ -17,22 +18,34 @@
 MAINTAINER=	clive@FreeBSD.org
 
 HAS_CONFIGURE=	yes
-IS_INTERACTIVE=	yes
-NO_PACKAGE=	yes
 
 MAN1=	nullmailer-inject.1 sendmail.1
 MAN7=	nullmailer.7
 MAN8=	nullmailer-queue.8 nullmailer-send.8
 
+PKGMESSAGE=	${WRKDIR}/pkg-message
+
+.if defined(BATCH)
+PLIST_SUB=		LOCALSTATEDIR="${PREFIX}"
+PLIST_SUB+=		LOCALSTATEDIR_RM="@dirrm "
+NMH_PREFIX=		${PREFIX}
+.else
+PLIST_SUB=		LOCALSTATEDIR=""
+PLIST_SUB+=		LOCALSTATEDIR_RM="@comment "
+CONFIGURE_ARGS+=	'--localstatedir=/var/'
+.endif
+
+# Pass BATCH to pkg-install for Evil Things(tm)
 pre-install:
-	@PKG_PREFIX="${PREFIX}" ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
+	@BATCH="${BATCH}" NMH_PREFIX="${NMH_PREFIX}" PKG_PREFIX="${PREFIX}" ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
 
 do-install:
 	@cd ${WRKSRC} && make install && make install-root
 
 post-install:
-	@${INSTALL} -c files/nullmail.sh ${PREFIX}/etc/rc.d/
-	@${INSTALL} -c files/remotes.sample ${PREFIX}/etc/nullmailer/
-	@${CAT} ${PKGMESSAGE} | ${SED} -e 's,%%PREFIX%%,${PREFIX},'
+	@${INSTALL_SCRIPT} -c files/nullmail.sh ${PREFIX}/etc/rc.d/
+	@${INSTALL_DATA} -c files/remotes.sample ${PREFIX}/etc/nullmailer/
+	@${CAT} ${.CURDIR}/pkg-message | ${SED} -e 's,%%PREFIX%%,${PREFIX},' > ${PKGMESSAGE}
+	@${CAT} ${PKGMESSAGE}
 
 .include <bsd.port.mk>
diff -ruN nullmailer~/pkg-deinstall nullmailer/pkg-deinstall
--- nullmailer~/pkg-deinstall	Thu Jan  1 08:00:00 1970
+++ nullmailer/pkg-deinstall	Sun Mar  4 02:53:29 2001
@@ -0,0 +1,93 @@
+#!/bin/sh
+
+user=nullmail
+group=nullmail
+
+ask() {
+    local question default answer
+
+    question=$1
+    default=$2
+    if [ -z "${PACKAGE_BUILDING}" ]; then
+        read -p "${question} [${default}]? " answer
+    fi
+    if [ x${answer} = x ]; then
+        answer=${default}
+    fi
+    echo ${answer}
+}
+
+yesno() {
+    local dflt question answer
+
+    question=$1
+    dflt=$2
+    while :; do
+        answer=$(ask "${question}" "${dflt}")
+        case "${answer}" in
+        [Yy]*)          return 0;;
+        [Nn]*)          return 1;;
+        esac
+        echo "Please answer yes or no."
+    done
+}
+
+delete_account() {
+    local u g home
+
+    u=$1
+    g=$2
+    if yesno "Do you want me to remove group \"${g}\"" y; then
+	pw groupdel -n ${g}
+	echo "Done."
+    fi
+    if yesno "Do you want me to remove user \"${u}\"" y; then
+	eval home=~${u}
+	pw userdel -n ${u}
+	echo "Done."
+	if [ -d "${home}" ]; then
+	    echo "Please remember to check if there's any unsend mail left"
+	    echo "in the home directory \"${home}\""
+	fi
+
+    fi
+}
+
+if [ x"$2" = xDEINSTALL ]; then
+    if [ ! -n "$BATCH" ]; then
+	if /bin/ps -axc | /usr/bin/grep -q nullmailer-send; then
+	    if yesno "There are some nullmailer processes running.  Shall I kill them" y; then
+		${PKG_PREFIX}/etc/rc.d/nullmail.sh stop
+		sleep 2
+	    else
+		echo "OK ... I hope you know what you are doing."
+	    fi
+	fi
+
+    fi
+fi
+
+if [ x"$2" = xPOST-DEINSTALL ]; then
+    tmp="/etc/#nullmailer$$"
+    if [ ! -n "$BATCH" ]; then
+	if yesno "Do you want me to remove the nullmail logging from \"/etc/syslog.conf\"" y; then
+	    sed "/nullmail\.log\$/d" /etc/syslog.conf >${tmp} || exit
+	    chmod 644 ${tmp}
+	    mv ${tmp} /etc/syslog.conf || exit
+
+	    if [ -f /var/run/syslog.pid ]; then
+		echo "Giving syslogd a kick in the pants."
+		kill -HUP `cat /var/run/syslog.pid`
+	    fi
+	fi
+
+	if yesno "Do you want me to remove the nullmail log entry from \"/etc/newsyslog.conf\"" y; then
+	    sed "/nullmail\.log/d" /etc/newsyslog.conf >${tmp} || exit
+	    chmod 644 ${tmp}
+	    mv ${tmp} /etc/newsyslog.conf || exit
+	    echo "Done."
+	fi
+	delete_account ${user} ${group}
+
+    fi
+fi
diff -ruN nullmailer~/pkg-install nullmailer/pkg-install
--- nullmailer~/pkg-install	Mon Feb 26 11:08:51 2001
+++ nullmailer/pkg-install	Sun Mar  4 03:33:29 2001
@@ -37,7 +37,7 @@
         echo "You already have a group \"${group}\", so I will use it."
     else
         echo "You need a group \"${group}\"."
-        if yesno "Would you like me to create it" y; then
+        if ([ -n "$BATCH" ] || yesno "Would you like me to create it" y); then
             /usr/sbin/pw groupadd ${group} -g 522 -h - || exit
             echo "Done."
         else
@@ -50,14 +50,48 @@
         echo "You already have a user \"${user}\", so I will use it."
     else
         echo "You need a user \"${user}\"."
-        if yesno "Would you like me to create it" y; then
-            /usr/sbin/pw useradd ${user} -u 522 -g ${group} -h - -d ${PKG_PREFIX}/var/nullmailer \
+        if ([ -n "$BATCH" ] || yesno "Would you like me to create it" y); then
+            /usr/sbin/pw useradd ${user} -u 522 -g ${group} -h - -d ${NMH_PREFIX}/var/nullmailer \
                 -s /bin/sh -c "Nullmailer Mail System" || exit
             echo "Done."
         else
             echo "Please create it, and try again."
             exit 1
         fi
+    fi
+
+    if [ ! -n "$BATCH" ]; then
+	if grep -q "^[^#]*local5.*/var/log/nullmail.log" /etc/syslog.conf; then
+	    echo -n "It looks like you already have some logging set up, so I "
+	    echo "will use it."
+	elif yesno "Would you like me to set up the syslog logging" y; then
+	    echo "Setting up nullmailer logging in \"/etc/syslog.conf\"."
+	    cat <<EOF | ex -s
+e /etc/syslog.conf
+/\*\.\*/
+-1
+insert
+local5.info					/var/log/nullmail.log
+.
+wq
+EOF
+
+	    if [ ! -f /var/log/nullmail.log ]; then
+		echo "Creating \"/var/log/nullmail.log\"."
+		cp /dev/null /var/log/nullmail.log
+	    fi
+
+	    if [ -f /var/run/syslog.pid ]; then
+		echo "Giving syslogd a kick in the pants."
+		kill -HUP `cat /var/run/syslog.pid`
+	    fi
+
+	    echo "Adding nullmail log entry to \"/etc/newsyslog.conf\"."
+	    cat <<EOF >>/etc/newsyslog.conf
+/var/log/nullmail.log			644  7     *    @T00  Z
+EOF
+	    echo "Done."
+	fi
     fi
 
 fi
diff -ruN nullmailer~/pkg-message nullmailer/pkg-message
--- nullmailer~/pkg-message	Wed Feb 21 10:25:56 2001
+++ nullmailer/pkg-message	Sun Mar  4 02:51:39 2001
@@ -1,15 +1,9 @@
 ==================================================================
-1) Add the following line into your /etc/syslog.conf and 
-   killall -1 syslogd:
-local5.info					/var/log/nullmail
 
-NOTICE: This entry must be before 
-*.*						/var/log/all.log
+Please take %%PREFIX%%/etc/nullmailer/remotes.sample
+as an example and edit your own 
+%%PREFIX%%/etc/nullmailer/remotes
 
-2) Touch /var/log/nullmail as root.
+Also man nullmailer-send(8) for more details
 
-3) Add this line into your /etc/newsyslog.conf:
-/var/log/nullmail                       644  7     *    @T00  Z
-
-4) Edit %%PREFIX%%/etc/nullmailer/remotes
 ==================================================================
diff -ruN nullmailer~/pkg-plist nullmailer/pkg-plist
--- nullmailer~/pkg-plist	Tue Feb 27 01:10:16 2001
+++ nullmailer/pkg-plist	Sun Mar  4 03:28:27 2001
@@ -7,11 +7,22 @@
 sbin/sendmail
 etc/nullmailer/remotes.sample
 etc/rc.d/nullmail.sh
-@dirrm var/nullmailer/queue
-@dirrm var/nullmailer/tmp
-@unexec rm -f %D/var/nullmailer/trigger
+@exec mkdir -p %%LOCALSTATEDIR%%/var/nullmailer/queue
+@exec chmod 700 %%LOCALSTATEDIR%%/var/nullmailer/queue
+@exec mkdir -p %%LOCALSTATEDIR%%/var/nullmailer/tmp
+@exec chmod 700 %%LOCALSTATEDIR%%/var/nullmailer/tmp
+@exec rm -f %%LOCALSTATEDIR%%/var/nullmailer/trigger
+@exec mkfifo %%LOCALSTATEDIR%%/var/nullmailer/trigger
+@exec chmod 600 %%LOCALSTATEDIR%%/var/nullmailer/trigger
+@exec chown -R nullmail %%LOCALSTATEDIR%%/var/nullmailer/*
+@exec chown nullmail %D/sbin/nullmailer-queue
+@exec chmod u+s %D/sbin/nullmailer-queue
+@exec chown nullmail %D/bin/mailq
+@exec chmod u+s %D/bin/mailq
+%%LOCALSTATEDIR_RM%%var/nullmailer/queue
+%%LOCALSTATEDIR_RM%%var/nullmailer/tmp
+@unexec rm -f %%LOCALSTATEDIR%%/var/nullmailer/trigger
 @dirrm etc/nullmailer
-@dirrm var/nullmailer
-@unexec echo "Warning: If you will *NOT* use nullmailer anymore, please remove"
-@unexec echo "         1) nullmail user and its group."
-@unexec echo "         2) its relative entry in /etc/syslog.conf and /etc/newsyslog.conf"
+%%LOCALSTATEDIR_RM%%var/nullmailer
+%%LOCALSTATEDIR_RM%%var
+@unexec if [ -n "$BATCH" ]; then echo "Warning: In batch mode, I will do 'rmuser -y nullmail'"; rmuser -y nullmail; fi

--bp/iNruPH9dso1Pn--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010304040228.A85073>