diff options
author | Mikhail Gusarov <dottedmag@dottedmag.net> | 2014-02-23 00:52:50 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-02-24 13:16:42 +0000 |
commit | eec81891c4d911af1a9b0afbc2ebe4f5cd445ce5 (patch) | |
tree | 9325cf64aeb790d8517b023c8591cf2545d559d5 /debian/postinst | |
parent | 3fd1a501691b5cb27c17a9354d49db52cf13c4a6 (diff) | |
download | rspamd-eec81891c4d911af1a9b0afbc2ebe4f5cd445ce5.tar.gz rspamd-eec81891c4d911af1a9b0afbc2ebe4f5cd445ce5.zip |
Move preinst to postinst, rspamd does not need anything in preinst
Diffstat (limited to 'debian/postinst')
-rw-r--r-- | debian/postinst | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 000000000..b10ca9c24 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,69 @@ +#!/bin/sh +#DEBHELPER# + +set -e + +case "$1" in + configure) + SERVER_HOME=/var/lib/rspamd + SERVER_RUN=/var/run/rspamd + SERVER_LOG=/var/log/rspamd + SERVER_USER=rspamd + SERVER_NAME="Rspamd spam filtering system" + SERVER_GROUP=rspamd + + # create user to avoid running server as root + # 1. create group if not existing + if ! getent group | grep -q "^$SERVER_GROUP:" ; then + echo -n "Adding group $SERVER_GROUP.." + addgroup --quiet --system $SERVER_GROUP 2>/dev/null ||true + echo "..done" + fi + # 2. create homedir if not existing + test -d $SERVER_HOME || mkdir $SERVER_HOME + test -d $SERVER_RUN || mkdir $SERVER_RUN + test -d $SERVER_LOG || mkdir $SERVER_LOG + # 3. create user if not existing + if ! getent passwd | grep -q "^$SERVER_USER:"; then + echo -n "Adding system user $SERVER_USER.." + adduser --quiet \ + --system \ + --ingroup $SERVER_GROUP \ + --no-create-home \ + --disabled-password \ + $SERVER_USER 2>/dev/null || true + echo "..done" + fi + # 4. adjust passwd entry + usermod -c "$SERVER_NAME" \ + -d $SERVER_HOME \ + -g $SERVER_GROUP \ + $SERVER_USER + # 5. adjust file and directory permissions + if ! dpkg-statoverride --list $SERVER_HOME >/dev/null + then + chown -R $SERVER_USER:$SERVER_GROUP $SERVER_HOME $SERVER_LOG $SERVER_RUN + chmod u=rwx,g=rx,o= $SERVER_HOME + chmod u=rwx,g=rx,o=rx $SERVER_RUN + chmod u=rwx,g=rx,o=rx $SERVER_LOG + fi + # 6. Add the user to the ADDGROUP group + if test -n $ADDGROUP + then + if ! groups $SERVER_USER | cut -d: -f2 | \ + grep -qw $SERVER_GROUP; then + adduser $SERVER_USER $SERVER_GROUP + fi + fi + ;; + + abort-*) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +exit 0 |