Merge pull request #8500 from dataease/pr@v2_refactor_installer

refactor: 优化社区版升级企业版脚本,通过 bash install.sh 即可升级
This commit is contained in:
fit2cloudrd 2024-03-14 11:12:30 +08:00 committed by GitHub
commit 602dd79516
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,6 +12,10 @@ function log() {
echo -e "${message}" 2>&1 | tee -a ${CURRENT_DIR}/install.log echo -e "${message}" 2>&1 | tee -a ${CURRENT_DIR}/install.log
} }
function prop {
[ -f "$1" ] | grep -P "^\s*[^#]?${2}=.*$" $1 | cut -d'=' -f2
}
docker_config_folder="/etc/docker" docker_config_folder="/etc/docker"
compose_files="-f docker-compose.yml" compose_files="-f docker-compose.yml"
@ -42,6 +46,13 @@ set -a
if [[ -d $DE_BASE ]] && [[ -f $DE_BASE/dataease2.0/.env ]]; then if [[ -d $DE_BASE ]] && [[ -f $DE_BASE/dataease2.0/.env ]]; then
source $DE_BASE/dataease2.0/.env source $DE_BASE/dataease2.0/.env
INSTALL_TYPE='upgrade' INSTALL_TYPE='upgrade'
conf_install_mode=$(prop $CURRENT_DIR/install.conf DE_INSTALL_MODE)
if [[ $DE_INSTALL_MODE == 'community' ]] && [[ $conf_install_mode == 'enterprise' ]];then
DE_INSTALL_MODE=$conf_install_mode
export DE_INSTALL_MODE
fi
else else
source ${CURRENT_DIR}/install.conf source ${CURRENT_DIR}/install.conf
INSTALL_TYPE='install' INSTALL_TYPE='install'
@ -67,10 +78,6 @@ if [[ -d $DE_RUN_BASE ]];then
done done
fi fi
function prop {
[ -f "$1" ] | grep -P "^\s*[^#]?${2}=.*$" $1 | cut -d'=' -f2
}
echo -e "======================= 开始安装 =======================" 2>&1 | tee -a ${CURRENT_DIR}/install.log echo -e "======================= 开始安装 =======================" 2>&1 | tee -a ${CURRENT_DIR}/install.log
mkdir -p ${DE_RUN_BASE} mkdir -p ${DE_RUN_BASE}
@ -114,7 +121,7 @@ if [ ! -f /usr/bin/dectl ]; then
fi fi
if which getenforce >/dev/null 2>&1 && [ $(getenforce) == "Enforcing" ];then if which getenforce >/dev/null 2>&1 && [ $(getenforce) == "Enforcing" ];then
log "... 关闭 SELINUX" log "关闭 SELINUX"
setenforce 0 setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
fi fi
@ -127,23 +134,23 @@ if which docker >/dev/null 2>&1; then
service docker start >/dev/null 2>&1 | tee -a ${CURRENT_DIR}/install.log service docker start >/dev/null 2>&1 | tee -a ${CURRENT_DIR}/install.log
else else
if [[ -d docker ]]; then if [[ -d docker ]]; then
log "... 离线安装 docker" log "离线安装 docker"
cp docker/bin/* /usr/bin/ cp docker/bin/* /usr/bin/
cp docker/service/docker.service /etc/systemd/system/ cp docker/service/docker.service /etc/systemd/system/
chmod +x /usr/bin/docker* chmod +x /usr/bin/docker*
chmod 644 /etc/systemd/system/docker.service chmod 644 /etc/systemd/system/docker.service
log "... 启动 docker" log "启动 docker"
systemctl enable docker; systemctl daemon-reload; service docker start 2>&1 | tee -a ${CURRENT_DIR}/install.log systemctl enable docker >/dev/null 2>&1; systemctl daemon-reload; systemctl start docker 2>&1 | tee -a ${CURRENT_DIR}/install.log
else else
log "... 在线安装 docker" log "在线安装 docker"
curl -fsSL https://resource.fit2cloud.com/get-docker-linux.sh -o get-docker.sh 2>&1 | tee -a ${CURRENT_DIR}/install.log curl -fsSL https://resource.fit2cloud.com/get-docker-linux.sh -o get-docker.sh 2>&1 | tee -a ${CURRENT_DIR}/install.log
if [[ ! -f get-docker.sh ]];then if [[ ! -f get-docker.sh ]];then
log "docker 在线安装脚本下载失败,请稍候重试" log "docker 在线安装脚本下载失败,请稍候重试"
exit 1 exit 1
fi fi
sudo sh get-docker.sh 2>&1 | tee -a ${CURRENT_DIR}/install.log sudo sh get-docker.sh 2>&1 | tee -a ${CURRENT_DIR}/install.log
log "... 启动 docker" log "启动 docker"
systemctl enable docker; systemctl daemon-reload; service docker start 2>&1 | tee -a ${CURRENT_DIR}/install.log systemctl enable docker >/dev/null 2>&1; systemctl daemon-reload; systemctl start docker 2>&1 | tee -a ${CURRENT_DIR}/install.log
fi fi
if [ ! -d "$docker_config_folder" ];then if [ ! -d "$docker_config_folder" ];then
@ -168,11 +175,11 @@ if [ $? -ne 0 ]; then
chmod +x /usr/bin/docker-compose chmod +x /usr/bin/docker-compose
else else
if [[ -d docker ]]; then if [[ -d docker ]]; then
log "... 离线安装 docker-compose" log "离线安装 docker-compose"
cp docker/bin/docker-compose /usr/bin/ cp docker/bin/docker-compose /usr/bin/
chmod +x /usr/bin/docker-compose chmod +x /usr/bin/docker-compose
else else
log "... 在线安装 docker-compose" log "在线安装 docker-compose"
curl -L https://resource.fit2cloud.com/docker/compose/releases/download/v2.16.0/docker-compose-$(uname -s | tr A-Z a-z)-$(uname -m) -o /usr/local/bin/docker-compose 2>&1 | tee -a ${CURRENT_DIR}/install.log curl -L https://resource.fit2cloud.com/docker/compose/releases/download/v2.16.0/docker-compose-$(uname -s | tr A-Z a-z)-$(uname -m) -o /usr/local/bin/docker-compose 2>&1 | tee -a ${CURRENT_DIR}/install.log
if [[ ! -f /usr/local/bin/docker-compose ]];then if [[ ! -f /usr/local/bin/docker-compose ]];then
log "docker-compose 下载失败,请稍候重试" log "docker-compose 下载失败,请稍候重试"
@ -231,16 +238,16 @@ if [[ ! -f /etc/systemd/system/dataease.service ]];then
fi fi
if [[ $(grep "vm.max_map_count" /etc/sysctl.conf | wc -l) -eq 0 ]];then if [[ $(grep "vm.max_map_count" /etc/sysctl.conf | wc -l) -eq 0 ]];then
sysctl -w vm.max_map_count=2000000 sysctl -w vm.max_map_count=2000000 >/dev/null 2>&1
echo "vm.max_map_count=2000000" >> /etc/sysctl.conf echo "vm.max_map_count=2000000" >> /etc/sysctl.conf >/dev/null 2>&1
elif (( $(grep "vm.max_map_count" /etc/sysctl.conf | awk -F'=' '{print $2}') < 2000000 ));then elif (( $(grep "vm.max_map_count" /etc/sysctl.conf | awk -F'=' '{print $2}') < 2000000 ));then
sysctl -w vm.max_map_count=2000000 sysctl -w vm.max_map_count=2000000 >/dev/null 2>&1
sed -i 's/^vm\.max_map_count.*/vm\.max_map_count=2000000/' /etc/sysctl.conf sed -i 's/^vm\.max_map_count.*/vm\.max_map_count=2000000/' /etc/sysctl.conf
fi fi
if [ $(grep "net.ipv4.ip_forward" /etc/sysctl.conf | wc -l) -eq 0 ];then if [ $(grep "net.ipv4.ip_forward" /etc/sysctl.conf | wc -l) -eq 0 ];then
sysctl -w net.ipv4.ip_forward=1 sysctl -w net.ipv4.ip_forward=1 >/dev/null 2>&1
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf >/dev/null 2>&1
else else
sed -i 's/^net\.ipv4\.ip_forward.*/net\.ipv4\.ip_forward=1/' /etc/sysctl.conf sed -i 's/^net\.ipv4\.ip_forward.*/net\.ipv4\.ip_forward=1/' /etc/sysctl.conf
fi fi