From da6b22b78359db0b3497573a93bceba917db0b36 Mon Sep 17 00:00:00 2001 From: kevin Date: Mon, 26 Jan 2026 12:10:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E7=BC=96=E8=AF=91=E6=88=90linux?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/.gitignore | 4 ++- backend/install.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 backend/install.sh diff --git a/backend/.gitignore b/backend/.gitignore index a5eb322..31c46ed 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -10,4 +10,6 @@ /data /tmp -*.db \ No newline at end of file +*.db + +OPSYS \ No newline at end of file diff --git a/backend/install.sh b/backend/install.sh new file mode 100644 index 0000000..90f7f8c --- /dev/null +++ b/backend/install.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +APP_NAME="OPSYS" +APP_PATH="/opt/$APP_NAME" +SERVICE_FILE="/etc/systemd/system/$APP_NAME.service" +LOG_PATH="/var/log/$APP_NAME" + +echo "正在安装 $APP_NAME..." + +# 编译应用 +echo "编译应用..." +CGO_ENABLED=0 GOOS=linux go build -o $APP_NAME -ldflags="-s -w" main.go + +# 创建目录 +echo "创建目录..." +sudo mkdir -p $APP_PATH +sudo mkdir -p $LOG_PATH + +# 复制文件 +echo "复制文件..." +sudo cp $APP_NAME $APP_PATH/ +sudo cp -r defConfig $APP_PATH/ +sudo cp -r dist $APP_PATH/ + +# 创建服务文件 +echo "创建服务文件..." +sudo tee $SERVICE_FILE > /dev/null <