handle resolv.conf

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2016-06-16 16:02:29 +02:00
parent 4547d2efa1
commit ce82e32c59
1 changed files with 24 additions and 1 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/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. # This file is part of cdist.
# #
@ -25,6 +25,16 @@ remote_copy="$__type/files/remote/copy"
cdist_args="-v" cdist_args="-v"
[ "$__debug" = "yes" ] && cdist_args="$cdist_args -d" [ "$__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 cat << DONE
cdist $cdist_args \ cdist $cdist_args \
config \ config \
@ -32,3 +42,16 @@ cdist $cdist_args \
--remote-copy="$remote_copy $chroot" \ --remote-copy="$remote_copy $chroot" \
$__target_host $__target_host
DONE 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