From 44a5be191809d41330456945acddae3482bf6ecf Mon Sep 17 00:00:00 2001 From: wuko233 Date: Wed, 8 Apr 2026 21:37:33 +0800 Subject: [PATCH] =?UTF-8?q?[install]=20=E4=BF=AE=E6=94=B9=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index ee0152b..6f205e2 100644 --- a/install.sh +++ b/install.sh @@ -16,9 +16,12 @@ CONFIG_DIR="/etc/sysmonitord" DATA_DIR="/var/lib/sysmonitord" LOG_DIR="/var/log/sysmonitord" -# 编译 -echo "正在编译 sysmonitord..." -make build +# 检查当前目录下是否存在编译好的文件 +if [ ! -f "./$BIN_NAME" ]; then + echo "错误: 在当前目录未找到编译好的 $BIN_NAME 文件" + echo "请确保编译好的 $BIN_NAME 文件存在于当前目录" + exit 1 +fi # 创建目录 echo "正在创建目录..." @@ -28,22 +31,31 @@ mkdir -p "$LOG_DIR" # 复制文件 echo "正在复制文件..." -cp "dist/$BIN_NAME" "$INSTALL_DIR/" +cp "./$BIN_NAME" "$INSTALL_DIR/" chmod +x "$INSTALL_DIR/$BIN_NAME" # 初始化配置文件 if [ ! -f "$CONFIG_DIR/config.yaml" ]; then echo "==> 初始化配置文件..." - cp config.yaml.example $CONFIG_DIR/config.yaml + if [ -f "./config.yaml.example" ]; then + cp ./config.yaml.example $CONFIG_DIR/config.yaml + else + echo "警告: 未找到 config.yaml.example 文件,请手动创建配置文件" + fi else echo "==> 配置文件已存在,跳过覆盖..." fi # 安装systemd服务 -echo "正在安装 systemd 服务..." -cp scripts/sysmonitord.service /etc/systemd/system/ -systemctl daemon-reload -systemctl enable sysmonitord +if [ -f "./scripts/sysmonitord.service" ]; then + echo "正在安装 systemd 服务..." + cp ./scripts/sysmonitord.service /etc/systemd/system/ + systemctl daemon-reload + systemctl enable sysmonitord +else + echo "警告: 未找到 systemd 服务文件,跳过服务安装" +fi + echo "" echo "安装完成!" echo ""