热卖商品
新闻详情
shell 自动部署tar包_annan211的专栏-CSDN博客
来自 : CSDN技术社区
发布时间:2021-03-25
#!/bin/bash
: !
date 2018-03-15
author Jeff.jing
desc
使用规则
1 脚本需要有执行权限 chmod 755
2 需要将 standalone.tar.gz 压缩文件作为参数传入脚本
!
#接收部署文件名称
standalone_file $1
if [ ! -f $standalone_file ]; then
echo $standalone_file source file is not found,please check it and try again later !
exit 1
fi
if [[ ! -s $standalone_file ]];then
echo ***********************************************************************
echo ***********************************************************************
echo target source file is not found ,please check it and try again later !
echo ***********************************************************************
echo ***********************************************************************
exit 1
fi
if [ ! ${standalone_file##*.} x gz x ];then
echo ***********************************************************************
echo ***********************************************************************
echo target source file type is not .tar.gz ,please check it and try again later !
echo ***********************************************************************
echo ***********************************************************************
exit 1
fi
#备份原项目
backup_dir /opt/profile-facade-auto- date %Y%m%d%H%M%S
echo ***********************************************************************
echo begin backup profile-facade-auto into $backup_dir
sudo mkdir $backup_dir
sudo cp -R /opt/profile-facade-auto/* $backup_dir
echo backup profile-facade-auto into is done
p_id profile-facade-auto.PID
kill_file kil-file
touch $p_id
touch $kill_file
#停止facade-auto 进程
echo ***********************************************************************
echo begin stop profile-facade-auto java process
ps -ef | grep /opt/profile-facade-auto/config/ | grep -v grep | awk {print $2} $p_id
P_ID $(head -1 $p_id | awk {print$1} )
echo $P_ID
if [ ! -f $P_ID ]; then
echo exit failure process : $P_ID
sudo kill -9 ${P_ID} # /dev/null 2 1 需要判断此进程是否真的存在
echo profile-facade-auto has been stoped
fi
sudo rm -rf /opt/profile-facade-auto/
sudo mkdir /opt/profile-facade-auto/
#解压缩目标发布包
echo ***********************************************************************
echo begin install profile-facade-auto service,please wait a second...
sudo tar -zxvf $standalone_file -C /opt/profile-facade-auto
#线上环境配置文件覆盖
sudo cp $backup_dir/config/DP-ProfileFacadeAuto-Traffic/config/automotive-schema-extension.json /opt/profile-facade-auto/config/DP-ProfileFacadeAuto-Traffic/config/
sudo cp $backup_dir/config/DP-ProfileFacadeAuto-Traffic/config/profile-facade-auto.config.yml /opt/profile-facade-auto/config/DP-ProfileFacadeAuto-Traffic/config/
sudo cp $backup_dir/config/DP-ProfileFacadeAuto-Traffic/credential/DP-ProfileFacadeAuto-Traffic.yml /opt/profile-facade-auto/config/DP-ProfileFacadeAuto-Traffic/credential/
sudo cp -R $backup_dir/config/foundation-shared/config/* /opt/profile-facade-auto/config/foundation-shared/config/
#启动项目
echo ***********************************************************************
echo starting profile-facade-auto service
sudo /opt/profile-facade-auto/bin/startup.sh
echo profile-facade-auto start up success !
rm $p_id





本文链接: http://standtar.immuno-online.com/view-766762.html
发布于 : 2021-03-25
阅读(0)
最新动态
2021-03-24
2021-03-25
2021-03-24
2021-03-25
2021-03-24
2021-03-25
2021-03-25
2021-03-25
2021-03-24
2021-03-25
2021-03-24
2021-03-25