From ce82e32c5962af7ad473fa83d63f29c39e7d1feb Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 16 Jun 2016 16:02:29 +0200 Subject: [PATCH] handle resolv.conf Signed-off-by: Steven Armstrong --- .../conf/type/__install_config/gencode-local | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__install_config/gencode-local b/cdist/conf/type/__install_config/gencode-local index 6f9bb3c7..4f1dcc23 100755 --- a/cdist/conf/type/__install_config/gencode-local +++ b/cdist/conf/type/__install_config/gencode-local @@ -1,6 +1,6 @@ #!/bin/sh # -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011-2016 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -25,6 +25,16 @@ remote_copy="$__type/files/remote/copy" cdist_args="-v" [ "$__debug" = "yes" ] && cdist_args="$cdist_args -d" + +cat << DONE +$__remote_exec $__target_host << EOSSH +if [ ! -f "${chroot}/etc/resolv.conf" ]; then + touch "${chroot}/etc/resolv.conf" +fi +mount --bind -o ro /etc/resolv.conf "${chroot}/etc/resolv.conf" +EOSSH +DONE + cat << DONE cdist $cdist_args \ config \ @@ -32,3 +42,16 @@ cdist $cdist_args \ --remote-copy="$remote_copy $chroot" \ $__target_host DONE + +cat << DONE +$__remote_exec $__target_host << EOSSH +if mountpoint -q "${chroot}/etc/resolv.conf"; + umount "${chroot}/etc/resolv.conf" +fi +if [ -f "${chroot}/etc/resolv.conf" -a ! -s "${chroot}/etc/resolv.conf" ]; then + # file exists but is empty which means we created it or it's useless anyway + rm "${chroot}/etc/resolv.conf" +fi + +EOSSH +DONE