From 8fd695e69b97f4277e86dcd92994a6538b529ad6 Mon Sep 17 00:00:00 2001 From: Henning Heinold Date: Wed, 19 Aug 2015 20:37:09 +0200 Subject: [PATCH] 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 --- recipes-apps/images/image-static-dns.inc | 29 ++++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) 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 }