Permalink
Browse files

Add support for arguments with multiple variables

  • Loading branch information...
pieterlange committed May 26, 2017
1 parent fa46107 commit 17c2e043f9edfc86b981453fd6bda40cb4945268
Showing with 9 additions and 6 deletions.
  1. +6 −2 bin/func.sh
  2. +3 −4 entrypoint.sh
View
@@ -16,10 +16,14 @@ function hasArg {
# Adds the given argument if it's not already specified.
function addArg {
local arg="${1}"
[ $# -ge 1 ] && local val="${2}"
shift
if ! hasArg "${arg}" "${USER_ARGS[@]}"; then
ARGS+=("${arg}")
[ $# -ge 1 ] && ARGS+=("${val}")
if [ $# -ge 1 ]; then
for val in "$@"; do
ARGS+=("${val}")
done
fi
fi
}
View
@@ -55,8 +55,7 @@ routes+=("$OVPN_K8S_SERVICE_NETWORK" "$OVPN_K8S_POD_NETWORK")
for route in "${routes[@]}"; do
if [[ "$route" =~ ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ ]]; then
network_route=$(getroute $route)
addArg "--push" "route ${network_route}"
addArg "--push" "route $(getroute $route)"
else
echo "$(date "+%a %b %d %H:%M:%S %Y") Dropping invalid route '${route}'."
routes=("${routes[@]/$route}" )
@@ -97,7 +96,7 @@ if [ -d "${OVPN_OTP_AUTH:-}" ]; then
fi
if [ -n "${OVPN_MANAGEMENT_PORT}" ]; then
addArg "--management" "127.0.0.1 ${OVPN_MANAGEMENT_PORT}"
addArg "--management" "127.0.0.1" "${OVPN_MANAGEMENT_PORT}"
fi
if [ -n "${OVPN_STATUS}" ]; then
@@ -111,4 +110,4 @@ if [ $DEBUG ]; then
fi
echo "$(date "+%a %b %d %H:%M:%S %Y") Running 'openvpn ${ARGS[@]} ${USER_ARGS[@]}'"
exec openvpn ${ARGS[@]} ${USER_ARGS[@]} 1> /dev/stderr 2> /dev/stderr
exec openvpn "${ARGS[@]} ${USER_ARGS[@]}" 1> /dev/stderr 2> /dev/stderr

0 comments on commit 17c2e04

Please sign in to comment.