This commit is contained in:
2026-05-14 13:18:57 +08:00
parent b12b0f0356
commit 58fe23e5ef
7 changed files with 168 additions and 12 deletions

30
service/bird-lgp-alpine Normal file
View File

@@ -0,0 +1,30 @@
#!/sbin/openrc-run
# 服务名称
name="bird-lgproxy"
description="Bird Looking Glass Proxy (Go)"
# 程序路径和参数
command="/etc/birdlg/bird-lgproxy-go"
command_args="-config /etc/birdlg/config.yml"
pidfile="/run/${RC_SVCNAME}.pid"
command_background="yes"
# 自动重启配置(如果程序崩溃)
respawn_delay=5
respawn_max=10
depend() {
# 确保在网络和 bird 启动后再启动
need net
after bird
}
start_pre() {
# 启动前的检查:确保配置文件存在
if [ ! -f "/etc/bird-lg/bird-lgproxy.yaml" ]; then
eerror "Configuration file /etc/bird-lg/bird-lgproxy.yaml not found!"
return 1
fi
}

34
service/bird-lgp-openwrt Normal file
View File

@@ -0,0 +1,34 @@
#!/bin/sh /etc/rc.common
# 启动优先级,通常在网络启动后
START=99
USE_PROCD=1
# 程序路径和配置文件路径(根据你的实际情况修改)
PROG="/etc/birdlg/bird-lgproxy-go"
CONF="/etc/birdlg/config.yml"
start_service() {
# 检查程序是否存在
[ -f "$PROG" ] || return 1
procd_open_instance "bird-lgproxy"
# 执行程序命令,-c 指定配置文件(请根据 bird-lg-go 的实际参数调整)
# 如果 bird-lgproxy-go 默认在当前目录找 config.yml可以用 procd_set_param chdir
procd_set_param command "$PROG" -config "$CONF"
# 自动重启设置如果程序崩溃5秒后重启
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
# 错误日志和标准输出重定向到系统日志
procd_set_param stderr 1
procd_set_param stdout 1
procd_close_instance
}
stop_service() {
# 停止时的操作procd 会自动处理信号
return 0
}

13
service/birdlgp.service Normal file
View File

@@ -0,0 +1,13 @@
[Unit]
Description=Bird-lgproxy
After=network.target
[Service]
Type=simple
ExecStart=/etc/birdlg/bird-lgproxy-go
WorkingDirectory=/etc/birdlg/
Restart=always
User=root
[Install]
WantedBy=multi-user.target