原帖地址:https://www.bilibili.com/opus/913601425790992418
1、首先curl下载内核文件,移动至用户目录下,添加权限
VERSION="2025.2.1"
IUNAME="cloudflared-linux-arm64"
curl -O -L \
https://github.com/cloudflare/cloudflared/releases/download/${VERSION}/${IUNAME} \
&& chmod +x ${IUNAME} \
&& mv ${IUNAME} /usr/bin/cloudflared
touch /etc/init.d/cloudflared
chmod +x /etc/init.d/cloudflared
2、然后将以下内容添加到/etc/init.d/cloudflared:
- 把'<'yourtoken'>'替换成实际的cf隧道token
#!/bin/sh /etc/rc.common
USE_PROCD=1
START=95
STOP=01
cfd_init="/etc/init.d/cloudflared"
cfd_token="<yourtoken>"
boot()
{
ubus -t 30 wait_for network.interface network.loopback 2>/dev/null
rc_procd start_service
}
start_service() {
if [ $("${cfd_init}" enabled; printf "%u" ${?}) -eq 0 ]
then
procd_open_instance
procd_set_param command /usr/bin/cloudflared --no-autoupdate tunnel run --token ${cfd_token}
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
procd_close_instance
fi
}
stop_service() {
pidof cloudflared && kill -SIGINT `pidof cloudflared`
}
3、最后,确保启用了新的 Cloudflred init.d 服务并以下列方式启动:
/etc/init.d/cloudflared enable
/etc/init.d/cloudflared start
4、验证运行状态:
ps | grep cloudflared #应当列出cf进程
logread | grep cloudflared #应当是一大串日志