#!/bin/bash
BUILD_ID=DONTKILLME
pas_project=pas-cloud-service-auth
pas_origin_package=pas-cloud-service-auth-1.0.1-SNAPSHOT-assembly.tar.gz
pas_targe_tpath=/usr/a_pas_test
pas_origin_path=/usr/a_pas_deploy
pas_path=/usr/$pas_project/
pas_deploy_path=$pas_origin_path/$pas_origin_package
#解压要安装的程序包
echo $pas_deploy_path
if [ -f "$pas_deploy_path" ]; then
cd /$pas_origin_path/;
tar -zxvf $pas_origin_package;
mv $pas_project-1.0.1-SNAPSHOT $pas_project
echo "解压要安装的程序包"
else
exit 1
fi
sleep 3s
#杀死当前正在运行的程序1
if [ -d "$pas_path" ]; then
authPid=$(ps -ef |grep java|grep $pas_path |grep -v grep|awk '{print $2}')
for i in $authPid
do
echo "2Kill the $1 process [ $i ]"
#kill -9 $i
done
fi
#删除源程序包
if [ -d "$pas_targe_tpath/$pas_project" ]; then
cd $pas_targe_tpath/;
rm -rf $pas_project;
echo "3删除源程序包"
fi
#移动要安装的程序
if [ ! -d "$pas_targe_tpath/$pas_project" ]; then
mv $pas_origin_path/$pas_project $pas_targe_tpath/
echo "4移动要安装的程序"
fi
#执行程序
if [ -d "$pas_targe_tpath/$pas_project" ]; then
cd $pas_targe_tpath/$pas_project/bin;
#sh start.sh;
echo "5执行程序"
fi
sleep 10s
#判断线程是否启动
if [ -d "$pas_path" ]; then
newPid=$(ps -ef |grep java|grep $pas_path |grep -v grep|awk '{print $2}')
echo "6判断线程是否启动:$newPid"
if [ ! -n "$newPid" ]; then
exit 1
fi
fi