diff --git a/installer/dataease/bin/dataease/dataease.service b/installer/dataease/bin/dataease/dataease.service index 6e6e57396c..245c350ba1 100644 --- a/installer/dataease/bin/dataease/dataease.service +++ b/installer/dataease/bin/dataease/dataease.service @@ -1,43 +1,17 @@ -#!/bin/bash -# chkconfig: 2345 10 90 -# description: DATAEASE service +[Unit] +Description=DataEase Service +After=docker.service +Requires=docker.service -function startDATAEASE -{ - dectl reload -} +[Service] +User=root +Group=root -function stopDATAEASE -{ - dectl uninstall -} +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/dectl reload +ExecStop=/usr/bin/dectl uninstall +ExecReload=/usr/bin/dectl reload -function restartDATAEASE -{ - 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 +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/installer/dataease/install.sh b/installer/dataease/install.sh index 6560f67d28..fa13bf4b85 100755 --- a/installer/dataease/install.sh +++ b/installer/dataease/install.sh @@ -24,7 +24,7 @@ if [ -f /usr/bin/dectl ]; then fi 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 INSTALL_TYPE='upgrade' else @@ -231,7 +231,7 @@ else cp docker/bin/* /usr/bin/ cp docker/service/docker.service /etc/systemd/system/ chmod +x /usr/bin/docker* - chmod 754 /etc/systemd/system/docker.service + chmod 644 /etc/systemd/system/docker.service log "... 启动 docker" systemctl enable docker; systemctl daemon-reload; service docker start 2>&1 | tee -a ${CURRENT_DIR}/install.log else @@ -316,22 +316,20 @@ else cd - 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 - chkconfig --add dataease + chkconfig --del dataease fi -if [ -f /etc/rc.d/rc.local ];then - dataeaseService=$(grep "service dataease start" /etc/rc.d/rc.local | wc -l) - 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 +if [[ -f /etc/init.d/dataease ]];then + rm -f /etc/init.d/dataease 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 sysctl -w vm.max_map_count=2000000 echo "vm.max_map_count=2000000" >> /etc/sysctl.conf @@ -364,8 +362,7 @@ if [[ $http_code == 200 ]];then fi log "启动服务" -dectl reload | tee -a ${CURRENT_DIR}/install.log -dectl status 2>&1 | tee -a ${CURRENT_DIR}/install.log +systemctl start dataease 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 diff --git a/installer/dataease/uninstall.sh b/installer/dataease/uninstall.sh index c771897068..2b55094203 100644 --- a/installer/dataease/uninstall.sh +++ b/installer/dataease/uninstall.sh @@ -18,6 +18,22 @@ case $input in ;; 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 # 获取已安装的 DataEase 的运行目录 DE_BASE=$(grep "^DE_BASE=" /usr/bin/dectl | cut -d'=' -f2)