mirror of
https://github.com/wfg/docker-openvpn-client.git
synced 2025-06-28 12:22:55 -04:00
Switch to bash and use array for ovpn args
This commit is contained in:
parent
bffa3688bf
commit
ca0e1c0a91
4 changed files with 25 additions and 29 deletions
|
@ -3,9 +3,9 @@ FROM alpine:3.15
|
||||||
ARG IMAGE_VERSION
|
ARG IMAGE_VERSION
|
||||||
ARG BUILD_DATE
|
ARG BUILD_DATE
|
||||||
|
|
||||||
LABEL created="$BUILD_DATE"
|
LABEL org.opencontainers.image.created="$BUILD_DATE"
|
||||||
LABEL source="github.com/wfg/docker-openvpn-client"
|
LABEL org.opencontainers.image.source="github.com/wfg/docker-openvpn-client"
|
||||||
LABEL version="$IMAGE_VERSION"
|
LABEL org.opencontainers.image.version="$IMAGE_VERSION"
|
||||||
|
|
||||||
ENV KILL_SWITCH=on \
|
ENV KILL_SWITCH=on \
|
||||||
VPN_LOG_LEVEL=3 \
|
VPN_LOG_LEVEL=3 \
|
||||||
|
@ -13,6 +13,7 @@ ENV KILL_SWITCH=on \
|
||||||
SOCKS_PROXY=off
|
SOCKS_PROXY=off
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
|
bash \
|
||||||
bind-tools \
|
bind-tools \
|
||||||
dante-server \
|
dante-server \
|
||||||
openvpn \
|
openvpn \
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#!/bin/ash
|
#!/bin/bash
|
||||||
# shellcheck shell=ash
|
|
||||||
# shellcheck disable=SC2169 # making up for lack of ash support
|
|
||||||
|
|
||||||
echo -e "Running Dante SOCKS proxy server.\n"
|
echo -e "Running Dante SOCKS proxy server.\n"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#!/bin/ash
|
#!/bin/bash
|
||||||
# shellcheck shell=ash
|
|
||||||
# shellcheck disable=SC2169 # making up for lack of ash support
|
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
# When you run `docker stop` or any equivalent, a SIGTERM signal is sent to PID 1.
|
# When you run `docker stop` or any equivalent, a SIGTERM signal is sent to PID 1.
|
||||||
|
@ -185,34 +183,35 @@ if [ "$SOCKS_PROXY" = "on" ]; then
|
||||||
echo "$(cat /run/secrets/$PROXY_USERNAME_SECRET):$(cat /run/secrets/$PROXY_PASSWORD_SECRET)" | chpasswd 2> /dev/null
|
echo "$(cat /run/secrets/$PROXY_USERNAME_SECRET):$(cat /run/secrets/$PROXY_PASSWORD_SECRET)" | chpasswd 2> /dev/null
|
||||||
sed -i 's/socksmethod: none/socksmethod: username/' /data/sockd.conf
|
sed -i 's/socksmethod: none/socksmethod: username/' /data/sockd.conf
|
||||||
else
|
else
|
||||||
echo "WARNING: Credentials secrets not read. Starting SOCKS proxy without credentials."
|
echo "WARNING: Credentials secrets not present. Starting SOCKS proxy without credentials."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
/data/scripts/dante_wrapper.sh &
|
/data/scripts/dante_wrapper.sh &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ovpn_auth_flag=''
|
openvpn_args=(
|
||||||
if [ -n "$OPENVPN_AUTH_SECRET" ]; then
|
"--config" "$config_file_modified"
|
||||||
|
"--auth-nocache"
|
||||||
|
"--cd" "/data/vpn"
|
||||||
|
"--pull-filter" "ignore" "ifconfig-ipv6"
|
||||||
|
"--pull-filter" "ignore" "route-ipv6"
|
||||||
|
"--script-security" "2"
|
||||||
|
"--up-restart"
|
||||||
|
"--verb" "$vpn_log_level"
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ "$OPENVPN_AUTH_SECRET" ]; then
|
||||||
if [ -f "/run/secrets/$OPENVPN_AUTH_SECRET" ]; then
|
if [ -f "/run/secrets/$OPENVPN_AUTH_SECRET" ]; then
|
||||||
echo "Configuring OpenVPN authentication."
|
echo "Configuring OpenVPN authentication."
|
||||||
ovpn_auth_flag="--auth-user-pass /run/secrets/$OPENVPN_AUTH_SECRET"
|
openvpn_args+=("--auth-user-pass" "/run/secrets/$OPENVPN_AUTH_SECRET")
|
||||||
else
|
else
|
||||||
echo "WARNING: OpenVPN Credentials secrets fail to read."
|
echo "WARNING: OpenVPN credentials secrets not present."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "Running OpenVPN client.\n"
|
echo -e "Running OpenVPN client.\n"
|
||||||
|
|
||||||
openvpn --config "$config_file_modified" \
|
openvpn "${openvpn_args[@]}" &
|
||||||
$ovpn_auth_flag \
|
|
||||||
--verb "$vpn_log_level" \
|
|
||||||
--auth-nocache \
|
|
||||||
--connect-retry-max 10 \
|
|
||||||
--pull-filter ignore "route-ipv6" \
|
|
||||||
--pull-filter ignore "ifconfig-ipv6" \
|
|
||||||
--script-security 2 \
|
|
||||||
--up-restart \
|
|
||||||
--cd /data/vpn &
|
|
||||||
openvpn_child=$!
|
openvpn_child=$!
|
||||||
|
|
||||||
wait $openvpn_child
|
wait $openvpn_child
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#!/bin/ash
|
#!/bin/bash
|
||||||
# shellcheck shell=ash
|
|
||||||
# shellcheck disable=SC2169 # making up for lack of ash support
|
|
||||||
|
|
||||||
echo -e "Running Tinyproxy HTTP proxy server.\n"
|
echo -e "Running Tinyproxy HTTP proxy server.\n"
|
||||||
|
|
||||||
|
@ -8,8 +6,8 @@ until ip link show tun0 2>&1 | grep -qv "does not exist"; do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
function get_addr {
|
get_addr() {
|
||||||
echo $(ip a show dev $1 | grep inet | cut -d " " -f 6 | cut -d "/" -f 1)
|
ip a show dev "$1" | grep inet | cut -d " " -f 6 | cut -d "/" -f 1
|
||||||
}
|
}
|
||||||
|
|
||||||
addr_eth=${LISTEN_ON:-$(get_addr eth0)}
|
addr_eth=${LISTEN_ON:-$(get_addr eth0)}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue