Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: focal
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions openvpn/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]*$~~')

echo "[info] Adding ${name_server_item} to resolv.conf" | ts '%Y-%m-%d %H:%M:%.S'
echo "nameserver ${name_server_item}" >> /etc/resolv.conf

# 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
Expand Down