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 <