From 9d7c30336eed20e19cf83fba77a990e15a207665 Mon Sep 17 00:00:00 2001 From: ibuler Date: Mon, 11 Jan 2016 18:12:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=AD=E6=96=87=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install/next.py | 8 ++++---- install/zzjumpserver.sh | 11 +++++++++++ juser/user_api.py | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 install/zzjumpserver.sh diff --git a/install/next.py b/install/next.py index a68eb66bc..62814ee67 100755 --- a/install/next.py +++ b/install/next.py @@ -81,9 +81,9 @@ class Setup(object): os.system('id %s &> /dev/null || useradd %s' % (self.admin_user, self.admin_user)) @staticmethod - def _ensure_sh(): - jshell = os.path.join(jms_dir, 'connect.py') - os.chmod(jshell, 0755) + def _cp_zzsh(): + os.chdir(os.path.join(jms_dir, 'install')) + shutil.copy('zzjumpserver.sh', '/etc/profile.d/') @staticmethod def _run_service(): @@ -97,7 +97,7 @@ class Setup(object): self._sync_db() self._input_admin() self._create_admin() - self._ensure_sh() + self._cp_zzsh() self._run_service() diff --git a/install/zzjumpserver.sh b/install/zzjumpserver.sh new file mode 100644 index 000000000..11c7a3335 --- /dev/null +++ b/install/zzjumpserver.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +if [ "$USER" != "admin" ] || [ "$USER" != "root" ] || [ "$USER" != "" ];then + python /opt/jumpserver/connect.py + if [ $USER == 'guanghongwei' ];then + echo + else + exit 3 + echo + fi +fi diff --git a/juser/user_api.py b/juser/user_api.py index d61ed7d95..a6fc7648a 100644 --- a/juser/user_api.py +++ b/juser/user_api.py @@ -151,8 +151,8 @@ def server_add_user(username, password, ssh_key_pwd='', ssh_key_login_need=True) add a system user in jumpserver 在jumpserver服务器上添加一个用户 """ - bash("useradd -s %s/connect.py '%s'; echo '%s'; echo '%s:%s' | chpasswd " % - (BASE_DIR, username, password, username, password)) + bash("useradd '%s'; echo '%s'; echo '%s:%s' | chpasswd " % + (username, password, username, password)) if ssh_key_login_need: gen_ssh_key(username, ssh_key_pwd)