From 590d36b01c021fd84f589833dc6131d7796d3d46 Mon Sep 17 00:00:00 2001
From: BlubbFish <blubbfish@noreply.localhost>
Date: Tue, 17 Aug 2021 12:51:23 +0200
Subject: [PATCH] possibility to add more groups to the user

---
 deb/pre-post-build.sh | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/deb/pre-post-build.sh b/deb/pre-post-build.sh
index 27767fd..b11ab9f 100644
--- a/deb/pre-post-build.sh
+++ b/deb/pre-post-build.sh
@@ -4,7 +4,9 @@
 usage() {
   echo "usage: " \
   "NAME=app " \
-  "CONFIGREPLACEASK=setting.conf params.conf"
+  "CONFIGREPLACEASK=setting.conf params.conf " \
+  "[MOREGROUPS=dialout " \
+  "DATADIR=/var/lib/data]"
   "sh pre-post-build.sh"
   exit 1
 }
@@ -25,7 +27,11 @@ echo ""
 echo "if [ \"\$1\" = \"configure\" ]; then"                                                                                                      >> postinst
 echo "  if [ -z \"\`id -u ${NAME}bot  2> /dev/null\`\" ]; then"                                                                                  >> postinst
 echo "    adduser --system --group --home /nonexistent --gecos \"${NAME} User\" --no-create-home --disabled-password --quiet ${NAME}bot || true" >> postinst
-echo "    usermod -G ${NAME}bot,adm ${NAME}bot"                                                                                                  >> postinst
+if [[ -z "$MOREGROUPS" ]]; then
+  echo "    usermod -G ${NAME}bot,adm ${NAME}bot"                                                                                                >> postinst
+else
+  echo "    usermod -G ${NAME}bot,adm,${MOREGROUPS} ${NAME}bot"                                                                                  >> postinst
+fi
 echo "  fi"                                                                                                                                      >> postinst
 echo ""                                                                                                                                          >> postinst
 for conffile in $CONFIGREPLACEASK ; do