deploy.sh
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
time=$(date +%Y%m%d_%H%m%s)
project_name="ability"
##部署脚本/文件路径
deploy_shell_path="/home/tiptok/test"
##部署路径
project_root_path="/home/tiptok/www"
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"
## 看压缩文件的格式 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}
echo "mkdir ${project_bak_path}"
fi
if [ ! -d ${project_path} ];then
mkdir -p ${project_path}
echo "mkdir ${project_path}"
else
echo "backup : ${projcet_bak_file}"
cd $project_path && tar -zcf ${projcet_bak_file} * ||(echo "backup failed"; exit 1)
rm -fr "${project_path}/" *
fi
echo "------begin tar-------"
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 ..."
exit 0
fi
echo "------begin start-------"
cd ${project_path} && ./start.sh ${project_name}