forked from github/dataease
refactor: installer脚本适配Ubuntu操作系统
This commit is contained in:
parent
7c7d38be24
commit
546d44bcc1
@ -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 start
|
Group=root
|
||||||
}
|
|
||||||
|
|
||||||
function stopDATAEASE
|
Type=oneshot
|
||||||
{
|
RemainAfterExit=yes
|
||||||
dectl stop
|
ExecStart=/usr/bin/dectl start
|
||||||
}
|
ExecStop=/usr/bin/dectl stop
|
||||||
|
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
|
|
@ -28,7 +28,7 @@ if [ -f /usr/bin/dectl ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
set -a
|
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
|
source $DE_BASE/dataease2.0/.env
|
||||||
INSTALL_TYPE='upgrade'
|
INSTALL_TYPE='upgrade'
|
||||||
else
|
else
|
||||||
@ -48,7 +48,7 @@ DE_RUN_BASE=$DE_BASE/dataease2.0
|
|||||||
conf_folder=${DE_RUN_BASE}/conf
|
conf_folder=${DE_RUN_BASE}/conf
|
||||||
templates_folder=${DE_RUN_BASE}/templates
|
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
|
for image in $(grep "image: " $DE_RUN_BASE/docker*.yml | awk -F 'image:' '{print $2}'); do
|
||||||
image_path=$(eval echo $image)
|
image_path=$(eval echo $image)
|
||||||
image_name=$(echo $image_path | awk -F "[/]" '{print $3}')
|
image_name=$(echo $image_path | awk -F "[/]" '{print $3}')
|
||||||
@ -122,7 +122,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
|
||||||
@ -203,21 +203,17 @@ 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/init.d/dataease ]];then
|
||||||
if [ -f /etc/rc.d/rc.local ];then
|
rm -f /etc/init.d/dataease
|
||||||
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
|
|
||||||
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
|
||||||
@ -251,8 +247,7 @@ if [[ $http_code == 200 ]];then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
log "启动服务"
|
log "启动服务"
|
||||||
dectl start | 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
|
|
||||||
|
|
||||||
access_port=$DE_PORT
|
access_port=$DE_PORT
|
||||||
if [[ $DE_INSTALL_MODE != "community" ]];then
|
if [[ $DE_INSTALL_MODE != "community" ]];then
|
||||||
|
@ -18,14 +18,27 @@ 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)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "停止 DataEase 服务"
|
|
||||||
dectl stop
|
|
||||||
|
|
||||||
# 清理 DataEase 相关镜像
|
# 清理 DataEase 相关镜像
|
||||||
if test ! -z "$(docker images -f dangling=true -q)"; then
|
if test ! -z "$(docker images -f dangling=true -q)"; then
|
||||||
echo "清理虚悬镜像"
|
echo "清理虚悬镜像"
|
||||||
|
Loading…
Reference in New Issue
Block a user