aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2013-02-27 01:01:43 -0500
committerMike Frysinger <vapier@gentoo.org>2013-02-27 01:01:43 -0500
commit39b8fb41c50e6ee0aaca81cde2a4dec98d45ef9a (patch)
tree44f4d1a9b44bbaf98e28e94d8c20c784e5882f63 /examples
parent40b97fb31ec7c24db706b47182f400f2a13dbbfc (diff)
downloadbusybox-w32-39b8fb41c50e6ee0aaca81cde2a4dec98d45ef9a.tar.gz
busybox-w32-39b8fb41c50e6ee0aaca81cde2a4dec98d45ef9a.tar.bz2
busybox-w32-39b8fb41c50e6ee0aaca81cde2a4dec98d45ef9a.zip
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>
Diffstat (limited to 'examples')
-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 40ee73822..d42f2d3d5 100755
--- a/examples/udhcp/simple.script
+++ b/examples/udhcp/simple.script
@@ -34,13 +34,17 @@ case "$1" in
34 fi 34 fi
35 35
36 echo "Recreating $RESOLV_CONF" 36 echo "Recreating $RESOLV_CONF"
37 echo -n > $RESOLV_CONF-$$ 37 # If the file is a symlink somewhere (like /etc/resolv.conf
38 [ -n "$domain" ] && echo "search $domain" >> $RESOLV_CONF-$$ 38 # pointing to /run/resolv.conf), make sure things work.
39 realconf=$(realpath "$RESOLV_CONF" 2>/dev/null || echo "$RESOLV_CONF")
40 tmpfile="$realconf-$$"
41 > "$tmpfile"
42 [ -n "$domain" ] && echo "search $domain" >> "$tmpfile"
39 for i in $dns ; do 43 for i in $dns ; do
40 echo " Adding DNS server $i" 44 echo " Adding DNS server $i"
41 echo "nameserver $i" >> $RESOLV_CONF-$$ 45 echo "nameserver $i" >> "$tmpfile"
42 done 46 done
43 mv $RESOLV_CONF-$$ $RESOLV_CONF 47 mv "$tmpfile" "$realconf"
44 ;; 48 ;;
45esac 49esac
46 50