作者 yangfu

deploy.sh

#!/usr/bin/env bash
##部署脚本/文件路径
deploy_shell_path="/home/tiptok/test/ability.tar"
#deploy_shell_path="/home/tiptok/test/ability.tar"
deploy_shell_path="/home/tiptok/test/ability.zip"
go build -o ability main.go
chmod +x ability
tar -zcvf ${deploy_shell_path} ability conf deploy.sh run.sh start.sh stop.sh
#tar -zcvf ${deploy_shell_path} ability conf deploy.sh run.sh start.sh stop.sh
zip -r ${deploy_shell_path} ability conf deploy.sh run.sh start.sh stop.sh
... ...
... ... @@ -11,13 +11,20 @@ project_path="${project_root_path}/${project_name}"
project_bak_path="/home/tiptok/www/bin_bak"
projcet_bak_file="${project_bak_path}/${time}_${project_name}.tar"
project_gzip_file="${deploy_shell_path}/${project_name}.tar"
## 看压缩文件的格式 tar / zip
#project_gzip_file="${deploy_shell_path}/${project_name}.tar"
project_gzip_file="${deploy_shell_path}/${project_name}.zip"
conpress_type="${project_gzip_file##*.}"
echo "------begin deploy-------"
echo "ProjectName: ${project_name}"
echo "ProjectPath: ${project_path}"
echo "ProjectBakFile : ${projcet_bak_file}"
echo "ProjectGzipFile : ${project_gzip_file}"
echo "ConpressType : ${conpress_type}"
if [ ! -d ${project_bak_path} ];then
mkdir -p ${project_bak_path}
... ... @@ -38,8 +45,13 @@ if [ ! -e ${project_path} ];then
mkdir -p ${project_path}
echo "mkdir ${project_path}"
fi
if [ -f ${project_gzip_file} ];then
if [ ${conpress_type} == "tar" ];then
tar -xzf ${project_gzip_file} -C "${project_root_path}/${project_name}"||(echo "tar -x failed"; exit 1)
elif [ ${conpress_type} == "zip" ];then
unzip -o ${project_gzip_file} -d "${project_root_path}/${project_name}"||(echo "tar -x failed"; exit 1)
fi
rm -fr ${project_gzip_file}
else
echo "project_gzip_file not exists! please upload zip file ..."
... ...