Update backend/start.sh
Browse files- backend/start.sh +39 -0
backend/start.sh
CHANGED
@@ -1,4 +1,43 @@
|
|
1 |
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
4 |
cd "$SCRIPT_DIR" || exit
|
|
|
1 |
#!/usr/bin/env bash
|
2 |
+
set -e
|
3 |
+
|
4 |
+
# 检查 G_NAME 环境变量是否设置
|
5 |
+
if [ -z "$G_NAME" ]; then
|
6 |
+
echo "环境变量 G_NAME 未设置。"
|
7 |
+
exit 1
|
8 |
+
fi
|
9 |
+
|
10 |
+
# 检查 G_TOKEN 环境变量是否设置
|
11 |
+
if [ -z "$G_TOKEN" ]; then
|
12 |
+
echo "环境变量 G_TOKEN 未设置。"
|
13 |
+
exit 1
|
14 |
+
fi
|
15 |
+
|
16 |
+
# 构建 GitHub 仓库的克隆 URL,包含令牌
|
17 |
+
REPO_URL="https://[email protected]/$G_NAME.git"
|
18 |
+
|
19 |
+
# 检查并创建data目录
|
20 |
+
if [ ! -d "./data" ]; then
|
21 |
+
echo "创建data目录..."
|
22 |
+
mkdir ./data
|
23 |
+
|
24 |
+
if [ $? -ne 0 ]; then
|
25 |
+
echo "创建目录失败,请检查权限。"
|
26 |
+
exit 1
|
27 |
+
fi
|
28 |
+
fi
|
29 |
+
# 克隆仓库
|
30 |
+
echo "正在克隆仓库……"
|
31 |
+
git clone "$REPO_URL" ./data
|
32 |
+
|
33 |
+
# 检查克隆操作是否成功
|
34 |
+
if [ $? -ne 0 ]; then
|
35 |
+
echo "克隆失败,请检查 G_NAME 和 G_TOKEN 是否正确。"
|
36 |
+
exit 1
|
37 |
+
fi
|
38 |
+
|
39 |
+
echo "克隆成功!"
|
40 |
+
|
41 |
|
42 |
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
43 |
cd "$SCRIPT_DIR" || exit
|