Skip to content

Commit

Permalink
udhcpc: support resolv.conf symlinks
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
vapier committed Feb 27, 2013
1 parent 40b97fb commit 39b8fb4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions examples/udhcp/simple.script
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 39b8fb4

Please sign in to comment.