Utility to keep cloudflared updated on Raspberry Pi Zeros and other armv6 architecure devices
A pi zero (or zero W or old Pi v 1) can host a mostly static webserver just fine, and using Cloudflare's cloudflared utility and a Cloudflare account. The utility can also act as a DoH proxy and do some other things as well (and probably more will be added over time). Unfortunately there's a problem which is that Cloudflare builds for the ARM v7 architecture not the v6 and so if you try and run the official binary on your Pi Zero you get a very helpful
Segment fault
There is a bug report with many comments on the problem at the cloudflared github site that include instructions on how to build from source with the right architecture flag.
However a nice Canadian gentleman called Darren Hobin (who provided the build instructions) has been building v6 binaries and storing the results at this page:
The only problem is that you have to manually update the binary in order to keep up with the latest cloudflare official version with it's new features and bug fixes
This script (Github link, gist link) checks the page above for the latest version and compares it with the version of /usr/local/bin/cloudflared. If the versions differ (or the attempt results in a failure (e.g. a segfault)) then the script downloads the latest version, checks the SHA256 checksum and (presuming it passes) updates /usr/local/bin/cloudflared. and finally restarts the systemd service if one was installed.
Note that if you run cloudflared service install command it will create an updater systemd service and timer which you will want to disable them because they will cause the working cloudflared to be replaced with a v7 one that doesn't work on a Pi Zero.
sudo systemctl stop cloudflared-updater sudo systemctl disable cloudflared-updater
cd /tmp && wget https://raw.githubusercontent.com/FrancisTurner/francisturner.github.io/master/checkv6cfd.sh && chmod a+x checkv6cfd.sh sudo mv checkv6cfd.sh /usr/local/bin
sudo checkv6cfd.sh DEBUG to test that it works
Assuming that it reports something sensible add it to cron. The easiest way is to simply make a symlink in /etc/cron.daily (see below), although you can also create a one line file in /etc/cron.d/ or in the root crontab (sudo crontab -e)
sudo ln -s /usr/local/bin/checkv6cfd.sh /etc/cron.daily/checkv6cfd.sh
© 2021 Francis Turner