diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/nullmailer/Makefile | 25 | ||||
-rw-r--r-- | mail/nullmailer/pkg-deinstall | 93 | ||||
-rw-r--r-- | mail/nullmailer/pkg-install | 40 | ||||
-rw-r--r-- | mail/nullmailer/pkg-message | 14 | ||||
-rw-r--r-- | mail/nullmailer/pkg-plist | 25 |
5 files changed, 171 insertions, 26 deletions
diff --git a/mail/nullmailer/Makefile b/mail/nullmailer/Makefile index e728180b856c..406c32e3b14b 100644 --- a/mail/nullmailer/Makefile +++ b/mail/nullmailer/Makefile @@ -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 @@ DISTNAME= ${PORTNAME}-1.00RC5 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 --git a/mail/nullmailer/pkg-deinstall b/mail/nullmailer/pkg-deinstall new file mode 100644 index 000000000000..d49e047ad1dc --- /dev/null +++ b/mail/nullmailer/pkg-deinstall @@ -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 unsent 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 --git a/mail/nullmailer/pkg-install b/mail/nullmailer/pkg-install index 287d853da6aa..91fca36c8ef0 100644 --- a/mail/nullmailer/pkg-install +++ b/mail/nullmailer/pkg-install @@ -37,7 +37,7 @@ if [ x"$2" = xPRE-INSTALL ]; then 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,8 +50,8 @@ if [ x"$2" = xPRE-INSTALL ]; then 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 @@ -60,4 +60,38 @@ if [ x"$2" = xPRE-INSTALL ]; then 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 --git a/mail/nullmailer/pkg-message b/mail/nullmailer/pkg-message index c88f536f8101..08408035a7da 100644 --- a/mail/nullmailer/pkg-message +++ b/mail/nullmailer/pkg-message @@ -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 --git a/mail/nullmailer/pkg-plist b/mail/nullmailer/pkg-plist index 89a75952d432..2b058d2ec92b 100644 --- a/mail/nullmailer/pkg-plist +++ b/mail/nullmailer/pkg-plist @@ -7,11 +7,22 @@ sbin/nullmailer-send 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 |