[ntp] ignore duplicate servers from dhclient
Miroslav Lichvar
mlichvar at fedoraproject.org
Mon Jul 15 16:40:45 UTC 2013
commit cc2495980d2b6c80da9bae752356b0bf69b6ac57
Author: Miroslav Lichvar <mlichvar at redhat.com>
Date: Mon Jul 15 14:34:25 2013 +0200
ignore duplicate servers from dhclient
ntp.dhclient | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/ntp.dhclient b/ntp.dhclient
index 9608d93..1cc9f43 100755
--- a/ntp.dhclient
+++ b/ntp.dhclient
@@ -39,9 +39,12 @@ ntp_config() {
if [ ! "${PEERNTP}" = "no" ] && [ -n "${new_ntp_servers}" ] &&
[ -e ${CONF} ] && [ -d ${SAVEDIR} ]; then
local conf=$(grep -v '^server .* # added by /sbin/dhclient-script$' < ${CONF})
+ local unique_servers=$(comm -23 \
+ <(for s in ${new_ntp_servers}; do echo $s; done | sort -u) \
+ <(echo "$conf" | awk '$1=="peer"||$1=="server"{print $2}' | sort -u))
conf=$(echo "$conf"
- for s in ${new_ntp_servers}; do
+ for s in ${unique_servers}; do
echo "server ${s} ${NTPSERVERARGS} # added by /sbin/dhclient-script"
done)
More information about the scm-commits
mailing list