forked from github/dataease
Merge pull request #7751 from dataease/pr@v2_refactor_dectl
refactor: 优化dectl脚本
This commit is contained in:
commit
af9664fb32
@ -7,7 +7,7 @@ DE_RUNNING_BASE=${DE_BASE}/dataease2.0
|
|||||||
need_init_apisix=false
|
need_init_apisix=false
|
||||||
compose_files="-f docker-compose.yml"
|
compose_files="-f docker-compose.yml"
|
||||||
compose_cmd="docker-compose"
|
compose_cmd="docker-compose"
|
||||||
server_url="github.com"
|
server_url=""
|
||||||
current_version=""
|
current_version=""
|
||||||
latest_version=""
|
latest_version=""
|
||||||
|
|
||||||
@ -28,12 +28,6 @@ if [[ ! ${DE_EXTERNAL_MYSQL} ]] || [ "${DE_EXTERNAL_MYSQL}" = "false" ]; then
|
|||||||
compose_files="${compose_files} -f docker-compose-mysql.yml"
|
compose_files="${compose_files} -f docker-compose-mysql.yml"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -x "$(command -v python)" ]]; then
|
|
||||||
py_cmd='python'
|
|
||||||
elif [[ -x "$(command -v python3)" ]]; then
|
|
||||||
py_cmd='python3'
|
|
||||||
fi
|
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
echo "DATAEASE 控制脚本"
|
echo "DATAEASE 控制脚本"
|
||||||
echo
|
echo
|
||||||
@ -126,33 +120,32 @@ function _get_available_server() {
|
|||||||
git_urls=('github.com')
|
git_urls=('github.com')
|
||||||
|
|
||||||
for git_url in ${git_urls[*]}; do
|
for git_url in ${git_urls[*]}; do
|
||||||
success="true"
|
|
||||||
|
|
||||||
echo -ne "检测 ${git_url} ... "
|
echo -ne "检测 ${git_url} ... "
|
||||||
curl -m 5 -kIs https://${git_url} >/dev/null
|
curl -m 5 -kIs https://${git_url} >/dev/null
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "failed"
|
echo "failed"
|
||||||
success="false"
|
|
||||||
else
|
else
|
||||||
echo "ok"
|
echo "ok"
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ${success} == "true" ]]; then
|
|
||||||
server_url=${git_url}
|
server_url=${git_url}
|
||||||
break
|
break
|
||||||
else
|
|
||||||
unset server_url
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ "x${server_url}" == "x" ]]; then
|
|
||||||
echo "没有找到稳定的下载服务器,请访问 https://community.fit2cloud.com/#/products/dataease/downloads 下载离线安装包"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
function _get_latest_version() {
|
function _get_latest_version() {
|
||||||
rm -f /tmp/de_latest_release
|
rm -f /tmp/de_latest_release
|
||||||
|
|
||||||
|
_get_available_server
|
||||||
|
if [[ "x${server_url}" == "x" ]];then
|
||||||
|
echo "无法连接版本服务器,请稍候重试"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -x "$(command -v python)" ]]; then
|
||||||
|
py_cmd='python'
|
||||||
|
elif [[ -x "$(command -v python3)" ]]; then
|
||||||
|
py_cmd='python3'
|
||||||
|
fi
|
||||||
|
|
||||||
$py_cmd - <<EOF
|
$py_cmd - <<EOF
|
||||||
# -*- coding: UTF-8 -*-
|
# -*- coding: UTF-8 -*-
|
||||||
import os
|
import os
|
||||||
@ -185,8 +178,6 @@ while (page <= 3):
|
|||||||
if latest_release == None or latest_release == "":
|
if latest_release == None or latest_release == "":
|
||||||
print("Failed to obtain latest version, please try again.")
|
print("Failed to obtain latest version, please try again.")
|
||||||
exit(1)
|
exit(1)
|
||||||
else:
|
|
||||||
print("latest version is %s" % (latest_release))
|
|
||||||
|
|
||||||
# 记录最新版本号
|
# 记录最新版本号
|
||||||
os.popen("echo "+latest_release+" > /tmp/de_latest_release")
|
os.popen("echo "+latest_release+" > /tmp/de_latest_release")
|
||||||
@ -255,13 +246,10 @@ function version() {
|
|||||||
_get_current_version
|
_get_current_version
|
||||||
_get_latest_version
|
_get_latest_version
|
||||||
echo "current version is $current_version"
|
echo "current version is $current_version"
|
||||||
|
echo "latest version is $latest_version"
|
||||||
}
|
}
|
||||||
function upgrade() {
|
function upgrade() {
|
||||||
echo
|
version
|
||||||
_get_current_version
|
|
||||||
echo "检测当前版本为${current_version}"
|
|
||||||
_get_available_server
|
|
||||||
_get_latest_version
|
|
||||||
|
|
||||||
if [ "${latest_version}" = "" ]; then
|
if [ "${latest_version}" = "" ]; then
|
||||||
echo "未获取到最新版本"
|
echo "未获取到最新版本"
|
||||||
@ -269,9 +257,14 @@ function upgrade() {
|
|||||||
elif [ "${latest_version}" = "${current_version}" ]; then
|
elif [ "${latest_version}" = "${current_version}" ]; then
|
||||||
echo "最新版本与当前版本一致,退出升级过程"
|
echo "最新版本与当前版本一致,退出升级过程"
|
||||||
exit 0
|
exit 0
|
||||||
|
else
|
||||||
|
if [[ ! "$latest_version" =~ ^v2.* ]];then
|
||||||
|
echo "获取到的最新版本与当前版本不匹配,请访问 https://community.fit2cloud.com/#/products/dataease/downloads 下载离线安装包"
|
||||||
|
exit 1
|
||||||
else
|
else
|
||||||
echo "检测到 ${server_url} 上最新版本为 ${latest_version} 即将执行在线升级..."
|
echo "检测到 ${server_url} 上最新版本为 ${latest_version} 即将执行在线升级..."
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
echo "开始下载最新版本..."
|
echo "开始下载最新版本..."
|
||||||
|
Loading…
Reference in New Issue
Block a user