fi
echo "Recreating $RESOLV_CONF"
- echo -n > $RESOLV_CONF-$$
- [ -n "$domain" ] && echo "search $domain" >> $RESOLV_CONF-$$
+ # If the file is a symlink somewhere (like /etc/resolv.conf
+ # pointing to /run/resolv.conf), make sure things work.
+ realconf=$(realpath "$RESOLV_CONF" 2>/dev/null || echo "$RESOLV_CONF")
+ tmpfile="$realconf-$$"
+ > "$tmpfile"
+ [ -n "$domain" ] && echo "search $domain" >> "$tmpfile"
for i in $dns ; do
echo " Adding DNS server $i"
- echo "nameserver $i" >> $RESOLV_CONF-$$
+ echo "nameserver $i" >> "$tmpfile"
done
- mv $RESOLV_CONF-$$ $RESOLV_CONF
+ mv "$tmpfile" "$realconf"
;;
esac