Skip to content

Commit 17c2e04

Browse files
committed
Add support for arguments with multiple variables
1 parent fa46107 commit 17c2e04

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

bin/func.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ function hasArg {
1616
# Adds the given argument if it's not already specified.
1717
function addArg {
1818
local arg="${1}"
19-
[ $# -ge 1 ] && local val="${2}"
19+
shift
2020
if ! hasArg "${arg}" "${USER_ARGS[@]}"; then
2121
ARGS+=("${arg}")
22-
[ $# -ge 1 ] && ARGS+=("${val}")
22+
if [ $# -ge 1 ]; then
23+
for val in "$@"; do
24+
ARGS+=("${val}")
25+
done
26+
fi
2327
fi
2428
}
2529

entrypoint.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ routes+=("$OVPN_K8S_SERVICE_NETWORK" "$OVPN_K8S_POD_NETWORK")
5555

5656
for route in "${routes[@]}"; do
5757
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
58-
network_route=$(getroute $route)
59-
addArg "--push" "route ${network_route}"
58+
addArg "--push" "route $(getroute $route)"
6059
else
6160
echo "$(date "+%a %b %d %H:%M:%S %Y") Dropping invalid route '${route}'."
6261
routes=("${routes[@]/$route}" )
@@ -97,7 +96,7 @@ if [ -d "${OVPN_OTP_AUTH:-}" ]; then
9796
fi
9897

9998
if [ -n "${OVPN_MANAGEMENT_PORT}" ]; then
100-
addArg "--management" "127.0.0.1 ${OVPN_MANAGEMENT_PORT}"
99+
addArg "--management" "127.0.0.1" "${OVPN_MANAGEMENT_PORT}"
101100
fi
102101

103102
if [ -n "${OVPN_STATUS}" ]; then
@@ -111,4 +110,4 @@ if [ $DEBUG ]; then
111110
fi
112111

113112
echo "$(date "+%a %b %d %H:%M:%S %Y") Running 'openvpn ${ARGS[@]} ${USER_ARGS[@]}'"
114-
exec openvpn ${ARGS[@]} ${USER_ARGS[@]} 1> /dev/stderr 2> /dev/stderr
113+
exec openvpn "${ARGS[@]} ${USER_ARGS[@]}" 1> /dev/stderr 2> /dev/stderr

0 commit comments

Comments
 (0)