34 lines
969 B
Bash
34 lines
969 B
Bash
#!/bin/sh
|
|
#===============================================================================
|
|
#
|
|
# resolv
|
|
#
|
|
# Copyright (C) 2014 by Digi International Inc.
|
|
# All rights reserved.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License version 2 as published by
|
|
# the Free Software Foundation.
|
|
#
|
|
#
|
|
# !Description: Configure static DNS servers with ifup
|
|
#
|
|
#===============================================================================
|
|
|
|
# Only for static method
|
|
[ "${METHOD}" != "static" ] && exit 0
|
|
|
|
RESOLVCONF="/etc/resolv.conf"
|
|
|
|
# For symlinks reset to the destination file
|
|
[ -h "${RESOLVCONF}" ] && RESOLVCONF="$(readlink ${RESOLVCONF})"
|
|
|
|
NAMESERVERS=""
|
|
for NS in ${IF_DNS_NAMESERVER} ${IF_DNS_NAMESERVERS}; do
|
|
NAMESERVERS="${NAMESERVERS:+${NAMESERVERS}\n}nameserver ${NS}"
|
|
done
|
|
|
|
if [ -n "${RESOLVCONF}" -a -n "${NAMESERVERS}" ]; then
|
|
printf "${NAMESERVERS}\n" > "${RESOLVCONF}"
|
|
fi
|