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:
parent
4d0adcb963
commit
8fd695e69b
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue