From e609574ed78d2d5c3570c5c78f7799c1cc0bca53 Mon Sep 17 00:00:00 2001 From: woon Date: Thu, 24 Aug 2023 16:58:18 +0800 Subject: [PATCH] update --- build.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/build.sh b/build.sh index c6f6d96..60b4066 100644 --- a/build.sh +++ b/build.sh @@ -6,7 +6,7 @@ if id "appruner" >/dev/null 2>&1; then else # 创建 app 用户 echo "Creating user appruner..." - useradd -m -s /bin/bash appruner + sudo useradd -m -s /bin/bash appruner fi @@ -15,21 +15,24 @@ app_path=$(cd "$(dirname "$0")"; pwd) app_name=$(basename "${app_path}") # 执行 git pull 命令 -cd ${app_path} && git pull +# 判断目录是否存在 .git 文件夹 +if [ -d "$app_path/.git" ]; then + cd ${app_path} && git pull +fi # 执行 go build 命令 cd ${app_path} && go build -o app -cp app.service.example ${app_name}.service +sudo cp app.service.example ${app_name}.service # 替换 app.service 文件中的 APP_PATH sed -i "s|APP_PATH|${app_path}|g" ${app_name}.service -mv ${app_name}.service /etc/systemd/system/${app_name}.service +sudo mv ${app_name}.service /etc/systemd/system/${app_name}.service # 重新加载 systemd 配置文件 -systemctl daemon-reload +sudo systemctl daemon-reload # 重新启动应用程序服务 -systemctl stop ${app_name}.service -systemctl start ${app_name}.service \ No newline at end of file +sudo systemctl stop ${app_name}.service +sudo systemctl start ${app_name}.service