From a89b5587e2601c6a325e7a748f392fb8025df515 Mon Sep 17 00:00:00 2001 From: Henning Heinold Date: Tue, 19 May 2015 17:23:39 +0200 Subject: [PATCH] image-static-dns.bb: new image snippet to set a static dns configuration Fixes: SYS#1126 --- recipes-apps/images/image-static-dns.inc | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 recipes-apps/images/image-static-dns.inc diff --git a/recipes-apps/images/image-static-dns.inc b/recipes-apps/images/image-static-dns.inc new file mode 100644 index 0000000..26bae49 --- /dev/null +++ b/recipes-apps/images/image-static-dns.inc @@ -0,0 +1,29 @@ +# set the variables DNS_SERVER, DNS_DOMAIN or DNS_SEARCH in your image file +# and require this file afterwards + +DNSSERVER = "${@d.getVar('DNS_SERVER', True) or ''}" +DNSDOMAIN = "${@d.getVar('DNS_DOMAIN', True) or ''}" +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 + if [ -n "${DNSSERVER}" ]; then + printf "setting DNS-server\n" + echo "nameserver ${DNSSERVER}" >> ${IMAGE_ROOTFS}/etc/resolv.conf + fi + if [ -n "${DNSDOMAIN}" ]; then + printf "setting DNS-domain\n" + echo "domain ${DNSDOMAIN}" >> ${IMAGE_ROOTFS}/etc/resolv.conf + fi + + if [ -n "${DNSSEARCH}" ]; then + printf "seting DNS-search\n" + echo "search ${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 + fi +}