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