image-static-dns.inc: fix several items

* use printf instead of echo
* add missing /etc/ for the udhcpc-default file
* add log-entries for all shell actions in the
  post image setup
* generate comments in all files which are touched

Related: SYS#1774
This commit is contained in:
Henning Heinold 2015-08-19 20:37:09 +02:00 committed by Holger Hans Peter Freyther
parent 4d0adcb963
commit 8fd695e69b
1 changed files with 22 additions and 7 deletions

View File

@ -8,22 +8,37 @@ DNSSEARCH = "${@d.getVar('DNS_SEARCH', True) or ''}"
ROOTFS_POSTPROCESS_COMMAND += "set_static_dns;" ROOTFS_POSTPROCESS_COMMAND += "set_static_dns;"
set_static_dns() { set_static_dns() {
echo "#created by image-static-dns.inc" > ${IMAGE_ROOTFS}/etc/resolv.conf printf "Replacing /etc/resolv.conf\n"
printf "#This default-file was generated by the image-static-dns hook\n \
in the post-image setup.\n\n" > ${IMAGE_ROOTFS}/etc/resolv.conf
if [ -n "${DNSSERVER}" ]; then if [ -n "${DNSSERVER}" ]; then
printf "setting DNS-server\n" printf "setting DNS-server\n"
echo "nameserver ${DNSSERVER}" >> ${IMAGE_ROOTFS}/etc/resolv.conf printf "nameserver %s\n" "${DNSSERVER}" >> ${IMAGE_ROOTFS}/etc/resolv.conf
fi fi
if [ -n "${DNSDOMAIN}" ]; then if [ -n "${DNSDOMAIN}" ]; then
printf "setting DNS-domain\n" printf "setting DNS-domain\n"
echo "domain ${DNSDOMAIN}" >> ${IMAGE_ROOTFS}/etc/resolv.conf printf "domain %s\n" "${DNSDOMAIN}" >> ${IMAGE_ROOTFS}/etc/resolv.conf
fi fi
if [ -n "${DNSSEARCH}" ]; then if [ -n "${DNSSEARCH}" ]; then
printf "seting DNS-search\n" printf "setting DNS-search\n"
echo "search ${DNSSEARCH}" >> ${IMAGE_ROOTFS}/etc/resolv.conf printf "search %s\n" "${DNSSEARCH}" >> ${IMAGE_ROOTFS}/etc/resolv.conf
fi fi
if [ -w ${IMAGE_ROOTFS}/default/udhcpc ]; then if [ -w ${IMAGE_ROOTFS}/etc/default/udhcpc ]; then
sed -i -e "s/^#.*\(STATIC_DNS\).*$/\1=yes/g" ${IMAGE_ROOTFS}/default/udhcpc printf "Configure the installed udhcpc for static DNS\n"
STATIC_DNS_TEXT="# The static-dns configuration was generated by the image-static-dns hook."
sed -i -e "s/^#.*\(STATIC_DNS\).*$/${STATIC_DNS_TEXT}\n\1=\"yes\"/g" ${IMAGE_ROOTFS}/etc/default/udhcpc
else
printf "Configure the not installed udhcpc for static DNS\n"
mkdir -p ${IMAGE_ROOTFS}/etc/default
cat << EOF > ${IMAGE_ROOTFS}/etc/default/udhcpc
#This default-file was generated by the image-static-dns hook,
#in the post-image setup.
#
#When udhcpc is installed one setup needs to be chosen.
STATIC_DNS="yes"
EOF
fi fi
} }