forked from ungleich-public/cdist
Compare commits
10 commits
master
...
steven-bac
Author | SHA1 | Date | |
---|---|---|---|
|
d9a513e2a4 | ||
|
174fb3b7c8 | ||
|
d2694d83a9 | ||
|
f70a4acbb9 | ||
|
19b6dce8da | ||
|
7e768cc42a | ||
|
78511a63a8 | ||
|
3693cc9bbb | ||
|
fead1b6010 | ||
|
c93d0ba8a3 |
29 changed files with 416 additions and 120 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"
|
[ -d "${chroot}/tmp" ] || mkdir -m 1777 "${chroot}/tmp"
|
||||||
mountpoint -q "${chroot}/tmp" \
|
mountpoint -q "${chroot}/tmp" \
|
||||||
|| mount -t tmpfs -o mode=1777,strictatime,nodev,nosuid tmpfs "${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
|
DONE
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
cdist-type__chroot_mount(7)
|
cdist-type__chroot_mount(7)
|
||||||
===================================
|
===========================
|
||||||
|
|
||||||
NAME
|
NAME
|
||||||
----
|
----
|
||||||
|
@ -18,7 +18,17 @@ None
|
||||||
|
|
||||||
OPTIONAL PARAMETERS
|
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
|
EXAMPLES
|
||||||
|
@ -28,6 +38,9 @@ EXAMPLES
|
||||||
|
|
||||||
__chroot_mount /path/to/chroot
|
__chroot_mount /path/to/chroot
|
||||||
|
|
||||||
|
__chroot_mount /path/to/chroot \
|
||||||
|
--manage-resolv-conf "some-known-string"
|
||||||
|
|
||||||
|
|
||||||
AUTHORS
|
AUTHORS
|
||||||
-------
|
-------
|
||||||
|
@ -36,7 +49,7 @@ Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||||
|
|
||||||
COPYING
|
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
|
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
|
published by the Free Software Foundation, either version 3 of the
|
||||||
License, or (at your option) any later version.
|
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}/dev"
|
||||||
umount -l "${chroot}/sys"
|
umount -l "${chroot}/sys"
|
||||||
umount -l "${chroot}/proc"
|
umount -l "${chroot}/proc"
|
||||||
rm -f "${chroot}/etc/resolv.conf"
|
|
||||||
if [ -d "${chroot}/etc/resolvconf/resolv.conf.d" ]; then
|
if [ -d "${chroot}/etc/resolvconf/resolv.conf.d" ]; then
|
||||||
# ensure /etc/resolvconf/resolv.conf.d/tail is not linked to \
|
# ensure /etc/resolvconf/resolv.conf.d/tail is not linked to \
|
||||||
# e.g. /etc/resolvconf/resolv.conf.d/original
|
# e.g. /etc/resolvconf/resolv.conf.d/original
|
||||||
|
|
|
@ -18,7 +18,17 @@ None
|
||||||
|
|
||||||
OPTIONAL PARAMETERS
|
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
|
EXAMPLES
|
||||||
|
@ -28,6 +38,9 @@ EXAMPLES
|
||||||
|
|
||||||
__chroot_umount /path/to/chroot
|
__chroot_umount /path/to/chroot
|
||||||
|
|
||||||
|
__chroot_umount /path/to/chroot \
|
||||||
|
--manage-resolv-conf "some-known-string"
|
||||||
|
|
||||||
|
|
||||||
SEE ALSO
|
SEE ALSO
|
||||||
--------
|
--------
|
||||||
|
@ -41,7 +54,7 @@ Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||||
|
|
||||||
COPYING
|
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
|
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
|
published by the Free Software Foundation, either version 3 of the
|
||||||
License, or (at your option) any later version.
|
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
|
100
cdist/conf/type/__install_bootloader_grub/explorer/target_os
Executable file
100
cdist/conf/type/__install_bootloader_grub/explorer/target_os
Executable file
|
@ -0,0 +1,100 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
|
# 2014 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/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# All os variables are lower case. Keep this file in alphabetical
|
||||||
|
# order by os variable except in cases where order otherwise matters,
|
||||||
|
# in which case keep the primary os and its derivatives together in
|
||||||
|
# a block (see Debian and Redhat examples below).
|
||||||
|
#
|
||||||
|
|
||||||
|
chroot="$(cat "$__object/parameter/chroot")"
|
||||||
|
|
||||||
|
if grep -q ^Amazon "$chroot/etc/system-release" 2>/dev/null; then
|
||||||
|
echo amazon
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$chroot/etc/arch-release" ]; then
|
||||||
|
echo archlinux
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$chroot/etc/cdist-preos" ]; then
|
||||||
|
echo cdist-preos
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
### Debian and derivatives
|
||||||
|
if grep -q ^DISTRIB_ID=Ubuntu "$chroot/etc/lsb-release" 2>/dev/null; then
|
||||||
|
echo ubuntu
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$chroot/etc/debian_version" ]; then
|
||||||
|
echo debian
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
###
|
||||||
|
|
||||||
|
if [ -f "$chroot/etc/gentoo-release" ]; then
|
||||||
|
echo gentoo
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$chroot/etc/openwrt_version" ]; then
|
||||||
|
echo openwrt
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$chroot/etc/owl-release" ]; then
|
||||||
|
echo owl
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
### Redhat and derivatives
|
||||||
|
if grep -q ^CentOS "$chroot/etc/redhat-release" 2>/dev/null; then
|
||||||
|
echo centos
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -q ^Fedora "$chroot/etc/redhat-release" 2>/dev/null; then
|
||||||
|
echo fedora
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$chroot/etc/redhat-release" ]; then
|
||||||
|
echo redhat
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
###
|
||||||
|
|
||||||
|
if [ -f "$chroot/etc/SuSE-release" ]; then
|
||||||
|
echo suse
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$chroot/etc/slackware-version" ]; then
|
||||||
|
echo slackware
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Unknown OS" >&2
|
||||||
|
exit 1
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 2011-2015 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -18,51 +18,74 @@
|
||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
device="$(cat "$__object/parameter/device")"
|
device="$(cat "$__object/parameter/device" 2>/dev/null || echo "/$__object_id")"
|
||||||
chroot="$(cat "$__object/parameter/chroot")"
|
chroot="$(cat "$__object/parameter/chroot")"
|
||||||
|
|
||||||
|
target_os=$(cat "$__object/explorer/target_os")
|
||||||
|
|
||||||
|
mkdir "$__object/files"
|
||||||
|
install_script="$__object/files/install_script"
|
||||||
|
# Link file descriptor #6 with stdout
|
||||||
|
exec 6>&1
|
||||||
|
# Link stdout with $install_script
|
||||||
|
exec > $install_script
|
||||||
|
|
||||||
|
# Generate script to install bootloader on distro
|
||||||
|
printf '#!/bin/sh -l\n'
|
||||||
|
|
||||||
|
case "$target_os" in
|
||||||
|
ubuntu|debian)
|
||||||
|
if [ -s "$__global/explorer/efi" ]; then
|
||||||
|
# FIXME: untested. maybe also just run update-grub for EFI system?
|
||||||
|
printf 'grub-mkconfig --output=/boot/efi/EFI/%s/grub.cfg\n' "$target_os"
|
||||||
|
printf 'mkdir -p /boot/efi/EFI/BOOT\n'
|
||||||
|
printf 'cp /boot/efi/EFI/%s/grubx64.efi /boot/efi/EFI/BOOT/bootx64.efi' "$target_os"
|
||||||
|
else
|
||||||
|
printf 'grub-install "%s"\n' "$device"
|
||||||
|
printf 'update-grub\n'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
archlinux)
|
||||||
|
if [ -s "$__global/explorer/efi" ]; then
|
||||||
|
echo "EFI boot loader installation is on your operating system ($target_os) is currently not supported by this type (${__type##*/})." >&2
|
||||||
|
echo "Please contribute an implementation for it if you can." >&2
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
printf 'grub-install "%s"\n' "$device"
|
||||||
|
# bugfix/workarround: rebuild initramfs
|
||||||
|
# FIXME: doesn't belong here
|
||||||
|
printf 'mkinitcpio -p linux\n'
|
||||||
|
printf 'grub-mkconfig -o /boot/grub/grub.cfg\n'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
centos)
|
||||||
|
if [ -s "$__global/explorer/efi" ]; then
|
||||||
|
printf 'grub2-mkconfig --output=/boot/efi/EFI/%s/grub.cfg\n' "$target_os"
|
||||||
|
printf 'mkdir -p /boot/efi/EFI/BOOT\n'
|
||||||
|
printf 'cp /boot/efi/EFI/%s/grubx64.efi /boot/efi/EFI/BOOT/bootx64.efi' "$target_os"
|
||||||
|
else
|
||||||
|
printf 'grub2-install "%s"\n' "$device"
|
||||||
|
printf 'grub2-mkconfig --output=/boot/grub2/grub.cfg\n'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Your operating system ($target_os) is currently not supported by this type (${__type##*/})." >&2
|
||||||
|
echo "If you can, please contribute an implementation for it." >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
# Restore stdout and close file descriptor #6.
|
||||||
|
exec 1>&6 6>&-
|
||||||
|
|
||||||
|
|
||||||
cat << DONE
|
cat << DONE
|
||||||
os=\$(
|
|
||||||
if grep -q ^DISTRIB_ID=Ubuntu ${chroot}/etc/lsb-release 2>/dev/null; then
|
|
||||||
echo ubuntu
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f ${chroot}/etc/arch-release ]; then
|
|
||||||
echo archlinux
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f ${chroot}/etc/debian_version ]; then
|
|
||||||
echo debian
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
)
|
|
||||||
|
|
||||||
# Ensure /tmp exists
|
# Ensure /tmp exists
|
||||||
[ -d "${chroot}/tmp" ] || mkdir -m 1777 "${chroot}/tmp"
|
[ -d "${chroot}/tmp" ] || mkdir -m 1777 "${chroot}/tmp"
|
||||||
# Generate script to run in chroot
|
# Generate script to run in chroot
|
||||||
script=\$(mktemp "${chroot}/tmp/__install_bootloader_grub.XXXXXXXXXX")
|
script=\$(mktemp "${chroot}/tmp/${__type##*/}.XXXXXXXXXX")
|
||||||
# Link file descriptor #6 with stdout
|
cat > \$script << script_DONE
|
||||||
exec 6>&1
|
$(cat "$install_script")
|
||||||
# Link stdout with \$script
|
script_DONE
|
||||||
exec > \$script
|
|
||||||
|
|
||||||
echo "#!/bin/sh -l"
|
|
||||||
echo "grub-install $device"
|
|
||||||
case \$os in
|
|
||||||
archlinux)
|
|
||||||
# bugfix/workarround: rebuild initramfs
|
|
||||||
# FIXME: doesn't belong here
|
|
||||||
echo "mkinitcpio -p linux"
|
|
||||||
echo "grub-mkconfig -o /boot/grub/grub.cfg"
|
|
||||||
;;
|
|
||||||
ubuntu|debian) echo "update-grub" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Restore stdout and close file descriptor #6.
|
|
||||||
exec 1>&6 6>&-
|
|
||||||
|
|
||||||
# Make script executable
|
# Make script executable
|
||||||
chmod +x "\$script"
|
chmod +x "\$script"
|
||||||
|
@ -70,4 +93,5 @@ chmod +x "\$script"
|
||||||
# Run script in chroot
|
# Run script in chroot
|
||||||
relative_script="\${script#$chroot}"
|
relative_script="\${script#$chroot}"
|
||||||
chroot "$chroot" "\$relative_script"
|
chroot "$chroot" "\$relative_script"
|
||||||
|
rm -rf \$script
|
||||||
DONE
|
DONE
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
/target
|
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
|
|
@ -25,7 +25,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
echo "$@" | logger -t "__install_config copy"
|
#echo "$@" | logger -t "__install_config copy"
|
||||||
:
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
echo "$@" | logger -t "__install_config exec"
|
#echo "$@" | logger -t "__install_config exec"
|
||||||
:
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,10 @@ target_host="$__target_host"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
ssh="ssh -o User=root -q $target_host"
|
ssh="ssh -o User=root -q $target_host"
|
||||||
code="$ssh chroot $chroot sh -c '$@'"
|
|
||||||
|
# escape ' with '"'"'
|
||||||
|
code="$(echo "$@" | sed -e "s/'/'\"'\"'/g")"
|
||||||
|
code="$ssh chroot $chroot sh -c '$code'"
|
||||||
|
|
||||||
log "target_host: $target_host"
|
log "target_host: $target_host"
|
||||||
log "chroot: $chroot"
|
log "chroot: $chroot"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 2011-2017 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -22,29 +22,15 @@ chroot="$(cat "$__object/parameter/chroot")"
|
||||||
remote_exec="$__type/files/remote/exec"
|
remote_exec="$__type/files/remote/exec"
|
||||||
remote_copy="$__type/files/remote/copy"
|
remote_copy="$__type/files/remote/copy"
|
||||||
|
|
||||||
cdist_args="-v"
|
cdist_args=""
|
||||||
[ "$__debug" = "yes" ] && cdist_args="$cdist_args -d"
|
[ "$__verbose" = "yes" ] && cdist_args="-vv"
|
||||||
|
[ "$__debug" = "yes" ] && cdist_args="-d"
|
||||||
|
|
||||||
cat << DONE
|
cat << DONE
|
||||||
#echo "__apt_noautostart --state present" \
|
cdist config \
|
||||||
# | cdist $cdist_args \
|
$cdist_args \
|
||||||
# config \
|
|
||||||
# --initial-manifest - \
|
|
||||||
# --remote-exec="$remote_exec $chroot" \
|
|
||||||
# --remote-copy="$remote_copy $chroot" \
|
|
||||||
# $__target_host
|
|
||||||
|
|
||||||
cdist $cdist_args \
|
|
||||||
config \
|
|
||||||
--remote-exec="$remote_exec $chroot" \
|
--remote-exec="$remote_exec $chroot" \
|
||||||
--remote-copy="$remote_copy $chroot" \
|
--remote-copy="$remote_copy $chroot" \
|
||||||
$__target_host
|
$__target_host
|
||||||
|
|
||||||
#echo "__apt_noautostart --state absent" \
|
|
||||||
# | cdist $cdist_args \
|
|
||||||
# config \
|
|
||||||
# --initial-manifest - \
|
|
||||||
# --remote-exec="$remote_exec $chroot" \
|
|
||||||
# --remote-copy="$remote_copy $chroot" \
|
|
||||||
# $__target_host
|
|
||||||
DONE
|
DONE
|
||||||
|
|
||||||
|
|
1
cdist/conf/type/__install_directory/explorer
Symbolic link
1
cdist/conf/type/__install_directory/explorer
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../__directory/explorer
|
1
cdist/conf/type/__install_directory/gencode-remote
Symbolic link
1
cdist/conf/type/__install_directory/gencode-remote
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../__directory/gencode-remote
|
0
cdist/conf/type/__install_directory/install
Normal file
0
cdist/conf/type/__install_directory/install
Normal file
1
cdist/conf/type/__install_directory/man.rst
Symbolic link
1
cdist/conf/type/__install_directory/man.rst
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../__directory/man.rst
|
1
cdist/conf/type/__install_directory/parameter
Symbolic link
1
cdist/conf/type/__install_directory/parameter
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../__directory/parameter
|
|
@ -25,7 +25,7 @@ mkdir "$__object/files"
|
||||||
# get current UUID's from target_host
|
# get current UUID's from target_host
|
||||||
$__remote_exec $__target_host blkid > "$__object/files/blkid"
|
$__remote_exec $__target_host blkid > "$__object/files/blkid"
|
||||||
|
|
||||||
for object in $(find "$__global/object/__install_mount" -path "*.cdist"); do
|
for object in $(find "$__global/object/__install_mount" -type d -name "$__cdist_object_marker"); do
|
||||||
device="$(cat "$object/parameter/device")"
|
device="$(cat "$object/parameter/device")"
|
||||||
dir="$(cat "$object/parameter/dir")"
|
dir="$(cat "$object/parameter/dir")"
|
||||||
prefix="$(cat "$object/parameter/prefix")"
|
prefix="$(cat "$object/parameter/prefix")"
|
||||||
|
@ -44,6 +44,11 @@ for object in $(find "$__global/object/__install_mount" -path "*.cdist"); do
|
||||||
tmpfs)
|
tmpfs)
|
||||||
pass=0
|
pass=0
|
||||||
;;
|
;;
|
||||||
|
bind)
|
||||||
|
pass=0
|
||||||
|
type=none
|
||||||
|
options="bind,$options"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
pass=1
|
pass=1
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
# 2017 Nico Schottelius (nico-cdist at schottelius.org)
|
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -24,30 +23,47 @@ type="$(cat "$__object/parameter/type")"
|
||||||
|
|
||||||
case "$type" in
|
case "$type" in
|
||||||
swap)
|
swap)
|
||||||
echo "mkswap $device"
|
echo "mkswap -f $device"
|
||||||
exit 0
|
|
||||||
;;
|
;;
|
||||||
xfs)
|
xfs)
|
||||||
command="mkfs.xfs -f -q"
|
command="mkfs.xfs -f -q"
|
||||||
;;
|
if [ -f "$__object/parameter/options" ]; then
|
||||||
|
|
||||||
vfat)
|
|
||||||
command="mkfs.vfat"
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
command="mkfs -t $type -q"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -f "$__object/parameter/options" ]; then
|
|
||||||
options="$(cat "$__object/parameter/options")"
|
options="$(cat "$__object/parameter/options")"
|
||||||
command="$command $options"
|
command="$command $options"
|
||||||
fi
|
fi
|
||||||
|
command="$command $device"
|
||||||
command="$command $device"
|
if [ -f "$__object/parameter/blocks" ]; then
|
||||||
if [ -f "$__object/parameter/blocks" ]; then
|
|
||||||
blocks="$(cat "$__object/parameter/blocks")"
|
blocks="$(cat "$__object/parameter/blocks")"
|
||||||
command="$command $blocks"
|
command="$command $blocks"
|
||||||
fi
|
fi
|
||||||
echo "$command"
|
echo "$command"
|
||||||
|
;;
|
||||||
|
vfat)
|
||||||
|
command="mkfs.vfat"
|
||||||
|
if [ -n "$fat_size" ]; then
|
||||||
|
command="$command -F $fat_size"
|
||||||
|
fi
|
||||||
|
if [ -f "$__object/parameter/options" ]; then
|
||||||
|
options="$(cat "$__object/parameter/options")"
|
||||||
|
command="$command $options"
|
||||||
|
fi
|
||||||
|
command="$command $device"
|
||||||
|
if [ -f "$__object/parameter/blocks" ]; then
|
||||||
|
blocks="$(cat "$__object/parameter/blocks")"
|
||||||
|
command="$command $blocks"
|
||||||
|
fi
|
||||||
|
echo "$command"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
command="mkfs -t $type -q"
|
||||||
|
if [ -f "$__object/parameter/options" ]; then
|
||||||
|
options="$(cat "$__object/parameter/options")"
|
||||||
|
command="$command $options"
|
||||||
|
fi
|
||||||
|
command="$command $device"
|
||||||
|
if [ -f "$__object/parameter/blocks" ]; then
|
||||||
|
blocks="$(cat "$__object/parameter/blocks")"
|
||||||
|
command="$command $blocks"
|
||||||
|
fi
|
||||||
|
echo "$command"
|
||||||
|
esac
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
get_type_from_mkfs() {
|
get_type_from_mkfs() {
|
||||||
_device="$1"
|
_device="$1"
|
||||||
for mkfs_object in $(find "$__global/object/__install_mkfs" -path "*.cdist"); do
|
for mkfs_object in $(find "$__global/object/__install_mkfs" -type d -name "$__cdist_object_marker"); do
|
||||||
mkfs_device="$(cat "$mkfs_object/parameter/device")"
|
mkfs_device="$(cat "$mkfs_object/parameter/device")"
|
||||||
if [ "$_device" = "$mkfs_device" ]; then
|
if [ "$_device" = "$mkfs_device" ]; then
|
||||||
cat "$mkfs_object/parameter/type"
|
cat "$mkfs_object/parameter/type"
|
||||||
|
@ -42,18 +42,25 @@ else
|
||||||
# store for later use by others
|
# store for later use by others
|
||||||
echo "$type" > "$__object/parameter/type"
|
echo "$type" > "$__object/parameter/type"
|
||||||
fi
|
fi
|
||||||
[ -n "$type" ] || die "Can't determine type for $__object"
|
[ -n "$type" ] || {
|
||||||
|
echo "Can't determine type for $__object" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
if [ "$type" = "swap" ]; then
|
if [ "$type" = "swap" ]; then
|
||||||
echo "swapon \"$device\""
|
printf 'swapon "%s"\n' "$device"
|
||||||
else
|
else
|
||||||
if [ -f "$__object/parameter/options" ]; then
|
|
||||||
options="$(cat "$__object/parameter/options")"
|
|
||||||
else
|
|
||||||
options=""
|
|
||||||
fi
|
|
||||||
[ -n "$options" ] && options="-o $options"
|
|
||||||
mount_point="${prefix}${dir}"
|
mount_point="${prefix}${dir}"
|
||||||
|
printf '[ -d "%s" ] || mkdir -p "%s"\n' "$mount_point" "$mount_point"
|
||||||
echo "[ -d \"$mount_point\" ] || mkdir -p \"$mount_point\""
|
printf 'mount'
|
||||||
echo "mount -t \"$type\" $options \"$device\" \"$mount_point\""
|
if [ "$type" = "bind" ]; then
|
||||||
|
printf ' --bind'
|
||||||
|
device="${prefix}${device}"
|
||||||
|
else
|
||||||
|
printf ' -t "%s"' "$type"
|
||||||
|
fi
|
||||||
|
if [ -f "$__object/parameter/options" ]; then
|
||||||
|
printf ' -o %s' "$(cat "$__object/parameter/options")"
|
||||||
|
fi
|
||||||
|
printf ' "%s"' "$device"
|
||||||
|
printf ' "%s"\n' "$mount_point"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -19,6 +19,12 @@ type
|
||||||
|
|
||||||
OPTIONAL PARAMETERS
|
OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
|
device
|
||||||
|
the device we're working on. Defaults to the string prefix of --partition
|
||||||
|
|
||||||
|
minor
|
||||||
|
the partition number we're working on. Defaults to the numeric suffix of --partition
|
||||||
|
|
||||||
partition
|
partition
|
||||||
defaults to object_id
|
defaults to object_id
|
||||||
|
|
||||||
|
@ -49,6 +55,8 @@ EXAMPLES
|
||||||
__install_partition_msdos /dev/sda6 --type 83 --size 50%
|
__install_partition_msdos /dev/sda6 --type 83 --size 50%
|
||||||
# rest of the extended partition, linux
|
# rest of the extended partition, linux
|
||||||
__install_partition_msdos /dev/sda7 --type 83 --size +
|
__install_partition_msdos /dev/sda7 --type 83 --size +
|
||||||
|
# nvm device partition 2
|
||||||
|
__install_partition_msdos /dev/nvme0n1p2 --device /dev/nvme0n1 --minor 2 --type 83 --size 128M --bootable true
|
||||||
|
|
||||||
|
|
||||||
AUTHORS
|
AUTHORS
|
||||||
|
@ -58,7 +66,7 @@ Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||||
|
|
||||||
COPYING
|
COPYING
|
||||||
-------
|
-------
|
||||||
Copyright \(C) 2011 Steven Armstrong. You can redistribute it
|
Copyright \(C) 2011-2017 Steven Armstrong. You can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
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
|
published by the Free Software Foundation, either version 3 of the
|
||||||
License, or (at your option) any later version.
|
License, or (at your option) any later version.
|
||||||
|
|
|
@ -25,10 +25,15 @@ else
|
||||||
partition="/$__object_id"
|
partition="/$__object_id"
|
||||||
echo "$partition" > "$__object/parameter/partition"
|
echo "$partition" > "$__object/parameter/partition"
|
||||||
fi
|
fi
|
||||||
device="$(echo "$partition" | sed 's/[0-9]//g')"
|
|
||||||
echo "$device" > "$__object/parameter/device"
|
if [ ! -f "$__object/parameter/device" ]; then
|
||||||
minor="$(echo "$partition" | sed 's/[^0-9]//g')"
|
device="$(echo "$partition" | sed 's/[0-9]//g')"
|
||||||
echo "$minor" > "$__object/parameter/minor"
|
echo "$device" > "$__object/parameter/device"
|
||||||
|
fi
|
||||||
|
if [ ! -f "$__object/parameter/minor" ]; then
|
||||||
|
minor="$(echo "$partition" | sed 's/[^0-9]//g')"
|
||||||
|
echo "$minor" > "$__object/parameter/minor"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -f "$__object/parameter/bootable" ]; then
|
if [ ! -f "$__object/parameter/bootable" ]; then
|
||||||
echo "false" > "$__object/parameter/bootable"
|
echo "false" > "$__object/parameter/bootable"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
device
|
||||||
|
minor
|
||||||
partition
|
partition
|
||||||
bootable
|
bootable
|
||||||
size
|
size
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
#set -x
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
echo "[__install_partition_msdos_apply] $@" >&2
|
echo "[__install_partition_msdos_apply] $@" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -57,7 +59,7 @@ size_to_mb() {
|
||||||
|
|
||||||
get_objects() {
|
get_objects() {
|
||||||
objects_file=$(mktemp)
|
objects_file=$(mktemp)
|
||||||
for object in $(find "$__global/object/__install_partition_msdos" -path "*.cdist"); do
|
for object in $(find "$__global/object/__install_partition_msdos" -type d -name "$__cdist_object_marker"); do
|
||||||
object_device="$(cat "$object/parameter/device")"
|
object_device="$(cat "$object/parameter/device")"
|
||||||
object_minor="$(cat "$object/parameter/minor")"
|
object_minor="$(cat "$object/parameter/minor")"
|
||||||
echo "$object_device $object_minor $object" >> $objects_file
|
echo "$object_device $object_minor $object" >> $objects_file
|
||||||
|
|
Loading…
Reference in a new issue