-
Notifications
You must be signed in to change notification settings - Fork 2
/
prod_deploy.sh
54 lines (46 loc) · 1.21 KB
/
prod_deploy.sh
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
#!/bin/bash
# 定义源和目标目录
SOURCE_DIR="/tmp/provider_prod/"
DEST_DIR="provider_prod/"
BAK_DIR="provider_prod_bak/"
ZIP_FILE="/tmp/dist.zip"
EXTRACTED_DIR="/tmp/dist/"
# 检查并解压zip文件
if [ -f "$ZIP_FILE" ]; then
# 解压文件到指定目录
unzip -o "$ZIP_FILE" -d "/tmp/"
echo "Zip file extracted."
# 删除zip文件
rm "$ZIP_FILE"
echo "Zip file removed."
# 重命名解压后的文件夹
if [ -d "$EXTRACTED_DIR" ]; then
mv "$EXTRACTED_DIR" "$SOURCE_DIR"
echo "Extracted folder renamed to $SOURCE_DIR"
else
echo "Error: Extracted directory not found!"
exit 1
fi
else
echo "Error: ZIP file $ZIP_FILE not found!"
exit 1
fi
# 删除备份目录
if [ -d "$BAK_DIR" ]; then
rm -rf "$BAK_DIR"
echo "Old backup directory removed."
fi
# 将当前的dest目录重命名为备份目录
if [ -d "$DEST_DIR" ]; then
mv "$DEST_DIR" "$BAK_DIR"
echo "Current directory backed up."
fi
# 将源目录移动到目标目录
if [ -d "$SOURCE_DIR" ]; then
mv "$SOURCE_DIR" "$DEST_DIR"
echo "New version deployed."
else
echo "Error: Source directory not found!"
exit 1
fi
echo "Deployment completed successfully!"