need to pass a known suffix from outside

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2017-01-24 00:08:55 +01:00
parent 058e4d757b
commit 86a61bbcff
7 changed files with 60 additions and 8 deletions

View File

@ -21,8 +21,9 @@
chroot="/$__object_id"
if [ -f "$__object/parameter/manage-resolv-conf" ]; then
suffix="$(cat "$__object/parameter/manage-resolv-conf")"
resolv_conf="${chroot}/etc/resolv.conf"
original_resolv_conf="${resolv_conf}${__cdist_object_marker}"
original_resolv_conf="${resolv_conf}.${suffix}"
cat << DONE
$__remote_exec $__target_host << EOSSH
if [ -f "${resolv_conf}" ]; then

View File

@ -18,13 +18,17 @@ None
OPTIONAL PARAMETERS
-------------------
None
manage-resolv-conf
manage /etc/resolv.conf inside the chroot.
Use the value of this parameter as the suffix to save a copy
of the current /etc/resolv.conf to /etc/resolv.conf.$suffix.
This is used by the __chroot_umount type to restore the initial
file content when unmounting the chroot.
BOOLEAN PARAMETERS
------------------
manage-resolv-conf
manage /etc/resolv.conf inside the chroot
None.
EXAMPLES
@ -34,6 +38,9 @@ EXAMPLES
__chroot_mount /path/to/chroot
__chroot_mount /path/to/chroot \
--manage-resolv-conf "some-known-string"
AUTHORS
-------

View File

@ -21,8 +21,9 @@
chroot="/$__object_id"
if [ -f "$__object/parameter/manage-resolv-conf" ]; then
suffix="$(cat "$__object/parameter/manage-resolv-conf")"
resolv_conf="${chroot}/etc/resolv.conf"
original_resolv_conf="${resolv_conf}${__cdist_object_marker}"
original_resolv_conf="${resolv_conf}.${suffix}"
cat << DONE
$__remote_exec $__target_host << EOSSH
if [ -f "${original_resolv_conf}" ]; then

View File

@ -18,13 +18,17 @@ None
OPTIONAL PARAMETERS
-------------------
None
manage-resolv-conf
manage /etc/resolv.conf inside the chroot.
Use the value of this parameter as the suffix to find the backup file
that was saved by the __chroot_mount.
This is used by the to restore the initial file content when unmounting
the chroot.
BOOLEAN PARAMETERS
------------------
manage-resolv-conf
manage /etc/resolv.conf inside the chroot
None.
EXAMPLES
@ -34,6 +38,9 @@ EXAMPLES
__chroot_umount /path/to/chroot
__chroot_umount /path/to/chroot \
--manage-resolv-conf "some-known-string"
SEE ALSO
--------

View File

@ -0,0 +1,36 @@
#!/bin/sh
#
# 2016 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
chroot="/$__object_id"
if [ -f "$__object/parameter/manage-resolv-conf" ]; then
suffix="$(cat "$__object/parameter/manage-resolv-conf")"
resolv_conf="${chroot}/etc/resolv.conf"
original_resolv_conf="${resolv_conf}.${suffix}"
cat << DONE
$__remote_exec $__target_host << EOSSH
if [ -f "${original_resolv_conf}" ]; then
# restore original /etc/resolv.conf that we moved out of the way
# in __chroot_mount/gencode-local
mv -f "${original_resolv_conf}" "${resolv_conf}"
fi
EOSSH
DONE
fi