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

Update install.sh #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
65 changes: 35 additions & 30 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
#!/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
if (( $EUID != 0 )); then
echo "Please run as root"
echo "You can Try comand 'su root' or 'sudo -i' or 'sudo -'"
exit 1
fi

ARCHIVE=ngrok-v3-stable-linux-$ARCH.zip
DOWNLOAD_URL=https://bin.equinox.io/c/bNyj1mQVY4c/$ARCHIVE
sudo apt-get update

if [ ! $(which wget) ]; then
echo 'Please install wget package'
exit 1
sudo apt-get install wget -y
fi

if [ ! $(which git) ]; then
echo 'Please install git package'
exit 1
fi

if [ ! $(which unzip) ]; then
echo 'Please install zip package'
exit 1
if [ ! $(which jq) ]; then
sudo apt-get install jq -y
fi

if (( $EUID != 0 )); then
echo "Please run as root"
exit 1
if [ ! $(which git) ]; then
sudo apt-get install git -y
fi

if [ -z "$1" ]; then
Expand All @@ -48,20 +30,43 @@ if [ ! -e ngrok.service ]; then
cd systemd-ngrok
fi

# 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

ARCHIVE=ngrok-v3-stable-linux-$ARCH.tgz
DOWNLOAD_URL=https://bin.equinox.io/c/bNyj1mQVY4c/$ARCHIVE

cp ngrok.service /lib/systemd/system/
mkdir -p /opt/ngrok
cp ngrok.yml /opt/ngrok
sed -i "s/<add_your_token_here>/$1/g" /opt/ngrok/ngrok.yml

cd /opt/ngrok
echo "Downloading ngrok for $ARCH . . ."
wget $DOWNLOAD_URL
unzip $ARCHIVE
wget $DOWNLOAD_URL --no-check-certificate
tar xvf $ARCHIVE
rm $ARCHIVE
chmod +x ngrok

systemctl enable ngrok.service
systemctl start ngrok.service
systemctl status ngrok.service
sleep 5

STATUSNGROK=$(wget http://127.0.0.1:4040/api/tunnels -q -O - | jq '.tunnels | .[] | "\(.name) \(.public_url)"')
echo -e "service online NGROK:\n" $STATUSNGROK

echo "Done installing ngrok"
exit 0