-
Notifications
You must be signed in to change notification settings - Fork 143
/
entrypoint.sh
executable file
·98 lines (82 loc) · 2.48 KB
/
entrypoint.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/sh -e
if [ -n "$@" ]; then
exec "$@"
fi
# Legacy compatible:
if [ -z "$NGROK_PORT" ]; then
if [ -n "$HTTPS_PORT" ]; then
NGROK_PORT="$HTTPS_PORT"
elif [ -n "$HTTPS_PORT" ]; then
NGROK_PORT="$HTTP_PORT"
elif [ -n "$APP_PORT" ]; then
NGROK_PORT="$APP_PORT"
fi
fi
ARGS="ngrok"
# Set the protocol.
if [ "$NGROK_PROTOCOL" = "TCP" ]; then
ARGS="$ARGS tcp"
elif [ "$NGROK_PROTOCOL" = "TLS" ]; then
ARGS="$ARGS tls"
NGROK_PORT="${NGROK_PORT:-443}"
else
ARGS="$ARGS http"
NGROK_PORT="${NGROK_PORT:-80}"
fi
# Set the TLS binding flag
if [ -n "$NGROK_BINDTLS" ]; then
ARGS="$ARGS -bind-tls=$NGROK_BINDTLS "
fi
# Set the authorization token.
if [ -n "$NGROK_AUTH" ]; then
echo -e "\nauthtoken: $NGROK_AUTH" >> $HOME/.ngrok2/ngrok.yml
fi
# Set the subdomain or hostname, depending on which is set
if [ -n "$NGROK_HOSTNAME" ] && [ -n "$NGROK_AUTH" ]; then
ARGS="$ARGS -hostname=$NGROK_HOSTNAME "
elif [ -n "$NGROK_SUBDOMAIN" ] && [ -n "$NGROK_AUTH" ]; then
ARGS="$ARGS -subdomain=$NGROK_SUBDOMAIN "
elif [ -n "$NGROK_HOSTNAME" ] || [ -n "$NGROK_SUBDOMAIN" ]; then
if [ -z "$NGROK_AUTH" ]; then
echo "You must specify an authentication token after registering at https://ngrok.com to use custom domains."
exit 1
fi
fi
# Set the remote-addr if specified
if [ -n "$NGROK_REMOTE_ADDR" ]; then
if [ -z "$NGROK_AUTH" ]; then
echo "You must specify an authentication token after registering at https://ngrok.com to use reserved ip addresses."
exit 1
fi
ARGS="$ARGS -remote-addr=$NGROK_REMOTE_ADDR "
fi
# Set a custom region
if [ -n "$NGROK_REGION" ]; then
ARGS="$ARGS -region=$NGROK_REGION "
fi
if [ -n "$NGROK_HEADER" ]; then
ARGS="$ARGS -host-header=$NGROK_HEADER "
fi
if [ -n "$NGROK_USERNAME" ] && [ -n "$NGROK_PASSWORD" ] && [ -n "$NGROK_AUTH" ]; then
ARGS="$ARGS -auth=$NGROK_USERNAME:$NGROK_PASSWORD "
elif [ -n "$NGROK_USERNAME" ] || [ -n "$NGROK_PASSWORD" ]; then
if [ -z "$NGROK_AUTH" ]; then
echo "You must specify a username, password, and Ngrok authentication token to use the custom HTTP authentication."
echo "Sign up for an authentication token at https://ngrok.com"
exit 1
fi
fi
if [ -n "$NGROK_DEBUG" ]; then
ARGS="$ARGS -log stdout"
fi
# Set the port.
if [ -z "$NGROK_PORT" ]; then
echo "You must specify a NGROK_PORT to expose."
exit 1
fi
if [ -n "$NGROK_LOOK_DOMAIN" ]; then
ARGS="$ARGS `echo $NGROK_LOOK_DOMAIN:$NGROK_PORT | sed 's|^tcp://||'`"
else
ARGS="$ARGS `echo $NGROK_PORT | sed 's|^tcp://||'`"
fi
exec $ARGS