deploy.sh 2.07 KB
#!/bin/bash
org_dir=`pwd`
script_dir=$(cd `dirname $0`; pwd)
cont_name="finance_serv"
prj_name="finance_serv"
serv_port=19111
host_log_dir=/data/vion-data/$cont_name/logs
cont_log_dir=/usr/local/tomcat/logs
host_appendix_path=/data/face-web/www/static/pics/cache/finance/
cont_appendix_path=/data/finance/
#cont_log_dir=/usr/local/tomcat/logs

echo ============= env check ===============
if [ ! $db_serv_ip ]; then
    echo db_serv_ip missing.
    exit 1
else
    echo auth_serv_ip=$db_serv_ip
fi
if [ ! $auth_serv_ip ]; then
    echo auth_serv_ip missing.
    exit 1
else
    echo auth_serv_ip=$auth_serv_ip
fi
if [ ! $app_serv_ip ]; then
    echo app_serv_ip missing.
    exit 1
else
    echo app_serv_ip=$app_serv_ip
fi
echo ========== env check end ==============

echo "delete old $cont_name container."
docker rm -f $cont_name
echo "docker run --name $cont_name --restart=always -d -p $serv_port:8080 -v $host_log_dir:$cont_log_dir  192.168.9.26:5000/tomcat85_oraclejdk:latest"
docker run --name $cont_name --restart=always -d -p $serv_port:8080 -v $host_log_dir:$cont_log_dir -v $host_appendix_path:$cont_appendix_path 192.168.9.26:5000/tomcat85_oraclejdk:latest

echo "cd $script_dir"
cd $script_dir

echo ============= replace configure files ===============
cp application.yml.in application.yml
sed -i "s/PH_DB_SERV_IP/$db_serv_ip/g" application.yml
sed -i "s/PH_AUTH_SERV_IP/$auth_serv_ip/g" application.yml
sed -i "s/PH_APP_SERV_IP/$app_serv_ip/g" application.yml
mkdir -p ./WEB-INF/classes/
mv application.yml ./WEB-INF/classes/
jar uvf ./"$prj_name"-latest.war ./WEB-INF/classes/application.yml
echo ========== process configure files end ==============

echo "============= start deploy $cont_name ================"
if [ -f $script_dir/"$prj_name"-latest.war ]; then
    docker cp ./"$prj_name"-latest.war $cont_name:/usr/local/tomcat/webapps/$cont_name.war
else
    echo "============ program file not exit ============"
fi

docker restart $cont_name
echo "sleep a while"
sleep 3

echo "cd $org_dir"
cd $org_dir

echo "deploy finished."