From 69b48521524145f78929c075fec74c33be336e3c Mon Sep 17 00:00:00 2001 From: David Eleazar Date: Wed, 24 Nov 2021 01:11:11 +0700 Subject: [PATCH 1/3] Some improvements 1. Added simple architecture auto-detect feature 2. Improved README.md 3. Improved ngrok.yml config Signed-off-by: David Eleazar --- README.md | 29 +++++++---------------------- install.sh | 27 +++++++++++++++++++++++---- ngrok.yml | 15 ++++----------- 3 files changed, 34 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index c1336d1..254449f 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,9 @@ -# Installation +## Installation -Step 1: Place [`ngrok`](https://ngrok.com/download) in `/opt/ngrok/`. +1. Clone this repository to the target machine (eg: Raspberry Pi) +2. Get your `authtoken` from ngrok website +3. Inspect and modify the configuration file `ngrok.yml`, by default this config will use _Asia Pacific_ region to serve both **HTTP** and **TCP** tunnels +4. Run `sudo ./install.sh `, replace `` with the token you've obtained before from ngrok website. +5. You're good to go! -Step 2: Get `authtoken` from ngrok website, then add it to `/opt/ngrok/ngrok.yml`. - -Step 3. Modify your own configrations in `/opt/ngrok/ngrok.yml`. - -Step 4: Add `ngrok.service` to `/lib/systemd/system/`. - -Step 5: Start ngrok service by typing: - -``` - systemctl enable ngrok.service - systemctl start ngrok.service -``` - -or just execute `install.sh` on Linux x64 platform. - -``` - curl -O https://raw.githubusercontent.com/vincenthsu/systemd-ngrok/master/install.sh - chmod +x install.sh - sudo ./install.sh -``` +_NB : this repository is forked from [vincenthsu/systemd-ngrok](https://github.com/vincenthsu/systemd-ngrok) with architecture auto-detect feature_ diff --git a/install.sh b/install.sh index 3800fad..626d0c3 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,20 @@ #!/usr/bin/env bash +# determine system arch +ARCH= +if [ "$(uname -m)" == 'x86_64' ] +then + ARCH=amd64 +elif [ "$(uname -m)" == 'aarch64' ] +then + ARCH=arm64 +elif [ "$(uname -m)" == 'i386' ] || [ "$(uname -m)" == 'i686' ] +then + ARCH=386 +else + ARCH=arm +fi + if [ ! $(which wget) ]; then echo 'Please install wget package' exit 1 @@ -26,7 +41,7 @@ if [ -z "$1" ]; then fi if [ ! -e ngrok.service ]; then - git clone --depth=1 https://github.com/vincenthsu/systemd-ngrok.git + git clone --depth=1 https://github.com/elzdave/systemd-ngrok.git cd systemd-ngrok fi cp ngrok.service /lib/systemd/system/ @@ -35,10 +50,14 @@ cp ngrok.yml /opt/ngrok sed -i "s//$1/g" /opt/ngrok/ngrok.yml cd /opt/ngrok -wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip -unzip ngrok-stable-linux-amd64.zip -rm ngrok-stable-linux-amd64.zip +echo "Downloading ngrok for $ARCH . . ." +wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-$ARCH.zip +unzip ngrok-stable-linux-$ARCH.zip +rm ngrok-stable-linux-$ARCH.zip chmod +x ngrok systemctl enable ngrok.service systemctl start ngrok.service + +echo "Done installing ngrok" +exit 0 diff --git a/ngrok.yml b/ngrok.yml index 3e484d3..f07fb2f 100644 --- a/ngrok.yml +++ b/ngrok.yml @@ -1,16 +1,9 @@ authtoken: -# region: ap +region: ap tunnels: + web: + proto: http + addr: 80 ssh: proto: tcp addr: 22 -# myapp-http: -# addr: 80 -# proto: http -# hostname: example.com -# auth: "user:secretpassword" -# bind_tls: false -# myapp-https: -# addr: 443 -# proto: tls -# hostname: example.com From 46741f40ba7e90531ce958f547c5b9451fc61b3e Mon Sep 17 00:00:00 2001 From: David Eleazar Date: Tue, 8 Feb 2022 16:22:48 +0700 Subject: [PATCH 2/3] Improved script code --- install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 626d0c3..303368f 100755 --- a/install.sh +++ b/install.sh @@ -41,9 +41,10 @@ if [ -z "$1" ]; then fi if [ ! -e ngrok.service ]; then - git clone --depth=1 https://github.com/elzdave/systemd-ngrok.git + git clone --depth=1 https://github.com/vincenthsu/systemd-ngrok.git cd systemd-ngrok fi + cp ngrok.service /lib/systemd/system/ mkdir -p /opt/ngrok cp ngrok.yml /opt/ngrok From cc1fb252ab1613642be674cda7f7c9fd1d46095b Mon Sep 17 00:00:00 2001 From: David Eleazar Date: Tue, 8 Feb 2022 16:27:01 +0700 Subject: [PATCH 3/3] Improved README --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 254449f..4ce0d58 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,6 @@ 4. Run `sudo ./install.sh `, replace `` with the token you've obtained before from ngrok website. 5. You're good to go! -_NB : this repository is forked from [vincenthsu/systemd-ngrok](https://github.com/vincenthsu/systemd-ngrok) with architecture auto-detect feature_ +## Acknowledgements + +Ngrok architecture auto detection was contributed by [David Eleazar](https://github.com/elzdave).