diff --git a/nomohead.sh b/nomohead.sh index 1eeecd4..b9afdc3 100755 --- a/nomohead.sh +++ b/nomohead.sh @@ -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 @@ -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 diff --git a/setup.sh b/setup.sh index 6243b4f..affa5fb 100755 --- a/setup.sh +++ b/setup.sh @@ -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..." @@ -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 @@ -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..."