2016-06-28 14:43:45 +00:00
|
|
|
#!/bin/sh -e
|
2015-06-22 12:03:40 +00:00
|
|
|
|
2016-06-28 14:43:45 +00:00
|
|
|
if [ -n "$@" ]; then
|
|
|
|
exec "$@"
|
2015-06-22 12:03:40 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2016-06-28 14:43:45 +00:00
|
|
|
ARGS="ngrok"
|
2015-06-22 12:03:40 +00:00
|
|
|
|
2016-06-28 14:43:45 +00:00
|
|
|
# Set the protocol.
|
|
|
|
if [ "$NGROK_PROTOCOL" = "TCP" ]; then
|
|
|
|
ARGS="$ARGS tcp"
|
|
|
|
else
|
|
|
|
ARGS="$ARGS http"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Set the authorization token.
|
2015-06-22 12:03:40 +00:00
|
|
|
if [ -n "$NGROK_AUTH" ]; then
|
2016-06-28 14:43:45 +00:00
|
|
|
ARGS="$ARGS -authtoken=$NGROK_AUTH "
|
2015-06-22 12:03:40 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
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
|
2016-06-28 14:43:45 +00:00
|
|
|
echo "You must specify a username, password, and Ngrok authentication token to use the custom HTTP authentication."
|
2015-06-22 12:03:40 +00:00
|
|
|
echo "Sign up for an authentication token at https://ngrok.com"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2016-06-28 14:43:45 +00:00
|
|
|
ARGS="$ARGS -log stdout"
|
|
|
|
|
|
|
|
# Set the point.
|
|
|
|
if [ -n "$HTTPS_PORT" ]; then
|
|
|
|
ARGS="$ARGS `echo $HTTPS_PORT | sed 's|^tcp://||'`"
|
|
|
|
elif [ -n "$HTTP_PORT" ]; then
|
|
|
|
ARGS="$ARGS `echo $HTTP_PORT | sed 's|^tcp://||'`"
|
|
|
|
elif [ -n "$APP_PORT" ]; then
|
|
|
|
ARGS="$ARGS `echo $APP_PORT | sed 's|^tcp://||'`"
|
|
|
|
fi
|
2015-06-22 12:03:40 +00:00
|
|
|
|
2016-06-28 14:43:45 +00:00
|
|
|
set -x
|
|
|
|
exec $ARGS
|