Hi all,
I have followed this post by @tmomas however found that its not working as expected.
The option /etc/init.d/cloudflared start do not starting tunnel (tried on 2 devices and different tunnels).
Option /etc/init.d/cloudflared status return active with no instances
Because of that, the tunnel is not starting and you cannot go to next poing of migration.
To do that you need to run tunnel using cloudflared tunnel run but this command is not working as a service.
There is nothing in logs indicating why /etc/init.d/cloudflared not starting tunnel.
Second part is adding elements to sysctl -w to /etc/init.d/cloudflared.
The better approach is described in a comment to this post:
1. Create a file with this name: 99-fix-buffer-and-ping.conf in the folder: /etc/sysctl.d/
2. Add this inside and save the file.:
net.core.rmem_max=2500000
net.ipv4.ping_group_range=0 2147483647
3. Execute this command from SSH:sysctl -p /etc/sysctl.d/99-fix-buffer-and-ping.conf
as this sorting issue for generic cloudflared run.
Can somebody investigate why /etc/init.d/cloudflared not doing anything?
I found temporary solution by reinstalling cloudflared service.
/etc/init.d/cloudflared stop
mv /etc/init.d/cloudflared /etc/init.d/cloudflared.old
cloudflared service install
/etc/init.d/cloudflared start
The problem is that when its started its working in background but you cannot use /etc/init.d/cloudflared stop to stop it, as installed file is not compatible with OpenWrt as it come from Red Hat.
To stop it you need to kill it manually kill -9 <PID>.
But, I found out the issue.
the ps command in OpenWrt do not have same funcionality as in other systems, so in /etc/init.d/cloudflared I replaced the following:
I have tried various init files. I've tried the init file from the wiki as well as those found on various blogs and none of them worked well.
I wrote this simple init file but it works great. Hope this helps someone
Here is my /etc/init.d/cloudflared script modified for OpenWrt from original CloudFlare source made for RedHat.
#!/bin/sh
# For RedHat and cousins:
# chkconfig: 2345 99 01
# description: cloudflared
# processname: /usr/bin/cloudflared
### BEGIN INIT INFO
# Provides: /usr/bin/cloudflared
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: cloudflared
# Description: cloudflared agent
### END INIT INFO
name=$(basename $(readlink -f $0))
cmd="/usr/bin/cloudflared --pidfile /var/run/$name.pid --autoupdate-freq 24h0m0s --config /etc/cloudflared/config.yml tunnel run"
pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"
[ -e /etc/sysconfig/$name ] && . /etc/sysconfig/$name
get_pid() {
cat "$pid_file"
}
is_running() {
[ -f "$pid_file" ] && ps | grep $(get_pid) | grep -v grep > /dev/null 2>&1
}
case "$1" in
start)
if is_running; then
echo "Already started"
else
echo "Starting $name"
$cmd >> "$stdout_log" 2>> "$stderr_log" &
echo $! > "$pid_file"
fi
;;
stop)
if is_running; then
echo -n "Stopping $name.."
kill $(get_pid)
for i in {1..10}
do
if ! is_running; then
break
fi
echo -n "."
sleep 1
done
echo
if is_running; then
echo "Not stopped; may still be shutting down or shutdown may have failed"
exit 1
else
echo "Stopped"
$cmd >> "$stdout_log" 2>> "$stderr_log" &
echo $! > "$pid_file"
fi
;;
stop)
if is_running; then
echo -n "Stopping $name.."
kill $(get_pid)
for i in {1..10}
do
if ! is_running; then
break
fi
echo -n "."
sleep 1
done
echo
if is_running; then
echo "Not stopped; may still be shutting down or shutdown may have failed"
exit 1
else
echo "Stopped"
if [ -f "$pid_file" ]; then
rm "$pid_file"
fi
fi
else
echo "Not running"
fi
;;
restart)
$0 stop
if is_running; then
echo "Unable to stop, will not attempt to start"
exit 1
fi
$0 start
;;
status)
if is_running; then
echo "Running"
else
echo "Stopped"
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0
~