Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ngrok as a service and fix download links. #4

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions nomohead.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ fi

. "${DIR}/config.cfg"

echo "Starting ngrok..."

#Creates command to run ngrok using defined directory in setup.sh (Eg: ~/Downloads/ngrok)
COMMAND=("${DIR}/ngrok" tcp -region "${ngrok_server}" "${port}")

"${COMMAND[@]}" > /dev/null &

#Sleeps for delay defined in setup.sh
sleep $tunnel_delay

Expand All @@ -35,8 +28,10 @@ do
echo "${TUNNEL}" > tunnel_info.json
#Gets the tunnel's address and port
TUNNEL_TCP=$(grep -Po 'tcp:\/\/[^"]+' ./tunnel_info.json )

TIME=$(date +"Update: %T || %m-%d-%y")

#Pushes all this information to dweet.io
curl -d "tunnel=${TUNNEL_TCP}&internal_ip=${IP}&external_ip=${EXTERNALIP}" http://dweet.io/dweet/for/${dweet_id_tunnel}
curl -d "tunnel=${TUNNEL_TCP}&internal_ip=${IP}&external_ip=${EXTERNALIP}&time=${TIME}" http://dweet.io/dweet/for/${dweet_id_tunnel}
sleep $tunnel_delay
done
26 changes: 21 additions & 5 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

echo -e "\e[1m\e[44mWelcome to nomohead's setup script! \e[0m"

[[ $EUID -ne 0 ]] && echo "This script must be run as root." && exit 1

echo ""

echo "Testing to see if ngrok is contained inside this folder..."
Expand All @@ -15,14 +17,16 @@ if [ $? != 0 ]; then
download=""
zip=""
case $(uname -m) in
i386) download="https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-386.zip" && zip="ngrok-stable-linux-386.zip" && echo "Downloading archive for x86 Linux" ;;
i686) download="https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-386.zip" && zip="ngrok-stable-linux-386.zip" && echo "Downloading archive for x86 Linux" ;;
x86_64) download="https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip" && zip="ngrok-stable-linux-amd64.zip" && echo "Downloading archive for x86_64 Linux" ;;
arm) dpkg --print-architecture | grep -q "arm64" && download="https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm64.zip" && zip="ngrok-stable-linux-arm64.zip" && echo "Downloading archive for arm64 Linux" || download="https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.zip" && zip="ngrok-stable-arm.zip" && echo "Downloading archive for arm32 Linux" ;;
i386) download="https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-386.tgz" && tgz="ngrok-v3-stable-linux-386.tgz" && echo "Downloading archive for x86 Linux" ;;
i686) download="https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-386.tgz" && tgz="ngrok-v3-stable-linux-386.tgz" && echo "Downloading archive for x86 Linux" ;;
x86_64) download="https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz" && tgz="ngrok-v3-stable-linux-amd64.tgz" && echo "Downloading archive for x86_64 Linux" ;;
arm*) dpkg --print-architecture | grep -q "arm64" && download="https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-arm64.tgz" && tgz="ngrok-v3-stable-linux-arm64.tgz" && echo "Downloading archive for arm64 Linux" || download="https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-arm.tgz" && tgz="ngrok-v3-stable-linux-arm.tgz" && echo "Downloading archive for arm32 Linux" ;;
esac
wget "$download"
unzip "$zip" 1> /dev/null &
tar -xf "$tgz"
echo "Download and extraction of ngrok executable complete"
echo "Removing archive..."
rm "$tgz"
else
echo "ngrok executable found!"
fi
Expand Down Expand Up @@ -63,6 +67,18 @@ else
server="eu"
fi

echo "Installing ngrok service"
ngrokconf=\
"version: \"2\"\n\
authtoken: $user_authtoken\n\
region: $server\n\
tunnels:\n\
nomohead:\n\
proto: tcp\n\
addr: $ngrok_port"
echo -e "$ngrokconf" > ngrok.yml
command="${DIR}/ngrok service install --config ngrok.yml"

printf "dweet_id_tunnel=${d_id_tun}\nport=${ngrok_port}\ntunnel_delay=${tun_delay}\nngrok_server=${server}" > config.cfg

echo "Adding Cron job..."
Expand Down