Browse Source

build(deploy): add easytier systemd service and install script support

1. 新增 easytier.service 系统服务配置文件
2. 调整安装脚本步骤编号,新增RK3588平台的EasyTier部署逻辑
3. 优化安装验证步骤,新增VPN服务状态检查
wenhongquan 1 day ago
parent
commit
a20de2c742
4 changed files with 70 additions and 4 deletions
  1. BIN
      deploy/easytier-cli
  2. BIN
      deploy/easytier-core
  3. 15 0
      deploy/easytier.service
  4. 55 4
      deploy/install.sh

BIN
deploy/easytier-cli


BIN
deploy/easytier-core


+ 15 - 0
deploy/easytier.service

@@ -0,0 +1,15 @@
+[Unit]
+After=network.target syslog.target
+Description=easytier
+StartLimitIntervalSec=0
+
+[Service]
+Type=simple
+WorkingDirectory=/opt
+ExecStart=/opt/easytier-core -d --network-name dsh --network-secret 123456 -p tcp://remote-mange.dnnbuild.com:25700 -n 192.168.20.0/24
+Restart=always
+RestartSec=1
+LimitNOFILE=infinity
+
+[Install]
+WantedBy=multi-user.target

+ 55 - 4
deploy/install.sh

@@ -204,7 +204,7 @@ deploy_project_files() {
 
 install_systemd_service() {
     local platform="$1"
-    log_step "5/6 安装 Systemd 服务"
+    log_step "5/7 安装 Systemd 服务"
 
     if [ "$platform" = "macos" ]; then
         log_warn "macOS 不支持 systemd,跳过服务安装"
@@ -230,9 +230,56 @@ install_systemd_service() {
     fi
 }
 
+install_easytier() {
+    local platform="$1"
+    log_step "6/7 部署 EasyTier VPN"
+
+    if [ "$platform" != "rk3588" ]; then
+        log_warn "仅 RK3588 需要 easytier,跳过"
+        return
+    fi
+
+    # 部署 easytier-core
+    if [ -f "${SCRIPT_DIR}/easytier-core" ]; then
+        sudo cp "${SCRIPT_DIR}/easytier-core" /opt/easytier-core
+        sudo chmod 755 /opt/easytier-core
+        sudo chown root:root /opt/easytier-core
+        log_info "easytier-core 已部署到 /opt/easytier-core"
+    else
+        log_warn "未找到 ${SCRIPT_DIR}/easytier-core,跳过 core 部署"
+    fi
+
+    # 部署 easytier-cli
+    if [ -f "${SCRIPT_DIR}/easytier-cli" ]; then
+        sudo cp "${SCRIPT_DIR}/easytier-cli" /home/admin/easytier-cli
+        sudo chmod 755 /home/admin/easytier-cli
+        sudo chown admin:admin /home/admin/easytier-cli
+        log_info "easytier-cli 已部署到 /home/admin/easytier-cli"
+    else
+        log_warn "未找到 ${SCRIPT_DIR}/easytier-cli,跳过 CLI 部署"
+    fi
+
+    # 安装 easytier 系统服务
+    if [ -f "${SCRIPT_DIR}/easytier.service" ]; then
+        sudo cp "${SCRIPT_DIR}/easytier.service" /etc/systemd/system/easytier.service
+        sudo chmod 644 /etc/systemd/system/easytier.service
+        sudo systemctl daemon-reload
+        sudo systemctl enable easytier.service
+        sudo systemctl restart easytier.service
+        sleep 2
+        if systemctl is-active --quiet easytier.service; then
+            log_info "easytier 服务已启动并设置为开机自启"
+        else
+            log_warn "easytier 服务启动异常,请检查: sudo journalctl -u easytier.service -n 50 --no-pager"
+        fi
+    else
+        log_warn "未找到 ${SCRIPT_DIR}/easytier.service,跳过服务安装"
+    fi
+}
+
 verify_installation() {
     local platform="$1"
-    log_step "6/6 验证安装"
+    log_step "7/7 验证安装"
 
     echo ""
     echo "  ┌─────────────────────────────────────────────┐"
@@ -242,9 +289,12 @@ verify_installation() {
 
     if [ "$platform" != "macos" ]; then
         if systemctl is-active --quiet dsh-dual-camera.service; then
-            echo "  │  服务状态: ✅ 运行中 (systemd)            │"
+            echo "  │  主服务:       ✅ dsh-dual-camera          │"
         else
-            echo "  │  服务状态: ❌ 未运行                       │"
+            echo "  │  主服务:       ❌ dsh-dual-camera          │"
+        fi
+        if systemctl is-active --quiet easytier.service 2>/dev/null; then
+            echo "  │  VPN 服务:     ✅ easytier                 │"
         fi
         echo "  │  管理命令:                                  │"
         echo "  │    sudo systemctl start dsh-dual-camera     │"
@@ -305,6 +355,7 @@ main() {
     install_python_deps "$PLATFORM"
     deploy_project_files "$PLATFORM"
     install_systemd_service "$PLATFORM"
+    install_easytier "$PLATFORM"
     verify_installation "$PLATFORM"
 
     log_info "安装完成!"