image-static-dns.bb: new image snippet to set a static dns configuration

Fixes: SYS#1126
This commit is contained in:
Henning Heinold 2015-05-19 17:23:39 +02:00 committed by Holger Hans Peter Freyther
parent 8b5f88e80b
commit a89b5587e2
1 changed files with 29 additions and 0 deletions

View File

@ -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
}