Browse Source

dbfile依赖环境变量JUMPDB

master
牛批的一批 5 years ago
parent
commit
4df50638a8
  1. 36
      README.md
  2. 14
      client/jumpcli.py
  3. 12
      server/jumpserver.py

36
README.md

@ -5,14 +5,40 @@
```shell
├── README.md
├── client
│ ├── README.md
│ ├── go.mod
│ ├── go.sum
│ ├── jumpcli.go
│ └── jumpcli.svg
│   ├── README.md
│   ├── go.mod
│   ├── go.sum
│   ├── jumpcli.go
│   ├── jumpcli.py
│   ├── jumpcli.svg
│   └── requirements.txt
└── server
├── jumpserver.py
├── manager_user.sh
├── proto.md
└── requirements.txt
```
### 设置环境变量
'JUMPDB'是sqlite3本地数据库文件路径,这个环境变量是jumpserver和jumpcli必要的一个参数
```shell script
export JUMPDB=/usr/local/jumpserver/jumpserver.db # 设置sqlite3 db文件路径
chmod 755 $JUMPDB # 设置权限755
```
### JumpServer启动
```shell script
./jumpserver.py -host 192.168.1.44 -port 8080
```
### JumpCli命令
把jumpcli拷贝到PATH路径下
```shell script
cp jumpcli.py /usr/bin/jumpcli # 拷贝到path路径
jumpcli # 执行
```

14
client/jumpcli.py

@ -18,7 +18,7 @@ KEYS_UP = (curses.KEY_UP, ord('k'))
KEYS_DOWN = (curses.KEY_DOWN, ord('j'))
KEYS_SELECT = (curses.KEY_RIGHT, ord(' '))
# 数据库文件
# 数据库文件 default
gSqlite3File = "/usr/local/jumpserver/jumpserver.db"
# ssh_private_path ssh私钥路径
@ -28,8 +28,17 @@ if system_type == "Darwin":
elif system_type == "Linux":
ssh_private_path = "/home/%s/.ssh/id_rsa"
else:
print("Don't support your system(%s)" % system_type)
exit(1)
def init():
global gSqlite3File
jumpDb = os.environ.get("JUMPDB")
if jumpDb is not None:
gSqlite3File = jumpDb
else:
print("ERROR: Hadn't set environ var 'JUMPDB' for jump database! mod 755")
exit(1)
class Picker(object):
def __init__(self, options, title=None, indicator='*', default_index=0, multiselect=False, multi_select=False,
@ -278,6 +287,9 @@ def get_hosts(user):
return resp
def main():
# 初始化检测
init()
user = getpass.getuser()
print("current user: " + user)

12
server/jumpserver.py

@ -1,3 +1,4 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import argparse
@ -59,6 +60,14 @@ SSO_TIMER_PERIOD = 5 * 60
# sso过期时间
SSO_EXPIRE_TIMEOUT = 24 * 60 * 60
def init():
global gSqlite3File
jumpDb = os.environ.get("JUMPDB")
if jumpDb is not None:
gSqlite3File = jumpDb
else:
print("ERROR: Hadn't set environ var 'JUMPDB' for jump database! mod 755")
exit(1)
# 解析命令行
def parse_cmd():
@ -776,6 +785,9 @@ def init_log():
def main():
# 初始化检测
init()
# 初始化日志
init_log()

Loading…
Cancel
Save