From 61367e146998f59de67dc66c9e17f98eb6681d7c Mon Sep 17 00:00:00 2001 From: Jesse Young Date: Sun, 24 Oct 2010 11:59:57 -0500 Subject: [PATCH] Make static /etc/resolv.conf configurable via RESOLV_CONF The user may not want netcfg to clobber their resolv.conf. Instead allow the user to define where netcfg will output the generated resolv.conf. Using dnsmasq is an example of this use case. Signed-off-by: Jesse Young --- docs/ethernet | 8 +++++--- src/connections/ethernet | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/docs/ethernet b/docs/ethernet index 5df810a..dd9594b 100644 --- a/docs/ethernet +++ b/docs/ethernet @@ -23,16 +23,18 @@ IPCFG IFOPTS (deprecated, requires IP of 'static') : Arguments to pass to 'ifconfig'. This allows you to use the syntax for the older 'ifconfig' tool. Retained for compatability. ### DNS +RESOLV_CONF +: Path to resolver configuration. Defaults to /etc/resolv.conf DNS : Array of DNS nameservers. Simply specify the IP's of each of the DNS nameservers. SEARCH -: "search" line for /etc/resolv.conf +: "search" line for RESOLV_CONF DOMAIN -: "domain" line for /etc/resolv.conf +: "domain" line for RESOLV_CONF HOSTNAME : Set the system hostname. Ensure any hostname is correctly referenced in /etc/hosts. DNS1, DNS2 (deprecated) -: First and second DNS servers for /etc/resolv.conf +: First and second DNS servers for RESOLV_CONF ### DHCP DHCP_OPTIONS : String. Any extra arguments to pass to the dhcp client, presently dhcpcd. diff --git a/src/connections/ethernet b/src/connections/ethernet index 36f6b93..40738f9 100644 --- a/src/connections/ethernet +++ b/src/connections/ethernet @@ -114,20 +114,21 @@ ethernet_up() { fi # Generate a new resolv.conf + [[ -z "$RESOLV_CONF" ]] && RESOLV_CONF="/etc/resolv.conf" if [[ -n "$DNS" ]]; then - : >/etc/resolv.conf - [[ -n "$DOMAIN" ]] && echo "domain $DOMAIN" >>/etc/resolv.conf - [[ -n "$SEARCH" ]] && echo "search $SEARCH" >>/etc/resolv.conf + : >"$RESOLV_CONF" + [[ -n "$DOMAIN" ]] && echo "domain $DOMAIN" >>"$RESOLV_CONF" + [[ -n "$SEARCH" ]] && echo "search $SEARCH" >>"$RESOLV_CONF" for dns in "${DNS[@]}"; do - echo "nameserver $dns" >>/etc/resolv.conf + echo "nameserver $dns" >>"$RESOLV_CONF" done elif [[ -n "$DNS1" ]]; then # support older 'ethernet' syntax. - : >/etc/resolv.conf - [[ -n "$DOMAIN" ]] && echo "domain $DOMAIN" >>/etc/resolv.conf - [[ -n "$SEARCH" ]] && echo "search $SEARCH" >>/etc/resolv.conf - [[ -n "$DNS1" ]] && echo "nameserver $DNS1" >>/etc/resolv.conf - [[ -n "$DNS2" ]] && echo "nameserver $DNS2" >>/etc/resolv.conf + : >"$RESOLV_CONF" + [[ -n "$DOMAIN" ]] && echo "domain $DOMAIN" >>"$RESOLV_CONF" + [[ -n "$SEARCH" ]] && echo "search $SEARCH" >>"$RESOLV_CONF" + [[ -n "$DNS1" ]] && echo "nameserver $DNS1" >>"$RESOLV_CONF" + [[ -n "$DNS2" ]] && echo "nameserver $DNS2" >>"$RESOLV_CONF" fi return 0 -- 1.7.2.3