trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hfutm...@apache.org
Subject [1/2] incubator-trafodion git commit: [TRAFODION-2539] pyinstaller - set actual trafodion group if trafodion user exists
Date Mon, 27 Mar 2017 05:54:26 GMT
Repository: incubator-trafodion
Updated Branches:
  refs/heads/release2.1 e8a88e5fa -> c58a1809f


[TRAFODION-2539] pyinstaller - set actual trafodion group if trafodion user exists


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/3f85cf8b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/3f85cf8b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/3f85cf8b

Branch: refs/heads/release2.1
Commit: 3f85cf8bf33712c50b84abf9c0e55693ef873166
Parents: a48a06d
Author: Eason <hfutmkby@gmail.com>
Authored: Thu Mar 16 17:22:39 2017 +0800
Committer: Eason <hfutmkby@gmail.com>
Committed: Fri Mar 17 11:24:08 2017 +0800

----------------------------------------------------------------------
 install/python-installer/scripts/traf_user.py | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3f85cf8b/install/python-installer/scripts/traf_user.py
----------------------------------------------------------------------
diff --git a/install/python-installer/scripts/traf_user.py b/install/python-installer/scripts/traf_user.py
index 09a346a..05b132c 100755
--- a/install/python-installer/scripts/traf_user.py
+++ b/install/python-installer/scripts/traf_user.py
@@ -43,13 +43,12 @@ def run():
     elif 'APACHE' in distro:
         hadoop_type = 'apache'
 
-    traf_user = dbcfgs['traf_user']
-    traf_group = traf_user
-    home_dir = cmd_output('cat /etc/default/useradd |grep HOME |cut -d "=" -f 2').strip()
+    home_dir = cmd_output('cat /etc/default/useradd |grep HOME |cut -d "=" -f 2')
     # customize trafodion home dir
     if dbcfgs.has_key('home_dir') and dbcfgs['home_dir']:
         home_dir = dbcfgs['home_dir']
 
+    traf_user = dbcfgs['traf_user']
     traf_user_dir = '%s/%s' % (home_dir, traf_user)
     traf_dirname = dbcfgs['traf_dirname']
     traf_home = '%s/%s' % (traf_user_dir, traf_dirname)
@@ -60,13 +59,18 @@ def run():
     ulimits_file = '/etc/security/limits.d/%s.conf' % traf_user
 
     # create trafodion user and group
-    if not cmd_output('getent group %s' % traf_group):
-        run_cmd('groupadd %s > /dev/null 2>&1' % traf_group)
-
-    if not cmd_output('getent passwd %s' % traf_user):
+    if cmd_output('getent passwd %s' % traf_user):
+        # trafodion user exists, set actual trafodion group
+        traf_group = cmd_output('id -ng %s' % traf_user)
+    else:
+        # default trafodion group
+        traf_group = traf_user
+        if not cmd_output('getent group %s' % traf_group):
+            run_cmd('groupadd %s > /dev/null 2>&1' % traf_group)
         traf_pwd = dbcfgs['traf_pwd']
         run_cmd('useradd --shell /bin/bash -m %s -g %s --home %s --password "$(openssl passwd
%s)"' % (traf_user, traf_group, traf_user_dir, traf_pwd))
-    elif not os.path.exists(traf_user_dir):
+
+    if not os.path.exists(traf_user_dir):
         run_cmd('mkdir -p %s' % traf_user_dir)
         run_cmd('chmod 700 %s' % traf_user_dir)
 


Mime
View raw message