Created
April 14, 2022 13:20
-
-
Save fcsest/4223ae0e23a5bcf2cc32f16ff4478903 to your computer and use it in GitHub Desktop.
Start ngrok connection in background in fish shell with "source start_ngrok.sh".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set NGROK_PUBLIC_URL "" | |
echo "Start ssh-access ngrok in background" | |
nohup ngrok start ssh-access &>/dev/null & | |
echo -e "Extracting ngrok port..." | |
while [ -z "$NGROK_PUBLIC_URL" ]; | |
sleep 1 | |
# Run 'curl' against ngrok API and extract public (using 'sed' command) | |
set NGROK_PUBLIC_URL $(curl --silent --max-time 10 --connect-timeout 5 \ | |
--show-error http://127.0.0.1:4040/api/tunnels | \ | |
sed -nE 's/.*ngrok.i..([^"]*).*/\1/p') | |
end | |
echo "ngrok port => $NGROK_PUBLIC_URL" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment