mirror of
https://github.com/haugene/docker-transmission-openvpn.git
synced 2025-08-18 21:11:00 +02:00
45 lines
1.7 KiB
Bash
Executable File
45 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
if [ "${PEER_DNS}" != "no" ]; then
|
|
NS=
|
|
DOMAIN=
|
|
SEARCH=
|
|
i=1
|
|
while true ; do
|
|
eval opt=\$foreign_option_${i}
|
|
[ -z "${opt}" ] && break
|
|
if [ "${opt}" != "${opt#dhcp-option DOMAIN *}" ] ; then
|
|
if [ -z "${DOMAIN}" ] ; then
|
|
DOMAIN="${opt#dhcp-option DOMAIN *}"
|
|
else
|
|
SEARCH="${SEARCH}${SEARCH:+ }${opt#dhcp-option DOMAIN *}"
|
|
fi
|
|
elif [ "${opt}" != "${opt#dhcp-option DNS *}" ] ; then
|
|
NS="${NS}nameserver ${opt#dhcp-option DNS *}\n"
|
|
fi
|
|
i=$((${i} + 1))
|
|
done
|
|
if [ -n "${NS}" ] ; then
|
|
DNS="# Generated by openvpn for interface ${dev}\n"
|
|
if [ -n "${SEARCH}" ] ; then
|
|
DNS="${DNS}search ${DOMAIN} ${SEARCH}\n"
|
|
elif [ -n "${DOMAIN}" ]; then
|
|
DNS="${DNS}domain ${DOMAIN}\n"
|
|
fi
|
|
DNS="${DNS}${NS}"
|
|
if [ -x /sbin/resolvconf ] ; then
|
|
printf "${DNS}" | /sbin/resolvconf -a "${dev}"
|
|
else
|
|
# Preserve the existing resolv.conf
|
|
if [ -e /etc/resolv.conf ] ; then
|
|
cp /etc/resolv.conf /etc/resolv.conf-"${dev}".sv
|
|
fi
|
|
printf "${DNS}" > /etc/resolv.conf
|
|
chmod 644 /etc/resolv.conf
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
/etc/transmission/start.sh "$@"
|
|
[[ ! -f /opt/tinyproxy/start.sh ]] || /opt/tinyproxy/start.sh
|
|
|
|
exit 0 |