From 1c623f71e02bbada16dbd968b96ec6d933221699 Mon Sep 17 00:00:00 2001 From: wojiushixiaobai <296015668@qq.com> Date: Sun, 22 Apr 2018 19:22:55 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/upgrade.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 utils/upgrade.sh diff --git a/utils/upgrade.sh b/utils/upgrade.sh new file mode 100644 index 000000000..6e6efcb73 --- /dev/null +++ b/utils/upgrade.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +if [ ! -d "/opt/py3" ]; then +echo -e "\033[31m python3虚拟路径不正确 \033[0m" +echo -e "\033[31m 请手动修改虚拟环境的位置 \033[0m" +exit 0 +else +source /opt/py3/bin/activate +fi + +cd `dirname $0`/ && cd .. && ./jms stop + +jumpserver_backup=/tmp/jumpserver_backup$(date -d "today" +"%Y%m%d_%H%M%S") +mkdir -p $jumpserver_backup +cp -r ./* $jumpserver_backup + +echo -e "\033[31m 是否需要备份Jumpserver数据库 \033[0m" +stty erase ^H +read -p "确认备份请按Y,否则按其他键跳过备份 " a +if [ "$a" == y -o "$a" == Y ];then +echo -e "\033[31m 正在备份数据库 \033[0m" +echo -e "\033[31m 请手动输入数据库信息 \033[0m" +read -p '请输入Jumpserver数据库ip:' DB_HOST +read -p '请输入Jumpserver数据库端口:' DB_PORT +read -p '请输入Jumpserver数据库名称:' DB_NAME +read -p '请输入有权限导出数据库的用户:' DB_USER +read -p '请输入该用户的密码:' DB_PASSWORD +mysqldump -h$DB_HOST -P$DB_PORT -u$DB_USER -p$DB_PASSWORD $DB_NAME > /$jumpserver_backup/$DB_NAME$(date -d "today" +"%Y%m%d_%H%M%S").sql || { +echo -e "\033[31m 备份数据库失败,请检查输入是否有误 \033[0m" +exit 1 +} +echo -e "\033[31m 备份数据库完成 \033[0m" + +else +echo -e "\033[31m 已取消备份数据库操作 \033[0m" +fi + +git pull && pip install -r requirements/requirements.txt && cd utils && sh make_migrations.sh + +echo -e "\033[31m 备份文件存放于$jumpserver_backup目录 \033[0m" + +exit 0 From 5c7acae0183606ec1bedddcccd0ef3e4f6230c6d Mon Sep 17 00:00:00 2001 From: wojiushixiaobai <296015668@qq.com> Date: Sun, 22 Apr 2018 20:18:10 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/__init__.py | 4 ++-- apps/templates/_footer.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/__init__.py b/apps/__init__.py index 7f7347e2e..def994bcd 100644 --- a/apps/__init__.py +++ b/apps/__init__.py @@ -1,5 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# +# -__version__ = "1.2.0" +__version__ = "1.2.1" diff --git a/apps/templates/_footer.html b/apps/templates/_footer.html index dbe60e1bc..f23c89399 100644 --- a/apps/templates/_footer.html +++ b/apps/templates/_footer.html @@ -1,9 +1,9 @@
\ No newline at end of file + From abd20f31b8477d3a35b641b1c9db2e6922472cf7 Mon Sep 17 00:00:00 2001 From: wojiushixiaobai <296015668@qq.com> Date: Sun, 22 Apr 2018 22:37:51 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/upgrade.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/utils/upgrade.sh b/utils/upgrade.sh index 6e6efcb73..878bf770a 100644 --- a/utils/upgrade.sh +++ b/utils/upgrade.sh @@ -1,9 +1,20 @@ #!/bin/bash if [ ! -d "/opt/py3" ]; then -echo -e "\033[31m python3虚拟路径不正确 \033[0m" -echo -e "\033[31m 请手动修改虚拟环境的位置 \033[0m" +echo -e "\033[31m python3虚拟环境不是默认路径 \033[0m" +ps -ef | grep jumpserver/tmp/beat.pid | grep -v grep +if [ $? -ne 0 ] +then +echo -e "\033[31m jumpserver未运行,请到jumpserver目录使用 ./jms start all -d 启动 \033[0m" exit 0 +else +echo -e "\033[31m 正在计算python3虚拟环境路径 \033[0m" +fi +py3pid=`ps -ef | grep jumpserver/tmp/beat.pid | grep -v grep | awk '{print $2}'` +py3file=`cat /proc/$py3pid/cmdline` +py3even=`echo ${py3file%/bin/python3*}` +echo -e "\033[31m python3虚拟环境路径为$py3even \033[0m" +source $py3even/bin/activate else source /opt/py3/bin/activate fi @@ -37,6 +48,8 @@ fi git pull && pip install -r requirements/requirements.txt && cd utils && sh make_migrations.sh +cd .. && ./jms start all -d +echo -e "\033[31m 请检查jumpserver是否启动成功 \033[0m" echo -e "\033[31m 备份文件存放于$jumpserver_backup目录 \033[0m" exit 0