]> source.dussan.org Git - rspamd.git/commitdiff
Use more adduser options to shorten preinst
authorMikhail Gusarov <dottedmag@dottedmag.net>
Sat, 22 Feb 2014 23:47:52 +0000 (00:47 +0100)
committerMikhail Gusarov <dottedmag@dottedmag.net>
Sat, 22 Feb 2014 23:47:52 +0000 (00:47 +0100)
debian/preinst

index 3588f2f5bd058b8814b0bc8b9e57277b3f0fee9f..60eb3c400f991cf4bfa17a7dac58924438dd65c2 100644 (file)
@@ -11,35 +11,21 @@ case "$1" in
        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
+       adduser --quiet \
+               --system \
+               --group \
+               --home $SERVER_HOME \
+               --no-create-home \
+               --disabled-login \
+               --gecos "$SERVER_NAME" \
+               $SERVER_USER
+
        # 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
@@ -48,14 +34,6 @@ case "$1" in
            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-upgrade|upgrade)