-
Notifications
You must be signed in to change notification settings - Fork 12
/
ngrok-dev.sh
46 lines (42 loc) · 1.29 KB
/
ngrok-dev.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Check if curl is installed
if ! command -v curl &>/dev/null; then
echo "Error: curl is not installed. Please install it and try again."
exit 1
fi
# Check if jq is installed
if ! command -v jq &>/dev/null; then
echo "Error: jq is not installed. Please install it and try again."
exit 1
fi
if curl -s --head --request GET http://localhost:4040 | grep "302 Found" >/dev/null; then
URL=$(curl -s localhost:4040/api/tunnels | jq -r '.tunnels[] | select(.proto == "https") | .public_url')
case "$OSTYPE" in
linux*)
if command -v xdg-open >/dev/null; then
xdg-open "$URL"
else
echo "Error: xdg-open not found. Please open the URL manually: $URL"
fi
;;
darwin*)
if command -v open >/dev/null; then
open "$URL"
else
echo "Error: open command not found. Please open the URL manually: $URL"
fi
;;
msys* | cygwin*)
if command -v start >/dev/null; then
start "$URL"
else
echo "Error: start command not found. Please open the URL manually: $URL"
fi
;;
*)
echo "Error: Unsupported operating system. Please open the URL manually: $URL"
;;
esac
else
echo "run 'yarn ngrok' first"
fi