1
geekvcn 171 天前
#!/bin/sh /etc/rc.common
START=99 start(){ nohup cloudflared tunnel run [Tunnel name 或 Tunnel ID] >/dev/null 2>&1 & } stop(){ kill -9 `ps |grep cloudflared|grep -v grep|awk '{print $1}'` } restart(){ stop sleep 1 start } 把上面的内容写入到/etc/init.d/cloudflared chmod +x /etc/init.d/cloudflared service cloudflared enable |
2
ttut OP @geekvcn #1 还是不行,不知道是不是这样加
#!/bin/sh /etc/rc.common USE_PROCD=1 START=99 start(){ nohup cloudflared tunnel run [Tunnel name 或 Tunnel ID] >/dev/null 2>&1 & } stop(){ kill -9 `ps |grep cloudflared|grep -v grep|awk '{print $1}'` } restart(){ stop sleep 1 start } CONF="cloudflared" PROG="/usr/bin/cloudflared" append_param_arg() { local value config_get value "config" "$1" $2 [ -n "$value" ] && procd_append_param command "--$1" "$value" } start_service() { config_load "$CONF" local enabled config_get_bool enabled "config" "enabled" [ "$enabled" -eq "1" ] || return 1 procd_open_instance "$CONF" procd_set_param command "$PROG" "tunnel" procd_append_param command "--no-autoupdate" append_param_arg "config" "/etc/cloudflared/config.yml" append_param_arg "origincert" "/etc/cloudflared/cert.pem" append_param_arg "region" append_param_arg "loglevel" append_param_arg "logfile" procd_append_param command "run" append_param_arg "token" procd_set_param respawn procd_set_param stderr 1 procd_close_instance } reload_service() { stop start } service_triggers() { procd_add_reload_trigger "$CONF" } |
3
flynaj 171 天前 via Android
原版你直接安装 luci-i18n-cloudflared-zh-cn ,在 Web 界面配置就行,不需要你改它的脚本,
|
4
flynaj 171 天前 via Android
也可以直接编辑配置
文件在 /etc/config/cloudflared config cloudflared 'config' option enabled '1' 这样才会运行 |
5
sky96111 170 天前
cf tunnel 生成的 rc 启动脚本在 op 里有兼容性问题,你比对一下格式就知道了。要么用 luci 那个包,要么动手改一下启动脚本
|
6
ttut OP @flynaj #3 可能我的 openwrt 版本不兼容,我试过装 packages-23.05 和 packages-22.03 里的(packages-22.03 以下就没有 cloudflared 了)
luci-app-cloudflared_1.2_all.ipk packages-23.05:luci-i18n-cloudflared-zh-cn_git-24.137.59920-b342a45_all.ipk packages-22.03:luci-i18n-cloudflared-zh-cn_git-24.137.60246-95611b9_all.ipk 但在 openwrt 的 web 页面不出现 cloudflared 相关配置。 |
8
photon006 170 天前
docker 运行
|
10
fanersai 170 天前
我是 docker 跑
|