Skip to content

Instantly share code, notes, and snippets.

@Erisa
Last active Aug 24, 2021
Embed
What would you like to do?
Install the Cloudflare Daemon (cloudflared) in Termux
#!/bin/sh
echo "--upgrading packages"
yes "" | pkg update
echo "-- installing dependancies: golang git debianutils make"
yes "" | pkg install golang git debianutils make
echo "-- downloading cloudflared source"
git clone https://github.com/cloudflare/cloudflared.git --depth=1
cd cloudflared
sed -i 's/linux/android/g' Makefile
echo "-- building and installing cloudflared"
make cloudflared
install cloudflared /data/data/com.termux/files/usr/bin
echo "-- done!"
@srivathsanvenkateswaran

This comment has been minimized.

Copy link

@srivathsanvenkateswaran srivathsanvenkateswaran commented Feb 10, 2021

The github link specified here is broken. Also, while trying with Termux, the last line

install $GOPATH/bin/cloudflared /data/data/com.termux/files/usr/bin threw me an error : No such file or directory
image

@Erisa

This comment has been minimized.

Copy link
Owner Author

@Erisa Erisa commented Feb 10, 2021

Hi @srivathsanvenkateswaran,
I didn't really expect anyone to use this little script and I haven't touched it since I first threw it together a few months ago.

The github "link" isn't a real link, just a reference for Go to know where to retrieve the module and which one to build from the repository (https://github.com/cloudflare/cloudflared)

These days because of changes in their build process I would instead recommend cloning the repository (With --depth=1 to save time, bandwidth and storage), installing the make package as well as the ones mentioned here and running make cloudflared in the directory after editing the makefile to support Android as a target.

As a script this would be something like:

cd ~
yes "" | pkg update
yes "" | pkg install golang git debianutils make
git clone https://github.com/cloudflare/cloudflared.git --depth=1
cd cloudflared
sed -i 's/linux/android/g' Makefile
make cloudflared
install cloudflared /data/data/com.termux/files/usr/bin

There are prettier ways to handle the Makefile edit, I'm (ironically) writing this from my phone so thats the best I could come up with that works.
I'd be happy to update the script with this method later.

Screenshot_20210210-061425_Termux

@nalakawula

This comment has been minimized.

Copy link

@nalakawula nalakawula commented May 17, 2021

I got an error when trying to run cloudflared


2021-05-17T02:30:30Z INF Initial protocol h2mux
2021-05-17T02:30:30Z INF Starting metrics server on 127.0.0.1:41105/metrics
2021-05-17T02:30:31Z ERR Error looking up Cloudflare edge IPs: the DNS query failed error="lookup _origintunneld._tcp.argotunnel.com on [::1]:53: read udp [::1]:38332->[::1]:53: read: connection refused"
@Erisa

This comment has been minimized.

Copy link
Owner Author

@Erisa Erisa commented May 17, 2021

Its working fine for me on the latest version.
In the past I've had that issue when running cloudflared compiled for linux (GOOS=linux or precompiled binary from their website) rather than for Android (GOOS=android from source).
This reason is why my short script (Made for my personal use) builds it from source targeting Android.

@Erisa

This comment has been minimized.

Copy link
Owner Author

@Erisa Erisa commented May 17, 2021

The lines at the top of your output that look like this

2021-05-17T02:39:15Z INF Version 2021.5.6-dev
2021-05-17T02:39:15Z INF GOOS: android, GOVersion: go1.16.3, GoArch: arm64

Will tell you that information

@Isbbrt

This comment has been minimized.

Copy link

@Isbbrt Isbbrt commented Jun 29, 2021

is there how to install it on windows cmd?

@Erisa

This comment has been minimized.

Copy link
Owner Author

@Erisa Erisa commented Jun 29, 2021

is there how to install it on windows cmd?

You can do that officially with official instructions: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation#windows

Or install Scoop and simply scoop install cloudflared

@Isbbrt

This comment has been minimized.

Copy link

@Isbbrt Isbbrt commented Jun 29, 2021

is there how to install it on windows cmd?

You can do that officially with official instructions: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation#windows

Or install Scoop and simply scoop install cloudflared

thank you so much

@yelrom0

This comment has been minimized.

Copy link

@yelrom0 yelrom0 commented Jul 15, 2021

The github link specified here is broken. Also, while trying with Termux, the last line

install $GOPATH/bin/cloudflared /data/data/com.termux/files/usr/bin threw me an error : No such file or directory
image

It worked fine for me. Make sure that you run chmod +x before running the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment