forked from ungleich-public/cdist
Backport __chroot_mount, __chroot_umount and __install variants from Steven
This commit is contained in:
parent
e7fa238b2a
commit
c93d0ba8a3
11 changed files with 143 additions and 10 deletions
36
cdist/conf/type/__chroot_mount/gencode-local
Executable file
36
cdist/conf/type/__chroot_mount/gencode-local
Executable 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 "${resolv_conf}" ]; then
|
||||
mv "${resolv_conf}" "${original_resolv_conf}"
|
||||
fi
|
||||
# copy hosts resolv.conf into chroot
|
||||
cp /etc/resolv.conf "${resolv_conf}"
|
||||
EOSSH
|
||||
DONE
|
||||
fi
|
|
@ -41,8 +41,4 @@ mountpoint -q "${chroot}/dev/pts" \
|
|||
[ -d "${chroot}/tmp" ] || mkdir -m 1777 "${chroot}/tmp"
|
||||
mountpoint -q "${chroot}/tmp" \
|
||||
|| mount -t tmpfs -o mode=1777,strictatime,nodev,nosuid tmpfs "${chroot}/tmp"
|
||||
|
||||
if [ ! -f "${chroot}/etc/resolv.conf" ]; then
|
||||
cp /etc/resolv.conf "${chroot}/etc/"
|
||||
fi
|
||||
DONE
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
cdist-type__chroot_mount(7)
|
||||
===================================
|
||||
===========================
|
||||
|
||||
NAME
|
||||
----
|
||||
|
@ -18,7 +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
|
||||
------------------
|
||||
None.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
|
@ -28,6 +38,9 @@ EXAMPLES
|
|||
|
||||
__chroot_mount /path/to/chroot
|
||||
|
||||
__chroot_mount /path/to/chroot \
|
||||
--manage-resolv-conf "some-known-string"
|
||||
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
|
@ -36,7 +49,7 @@ Steven Armstrong <steven-cdist--@--armstrong.cc>
|
|||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2012 Steven Armstrong. You can redistribute it
|
||||
Copyright \(C) 2012-2017 Steven Armstrong. 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.
|
||||
|
|
1
cdist/conf/type/__chroot_mount/parameter/optional
Normal file
1
cdist/conf/type/__chroot_mount/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
|||
manage-resolv-conf
|
36
cdist/conf/type/__chroot_umount/gencode-local
Executable file
36
cdist/conf/type/__chroot_umount/gencode-local
Executable 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
|
|
@ -26,7 +26,6 @@ umount -l "${chroot}/dev/pts"
|
|||
umount -l "${chroot}/dev"
|
||||
umount -l "${chroot}/sys"
|
||||
umount -l "${chroot}/proc"
|
||||
rm -f "${chroot}/etc/resolv.conf"
|
||||
if [ -d "${chroot}/etc/resolvconf/resolv.conf.d" ]; then
|
||||
# ensure /etc/resolvconf/resolv.conf.d/tail is not linked to \
|
||||
# e.g. /etc/resolvconf/resolv.conf.d/original
|
||||
|
|
|
@ -18,7 +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
|
||||
------------------
|
||||
None.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
|
@ -28,6 +38,9 @@ EXAMPLES
|
|||
|
||||
__chroot_umount /path/to/chroot
|
||||
|
||||
__chroot_umount /path/to/chroot \
|
||||
--manage-resolv-conf "some-known-string"
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
|
@ -41,7 +54,7 @@ Steven Armstrong <steven-cdist--@--armstrong.cc>
|
|||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2012 Steven Armstrong. You can redistribute it
|
||||
Copyright \(C) 2012-2017 Steven Armstrong. 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.
|
||||
|
|
36
cdist/conf/type/__chroot_umount/manifest
Executable file
36
cdist/conf/type/__chroot_umount/manifest
Executable 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
|
1
cdist/conf/type/__chroot_umount/parameter/optional
Normal file
1
cdist/conf/type/__chroot_umount/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
|||
manage-resolv-conf
|
1
cdist/conf/type/__install_chroot_mount/parameter
Symbolic link
1
cdist/conf/type/__install_chroot_mount/parameter
Symbolic link
|
@ -0,0 +1 @@
|
|||
../__chroot_mount/parameter
|
1
cdist/conf/type/__install_chroot_umount/parameter
Symbolic link
1
cdist/conf/type/__install_chroot_umount/parameter
Symbolic link
|
@ -0,0 +1 @@
|
|||
../__chroot_umount/parameter
|
Loading…
Reference in a new issue