fix: openvpn/start.sh add condition to prevent appending duplicative name server entries

This commit is contained in:
Garret Premo 2024-12-19 10:10:13 -05:00 committed by GitHub
parent 2dbbbc6006
commit 51a7c6fdeb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -144,9 +144,13 @@ for name_server_item in "${name_server_list[@]}"; do
# strip whitespace from start and end of lan_network_item
name_server_item=$(echo "${name_server_item}" | sed -e 's~^[ \t]*~~;s~[ \t]*$~~')
# check if name server is already defined
existing_name_servers=$(awk "/^nameserver ${name_server_item}$/" /etc/resolv.conf | wc -l)
if [ "$existing_name_servers" -eq 0 ]; then
echo "[info] Adding ${name_server_item} to resolv.conf" | ts '%Y-%m-%d %H:%M:%.S'
echo "nameserver ${name_server_item}" >> /etc/resolv.conf
fi
done
if [[ -z "${PUID}" ]]; then