diff --git a/installer/dataease/bin/dataease/dataease.service b/installer/dataease/bin/dataease/dataease.service index 6364c0a46c..2752d16200 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 start -} +[Service] +User=root +Group=root -function stopDATAEASE -{ - dectl stop -} +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/dectl start +ExecStop=/usr/bin/dectl stop +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/install.sh b/installer/install.sh index 7111eff777..f49a596679 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -28,7 +28,7 @@ if [ -f /usr/bin/dectl ]; then fi set -a -if [[ $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 INSTALL_TYPE='upgrade' else @@ -48,7 +48,7 @@ DE_RUN_BASE=$DE_BASE/dataease2.0 conf_folder=${DE_RUN_BASE}/conf templates_folder=${DE_RUN_BASE}/templates -if [[ $DE_RUN_BASE ]];then +if [[ -d $DE_RUN_BASE ]];then for image in $(grep "image: " $DE_RUN_BASE/docker*.yml | awk -F 'image:' '{print $2}'); do image_path=$(eval echo $image) image_name=$(echo $image_path | awk -F "[/]" '{print $3}') @@ -122,7 +122,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 @@ -203,21 +203,17 @@ 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 @@ -251,8 +247,7 @@ if [[ $http_code == 200 ]];then fi log "启动服务" -dectl start | 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 access_port=$DE_PORT if [[ $DE_INSTALL_MODE != "community" ]];then diff --git a/installer/uninstall.sh b/installer/uninstall.sh index 433f478122..f28e1cbf0a 100644 --- a/installer/uninstall.sh +++ b/installer/uninstall.sh @@ -18,14 +18,27 @@ 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) fi -echo "停止 DataEase 服务" -dectl stop - # 清理 DataEase 相关镜像 if test ! -z "$(docker images -f dangling=true -q)"; then echo "清理虚悬镜像"