Merge pull request #7932 from dataease/pr@v1_installer_fit_ubuntu

refactor: installer脚本适配Ubuntu操作系统
This commit is contained in:
fit2cloudrd 2024-01-31 11:40:45 +08:00 committed by GitHub
commit 4147c9b85b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 42 additions and 55 deletions

View File

@ -1,43 +1,17 @@
#!/bin/bash [Unit]
# chkconfig: 2345 10 90 Description=DataEase Service
# description: DATAEASE service After=docker.service
Requires=docker.service
function startDATAEASE [Service]
{ User=root
dectl reload Group=root
}
function stopDATAEASE Type=oneshot
{ RemainAfterExit=yes
dectl uninstall ExecStart=/usr/bin/dectl reload
} ExecStop=/usr/bin/dectl uninstall
ExecReload=/usr/bin/dectl reload
function restartDATAEASE [Install]
{ WantedBy=multi-user.target
stopDATAEASE
startDATAEASE
}
function statusDATAEASE
{
dectl status
}
export HOSTNAME=$HOSTNAME
case "$1" in
start)
startDATAEASE
;;
stop)
stopDATAEASE
;;
restart)
restartDATAEASE
;;
status)
statusDATAEASE
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
;;
esac

View File

@ -24,7 +24,7 @@ if [ -f /usr/bin/dectl ]; then
fi fi
set -a set -a
if [[ $DE_BASE ]] && [[ -f $DE_BASE/dataease/.env ]]; then if [[ -d $DE_BASE ]] && [[ -f $DE_BASE/dataease/.env ]]; then
source $DE_BASE/dataease/.env source $DE_BASE/dataease/.env
INSTALL_TYPE='upgrade' INSTALL_TYPE='upgrade'
else else
@ -231,7 +231,7 @@ else
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 754 /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; systemctl daemon-reload; service docker start 2>&1 | tee -a ${CURRENT_DIR}/install.log
else else
@ -316,22 +316,20 @@ else
cd - cd -
fi fi
log "配置 dataease Service"
cp ${DE_RUN_BASE}/bin/dataease/dataease.service /etc/init.d/dataease
chmod a+x /etc/init.d/dataease
if which chkconfig;then if which chkconfig;then
chkconfig --add dataease chkconfig --del dataease
fi fi
if [ -f /etc/rc.d/rc.local ];then if [[ -f /etc/init.d/dataease ]];then
dataeaseService=$(grep "service dataease start" /etc/rc.d/rc.local | wc -l) rm -f /etc/init.d/dataease
if [ "$dataeaseService" -eq 0 ]; then
echo "sleep 10" >> /etc/rc.d/rc.local
echo "service dataease start" >> /etc/rc.d/rc.local
fi
chmod +x /etc/rc.d/rc.local
fi fi
log "配置 dataease Service"
cp ${DE_RUN_BASE}/bin/dataease/dataease.service /etc/systemd/system/
chmod 644 /etc/systemd/system/dataease.service
log "配置开机自启动"
systemctl enable dataease; systemctl daemon-reload 2>&1 | tee -a ${CURRENT_DIR}/install.log
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
echo "vm.max_map_count=2000000" >> /etc/sysctl.conf echo "vm.max_map_count=2000000" >> /etc/sysctl.conf
@ -364,8 +362,7 @@ if [[ $http_code == 200 ]];then
fi fi
log "启动服务" log "启动服务"
dectl reload | tee -a ${CURRENT_DIR}/install.log systemctl start dataease 2>&1 | tee -a ${CURRENT_DIR}/install.log
dectl status 2>&1 | tee -a ${CURRENT_DIR}/install.log
echo -e "======================= 安装完成 =======================\n" 2>&1 | tee -a ${CURRENT_DIR}/install.log echo -e "======================= 安装完成 =======================\n" 2>&1 | tee -a ${CURRENT_DIR}/install.log
echo -e "请通过以下方式访问:\n URL: http://\$LOCAL_IP:$DE_PORT\n 用户名: admin\n 初始密码: dataease" 2>&1 | tee -a ${CURRENT_DIR}/install.log echo -e "请通过以下方式访问:\n URL: http://\$LOCAL_IP:$DE_PORT\n 用户名: admin\n 初始密码: dataease" 2>&1 | tee -a ${CURRENT_DIR}/install.log

View File

@ -18,6 +18,22 @@ case $input in
;; ;;
esac esac
echo "停止 DataEase 服务"
service dataease stop
echo "移除 DataEase 服务"
if which chkconfig;then
chkconfig --del dataease
fi
if [ -f /etc/systemd/system/dataease.service ];then
systemctl disable dataease
rm -f /etc/systemd/system/dataease.service
systemctl daemon-reload
elif [[ -f /etc/init.d/dataease ]];then
rm -f /etc/init.d/dataease
fi
if [ -f /usr/bin/dectl ]; then if [ -f /usr/bin/dectl ]; then
# 获取已安装的 DataEase 的运行目录 # 获取已安装的 DataEase 的运行目录
DE_BASE=$(grep "^DE_BASE=" /usr/bin/dectl | cut -d'=' -f2) DE_BASE=$(grep "^DE_BASE=" /usr/bin/dectl | cut -d'=' -f2)