File debian.postinst of Package netqmail

#!/bin/sh

QMAIL_HOME=/var/lib/qmail
CONFDIR=/etc/qmail

getent group mail >/dev/null || groupadd -r mail
getent group nofiles >/dev/null || groupadd -r nofiles
getent group adm >/dev/null || groupadd -r adm
getent passwd mail >/dev/null || useradd -r -g mail -d "$QMAIL_HOME" -s /sbin/nologin -c "User for qmail" mail
getent passwd alias >/dev/null || useradd -r -g nofiles -d "$QMAIL_HOME/alias" -s /sbin/nologin -c "Alias user for qmail" alias
getent passwd qmaild >/dev/null || useradd -r -g nofiles -d "$QMAIL_HOME" -s /sbin/nologin -c "?mtpd user for qmail" qmaild
getent passwd qmaill >/dev/null || useradd -r -g nofiles -d "$QMAIL_HOME" -s /sbin/nologin -c "Log user for qmail" qmaill
getent passwd qmailp >/dev/null || useradd -r -g nofiles -d "$QMAIL_HOME" -s /sbin/nologin -c "getpw user for qmail" qmailp
getent passwd qmailq >/dev/null || useradd -r -g mail -d "$QMAIL_HOME" -s /sbin/nologin -c "Qmail queue owner" qmailq
getent passwd qmailr >/dev/null || useradd -r -g mail -d "$QMAIL_HOME" -s /sbin/nologin -c "qmail-remote user" qmailr
getent passwd qmails >/dev/null || useradd -r -g mail -d "$QMAIL_HOME" -s /sbin/nologin -c "qmail-send user" qmails

chmod 0750 "$CONFDIR/dkim"
chgrp mail "$CONFDIR/dkim"

cd "$QMAIL_HOME"

cd "$QMAIL_HOME/control"
if [ ! -f me ]; then
    hostname --fqdn >me
fi
if [ ! -f rcpthosts ]; then
    hostname --fqdn >rcpthosts
fi
if [ ! -r servercert.pem ]; then
    oldumask="`umask`"
    umask 0027
    openssl req -new -x509 -nodes -days 366 -out servercert.pem -keyout servercert.pem -batch -subj "/CN=`hostname --fqdn`"
    umask "$oldumask"
    chgrp mail servercert.pem
fi
if [ ! -r clientcert.pem ]; then
    ln -s servercert.pem clientcert.pem
fi
if [ ! -f "dh1024.pem" -o ! -f "dh512.pem" -o ! -f "rsa512.pem" ]; then
    "/usr/lib/qmail/update_tmprsadh"
fi
if [ ! -f "$CONFDIR/dkim/default.key" -a ! -f "$CONFDIR/dkim/default.pub" ]; then
    "/usr/lib/qmail/dkim-genkey" "$CONFDIR/dkim/default"
    chgrp mail "$CONFDIR/dkim/default.key"
    chgrp mail "$CONFDIR/dkim/default.pub"
fi
if [ ! -r "$QMAIL_HOME/queue/lock/tcpto" ]; then
    dd if=/dev/zero of="$QMAIL_HOME/queue/lock/tcpto" bs=2k count=1
    chmod 644 "$QMAIL_HOME/queue/lock/tcpto"
    chown qmailr:mail "$QMAIL_HOME/queue/lock/tcpto"
fi
if [ ! -r "$QMAIL_HOME/queue/lock/trigger" ]; then
    mknod -m 0666 "$QMAIL_HOME/queue/lock/trigger" p
    chown qmails:mail "$QMAIL_HOME/queue/lock/trigger"
fi

chmod -R go-rwx /etc/skel/Maildir

chown -R alias:mail "$QMAIL_HOME/alias"

cd /var/spool/qmail-queue
chown qmailq:mail .
for i in `find lock pid intd todo mess -type d`; do
  chown qmailq:mail $i
done
for i in `find bounce info local remote -type d`; do
  chown qmails:mail $i
done
chown qmails:mail lock/sendmutex
chgrp mail /usr/lib/qmail/*
chown qmailq:mail /usr/lib/qmail/qmail-queue
chmod 0751 /usr/lib/qmail/qmail-remote

#DEBHELPER#
openSUSE Build Service is sponsored by