From 81ffdb231afa17635fe1ebcdf10e4f8e9a84b88f Mon Sep 17 00:00:00 2001
From: osetrovich <osetrovich@users.noreply.github.com>
Date: Fri, 26 Jul 2019 15:55:36 +0500
Subject: [PATCH] Fixed up user permissions

---
 debian/postinst | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/debian/postinst b/debian/postinst
index c565c24c3..bd2d28bbb 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -39,12 +39,21 @@ else
     systemctl --system enable $DAP_PREFIX/share/$DAP_APP_NAME.service
 #    systemctl --system start $DAP_APP_NAME
 fi
-    USERMAN=`users | awk '{print $1}'`
-    #groupadd $DAP_CHAINS_NAME
+    #USERMAN=`users | awk '{print $1}'`
+    groupadd $DAP_CHAINS_NAME
     #usermod -aG $DAP_CHAINS_NAME `users | awk '{print $1}'`
+    for username in $(cat /etc/passwd | grep "/home" | cut -d ':' -f1); do
+        usermod -aG $DAP_CHAINS_NAME $username
+    done
     mkdir -p $DAP_PREFIX/var/{run,lib/ca,lib/wallet,lib/global_db} 
     touch $DAP_PREFIX/var/run/kelvin-node.pid 
-    chown -R $USERMAN:$USERMAN $DAP_PREFIX
-    chmod 0775 $DAP_PREFIX/var/{run,lib/ca,lib/wallet,lib/global_db}
+    #chown -R $USERMAN:$USERMAN $DAP_PREFIX
+    for filename in $(find $DAP_PREFIX); do
+        if [ -d $filename ]; then
+            chmod 0775 $filename
+        else
+            chmod 0664 $filename
+        fi
+    done
     
 echo "For start $DAP_APP_NAME - run 'systemctl start $DAP_APP_NAME'"
-- 
GitLab