summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2013-02-27 06:01:43 (GMT)
committer Mike Frysinger <vapier@gentoo.org>2013-02-27 06:01:43 (GMT)
commit39b8fb41c50e6ee0aaca81cde2a4dec98d45ef9a (patch)
tree44f4d1a9b44bbaf98e28e94d8c20c784e5882f63
parent40b97fb31ec7c24db706b47182f400f2a13dbbfc (diff)
downloadbusybox-39b8fb41c50e6ee0aaca81cde2a4dec98d45ef9a.tar.gz
busybox-39b8fb41c50e6ee0aaca81cde2a4dec98d45ef9a.tar.bz2
udhcpc: support resolv.conf symlinks
Often it is desirable to have /etc/ be on read-only storage (well, the whole rootfs) but have things like /etc/resolv.conf be symlinks to a writable location. Tweak the simple script to support that. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rwxr-xr-xexamples/udhcp/simple.script12
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/udhcp/simple.script b/examples/udhcp/simple.script
index 40ee738..d42f2d3 100755
--- a/examples/udhcp/simple.script
+++ b/examples/udhcp/simple.script
@@ -34,13 +34,17 @@ case "$1" in
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