diff --git a/recipes-apps/images/image-static-dns.inc b/recipes-apps/images/image-static-dns.inc index 26bae49..4147135 100644 --- a/recipes-apps/images/image-static-dns.inc +++ b/recipes-apps/images/image-static-dns.inc @@ -8,22 +8,37 @@ DNSSEARCH = "${@d.getVar('DNS_SEARCH', True) or ''}" ROOTFS_POSTPROCESS_COMMAND += "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 printf "setting DNS-server\n" - echo "nameserver ${DNSSERVER}" >> ${IMAGE_ROOTFS}/etc/resolv.conf + printf "nameserver %s\n" "${DNSSERVER}" >> ${IMAGE_ROOTFS}/etc/resolv.conf fi if [ -n "${DNSDOMAIN}" ]; then printf "setting DNS-domain\n" - echo "domain ${DNSDOMAIN}" >> ${IMAGE_ROOTFS}/etc/resolv.conf + printf "domain %s\n" "${DNSDOMAIN}" >> ${IMAGE_ROOTFS}/etc/resolv.conf fi if [ -n "${DNSSEARCH}" ]; then - printf "seting DNS-search\n" - echo "search ${DNSSEARCH}" >> ${IMAGE_ROOTFS}/etc/resolv.conf + printf "setting DNS-search\n" + printf "search %s\n" "${DNSSEARCH}" >> ${IMAGE_ROOTFS}/etc/resolv.conf fi - if [ -w ${IMAGE_ROOTFS}/default/udhcpc ]; then - sed -i -e "s/^#.*\(STATIC_DNS\).*$/\1=yes/g" ${IMAGE_ROOTFS}/default/udhcpc + if [ -w ${IMAGE_ROOTFS}/etc/default/udhcpc ]; then + 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 }