From fd71f08359eba049109c5d2281708db73238be8a Mon Sep 17 00:00:00 2001 From: camield Date: Wed, 23 Feb 2000 10:26:13 +0000 Subject: [PATCH] - mkdir, cp -> INSTALL_* macros - clean-up pkg/INSTALL (qmail now builds as non-root, if qmail accounts exist) The mysql and postfix ports could also use the create_user and/or create_group shell functions, as they do a bit more error-checking. - add obsd tags to INSTALL/DEINSTALL - fix mastersite - explicit warning that qmail does not automagically work after install --- mail/qmail/Makefile | 13 +-- mail/qmail/pkg/DEINSTALL | 3 +- mail/qmail/pkg/INSTALL | 186 ++++++++++++++++----------------------- 3 files changed, 83 insertions(+), 119 deletions(-) diff --git a/mail/qmail/Makefile b/mail/qmail/Makefile index aa2e66eb39d..95a05e847ff 100644 --- a/mail/qmail/Makefile +++ b/mail/qmail/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.2 2000/02/11 01:10:06 espie Exp $ +# $OpenBSD: Makefile,v 1.3 2000/02/23 10:26:13 camield Exp $ DISTNAME= qmail-1.03 CATEGORIES= mail @@ -9,7 +9,7 @@ MASTER_SITES= ftp://ftp.net.ohio-state.edu/pub/networking/mail/qmail/ \ ftp://ftp.id.wustl.edu/pub/qmail/ \ ftp://mirror.uk.uu.net/pub/qmail/ \ ftp://ftp.jp.qmail.org/qmail/ \ - http://ftp.rifkin.technion.ac.il/pub/qmail/ \ + ftp://ftp.rifkin.technion.ac.il/pub/qmail/ \ http://koobera.math.uic.edu/www/software/ \ http://pobox.com/~djb/software/ @@ -21,10 +21,10 @@ NO_MTREE= yes RUN_DEPENDS= tcpserver:${PORTSDIR}/net/ucspi-tcp -SETUPFILES= ${WRKSRC}/config ${WRKSRC}/config-fast \ - ${WRKSRC}/dnsfq ${WRKSRC}/dnsip \ +SETUPBINARIES= ${WRKSRC}/dnsfq ${WRKSRC}/dnsip \ ${WRKSRC}/dnsptr ${WRKSRC}/hostname \ ${WRKSRC}/ipmeprint ${WRKSRC}/install +SETUPSCRIPTS= ${WRKSRC}/config ${WRKSRC}/config-fast pre-build: @echo ${CC} ${CFLAGS} > ${WRKSRC}/conf-cc @@ -32,8 +32,9 @@ pre-build: @PREFIX=${PREFIX} ${SH} ${PKGDIR}/INSTALL ${DISTNAME} PRE-INSTALL post-install: - @mkdir -p ${PREFIX}/setup - @cp ${SETUPFILES} ${PREFIX}/setup + ${INSTALL_PROGRAM_DIR} ${PREFIX}/setup + ${INSTALL_PROGRAM} ${SETUPBINARIES} ${PREFIX}/setup + ${INSTALL_SCRIPT} ${SETUPSCRIPTS} ${PREFIX}/setup @PREFIX=${PREFIX} ${SH} ${PKGDIR}/INSTALL ${DISTNAME} POST-INSTALL .include diff --git a/mail/qmail/pkg/DEINSTALL b/mail/qmail/pkg/DEINSTALL index 8668c77f852..90d71b71415 100644 --- a/mail/qmail/pkg/DEINSTALL +++ b/mail/qmail/pkg/DEINSTALL @@ -1,6 +1,5 @@ #!/bin/sh -# -# +# $OpenBSD: DEINSTALL,v 1.2 2000/02/23 10:26:14 camield Exp $ PATH=/bin:/usr/bin:/sbin:/usr/sbin QMAILDIR=${PKG_PREFIX:-/var/qmail} diff --git a/mail/qmail/pkg/INSTALL b/mail/qmail/pkg/INSTALL index 1e340decac2..9fc269496a8 100644 --- a/mail/qmail/pkg/INSTALL +++ b/mail/qmail/pkg/INSTALL @@ -1,122 +1,79 @@ #!/bin/sh +# $OpenBSD: INSTALL,v 1.2 2000/02/23 10:26:14 camield Exp $ # -# Inspired by INSTALL from postfix port by dugsong@ +# Written by Camiel Dobbelaar , 2000 +# This file is in the public domain. PATH=/bin:/usr/bin:/sbin:/usr/sbin QMAILDIR=${PREFIX:-$PKG_PREFIX} +NOSHELL=/sbin/nologin -# Unlikely, but not impossible: these UIDs may clash -# with already installed UIDs. -# Workaround: make these users and groups yourself -# before installing the port or package. +QMAILGID=2850 +NOFILESGID=32750 -ALIASUID=2750 +ALIASUID=2849 QMAILDUID=2850 QMAILLUID=2851 QMAILPUID=2852 QMAILQUID=2853 QMAILRUID=2854 QMAILSUID=2855 -QMAILGID=2850 -NOFILESGID=32750 -# set up qmail user/group accounts. -# -do_accts() +# create_group and create_user work like this: +# 1) if user or group already exist: return (success) +# 2) if uid or gid already exist: abort with exitcode 1 (fail) +# 3) create user or group: abort with exitcode 1 if this operation fails, +# otherwise return (success) +# BUGS: +# - no argument checking +# - step 1) could do additional checking on the other password/group field(s) + +create_group() { - # Create qmail and nofiles group. - # qmail - line=`egrep '^qmail:' /etc/group` - if [ "$line" != "" ]; then - echo -n "-> Using " - QMAILGID=`echo $line | cut -f3 -d:` - else - echo -n "-> Creating " - echo "qmail:*:${QMAILGID}:" >> /etc/group - fi - echo "group 'qmail', gid $QMAILGID" - # nofiles - line=`egrep '^nofiles:' /etc/group` - if [ "$line" != "" ]; then - echo -n "-> Using " - NOFILESGID=`echo $line | cut -f3 -d:` - else - echo -n "-> Creating " - echo "nofiles:*:${NOFILESGID}:" >> /etc/group - fi - echo "group 'nofiles', gid $NOFILESGID" + GROUP=$1 + GID=$2 - # Create users alias, qmaild, qmaill, qmailp, qmailq, qmailr, qmails - # alias - line=`egrep '^alias:' /etc/passwd` - if [ "$line" != "" ]; then - echo -n "-> Using " - ALIASUID=`echo $line | cut -f3 -d:` - else - echo -n "-> Creating " - chpass -l -a "alias:*:${ALIASUID}:${NOFILESGID}::::QMAIL:${QMAILDIR}/alias:/sbin/nologin" - fi - echo "account 'alias', uid $ALIASUID, gid $NOFILESGID" - # qmaild - line=`egrep '^qmaild:' /etc/passwd` - if [ "$line" != "" ]; then - echo -n "-> Using " - QMAILDUID=`echo $line | cut -f3 -d:` - else - echo -n "-> Creating " - chpass -l -a "qmaild:*:${QMAILDUID}:${NOFILESGID}::::QMAIL:${QMAILDIR}:/sbin/nologin" - fi - echo "account 'qmaild', uid $QMAILDUID, gid $NOFILESGID" - # qmaill - line=`egrep '^qmaill:' /etc/passwd` - if [ "$line" != "" ]; then - echo -n "-> Using " - QMAILLUID=`echo $line | cut -f3 -d:` - else - echo -n "-> Creating " - chpass -l -a "qmaill:*:${QMAILLUID}:${NOFILESGID}::::QMAIL:${QMAILDIR}:/sbin/nologin" - fi - echo "account 'qmaill', uid $QMAILLUID, gid $NOFILESGID" - # qmailp - line=`egrep '^qmailp:' /etc/passwd` - if [ "$line" != "" ]; then - echo -n "-> Using " - QMAILPUID=`echo $line | cut -f3 -d:` - else - echo -n "-> Creating " - chpass -l -a "qmailp:*:${QMAILPUID}:${NOFILESGID}::::QMAIL:${QMAILDIR}:/sbin/nologin" - fi - echo "account 'qmailp', uid $QMAILPUID, gid $NOFILESGID" - # qmailq - line=`egrep '^qmailq:' /etc/passwd` - if [ "$line" != "" ]; then - echo -n "-> Using " - QMAILQUID=`echo $line | cut -f3 -d:` - else - echo -n "-> Creating " - chpass -l -a "qmailq:*:${QMAILQUID}:${QMAILGID}::::QMAIL:${QMAILDIR}:/sbin/nologin" - fi - echo "account 'qmailq', uid $QMAILQUID, gid $QMAILGID" - # qmailr - line=`egrep '^qmailr:' /etc/passwd` - if [ "$line" != "" ]; then - echo -n "-> Using " - QMAILRUID=`echo $line | cut -f3 -d:` - else - echo -n "-> Creating " - chpass -l -a "qmailr:*:${QMAILRUID}:${QMAILGID}::::QMAIL:${QMAILDIR}:/sbin/nologin" - fi - echo "account 'qmailr', uid $QMAILRUID, gid $QMAILGID" - # qmails - line=`egrep '^qmails:' /etc/passwd` - if [ "$line" != "" ]; then - QMAILSUID=`echo $line | cut -f3 -d:` - echo -n "-> Using " - else - echo -n "-> Creating " - chpass -l -a "qmails:*:${QMAILSUID}:${QMAILGID}::::QMAIL:${PREFIX}:/sbin/nologin" - fi - echo "account 'qmails', uid $QMAILSUID, gid $QMAILGID" + echo -n "creating group '$GROUP' with gid '$GID': " + + if grep -q "^$GROUP:" /etc/group; then + echo "OK, group already exists" >&2 + return + fi + cut -f3 -d':' /etc/group | grep -qw $GID + if [ $? == 0 ]; then + echo "ERR, gid taken" >&2 + exit 1 + fi + echo "$GROUP:*:$GID:" 2>/dev/null >>/etc/group || { + echo "ERR, cannot append to /etc/group" >&2 + exit 1 + } + echo "OK, created succesfully" >&2 + return +} + +create_user() +{ + NAME=$1; UID=$2; GID=$3 + GECOS=$4; HOME=$5; SHELL=$6 + + echo -n "creating user '$NAME' with uid '$UID': " + + if grep -q "^$NAME:" /etc/passwd; then + echo "OK, user already exists" >&2 + return + fi + cut -f3 -d':' /etc/passwd | grep -qw $UID + if [ $? == 0 ]; then + echo "ERR, uid taken" >&2 + exit 1 + fi + chpass -l -a "$NAME:*:$UID:$GID::::$GECOS:$HOME:$SHELL" 2>/dev/null || { + echo "ERR, cannot add user to database" >&2 + exit 1 + } + echo "OK, created successfully" >&2 + return } do_advice() @@ -125,6 +82,8 @@ do_advice() echo "qmail is installed" echo "----------------" echo + echo "qmail does NOT automatically work yet at this point." + echo echo "To activate qmail, please read $QMAILDIR/doc/INSTALL" echo "Steps 1, 2, 3 and 5 have been done by this port/package." echo "The config command from step 4 can be found in $QMAILDIR/setup" @@ -150,22 +109,27 @@ do_advice() do_aliases() { - touch ${QMAILDIR}/alias/.qmail-postmaster \ - ${QMAILDIR}/alias/.qmail-mailer-daemon \ - ${QMAILDIR}/alias/.qmail-root - chmod 644 ${QMAILDIR}/alias/.qmail-postmaster \ - ${QMAILDIR}/alias/.qmail-mailer-daemon \ - ${QMAILDIR}/alias/.qmail-root + cd $QMAILDIR/alias + touch .qmail-postmaster .qmail-mailer-daemon .qmail-root + chmod 644 .qmail-postmaster .qmail-mailer-daemon .qmail-root } case $2 in PRE-INSTALL) - do_accts + create_group qmail $QMAILGID + create_group nofiles $NOFILESGID + create_user alias $ALIASUID $NOFILESGID qmail $QMAILDIR/alias $NOSHELL + create_user qmaild $QMAILDUID $NOFILESGID qmail $QMAILDIR $NOSHELL + create_user qmaill $QMAILLUID $NOFILESGID qmail $QMAILDIR $NOSHELL + create_user qmailp $QMAILPUID $NOFILESGID qmail $QMAILDIR $NOSHELL + create_user qmailq $QMAILQUID $QMAILGID qmail $QMAILDIR $NOSHELL + create_user qmailr $QMAILRUID $QMAILGID qmail $QMAILDIR $NOSHELL + create_user qmails $QMAILSUID $QMAILGID qmail $QMAILDIR $NOSHELL ;; POST-INSTALL) # Install will abort because it cannot install all files. # It will make qmail/queue though, which is what we want. - sh -c "${QMAILDIR}/setup/install >/dev/null 2>&1" + sh -c "$QMAILDIR/setup/install >/dev/null 2>&1" do_aliases do_advice ;;