-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_ngrok.sh
executable file
·76 lines (65 loc) · 1.43 KB
/
run_ngrok.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
#
#
# My ngrok startup script
# Requirements:
# - Install ngrok command (https://ngrok.com/)
# - Configure variable NGROK_CMD
#
# From https://github.com/ktxo/my-linux-stuff
#
PORT=6767
USER=""
PASS=""
AUTH=""
PROTOCOL="http"
NGROK_CMD="/sw/ngrok"
usage() {
if [ -f "${NGROK_CMD}" ];then
NGROK_CMD_=${NGROK_CMD}
else
NGROK_CMD_="Missing, please install and configure NGROK_CMD var"
fi
echo "NAME"
echo " Wrapper for ngrok command (https://ngrok.com/)"
echo ""
echo " ngrok command=${NGROK_CMD_}"
echo ""
echo "USAGE"
echo " run_ngrok.sh [-P port_number] [-u user -p pass] [-c http|tcp]" 1>&2
echo ""
echo "EXAMPLES"
echo " run_ngrok.sh -P 8989 # expose HTTP 8989"
echo " run_ngrok.sh -P 8989 -u admin -p passw0rd # expose HTTP 8989 with basic auth admin:passw0rd"
echo ""
exit 1
}
while getopts ":P:u:p:c:" o; do
case "${o}" in
P)
PORT=${OPTARG}
;;
u)
USER=${OPTARG}
;;
p)
PASS=${OPTARG}
;;
c)
PROTOCOL=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
[ -z "${PORT}" ] && usage
[ -n "${USER}" ] && AUTH="${USER}:${PASS}"
echo "Using PORT=${PORT} AUTH=${AUTH}"
if [ -z "${AUTH}" ]
then
${NGROK_CMD} $PROTOCOL $PORT
else
${NGROK_CMD} $PROTOCOL $PORT --basic-auth=$AUTH
fi