Advertisement
SeloTapeTM

ngrokstart

Sep 17th, 2023 (edited)
4,657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.82 KB | None | 0 0
  1. # ngrok http --log=stdout https://localhost:6901 > /dev/null &
  2.  
  3. #!/bin/sh
  4.  
  5. # Set local port from command line arg or default to 8443
  6. LOCAL_PORT=${1-8443}
  7.  
  8. echo "Start ngrok in background on port [ $LOCAL_PORT ]"
  9. nohup ngrok http "$LOCAL_PORT" &>/dev/null &
  10.  
  11. echo -n "Extracting ngrok public url ."
  12. NGROK_PUBLIC_URL=""
  13. while [ -z "$NGROK_PUBLIC_URL" ]; do
  14.   # Run 'curl' against ngrok API and extract public (using 'sed' command)
  15.   export NGROK_PUBLIC_URL=$(curl --silent --max-time 10 --connect-timeout 5 \
  16.                             --show-error http://127.0.0.1:4040/api/tunnels | \
  17.                             sed -nE 's/.*public_url":"(https:..[^"]*).*/\1/p')
  18.   sleep 1
  19.   echo -n "."
  20. done
  21.  
  22. echo
  23. echo "NGROK_PUBLIC_URL => [ $NGROK_PUBLIC_URL ]"
  24. echo $NGROK_PUBLIC_URL > /home/ubuntu/docker/telegram_bot_link.secret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement