forked from ungleich-public/cdist
add install types
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
parent
54815e2b29
commit
02476073aa
79 changed files with 1767 additions and 0 deletions
73
cdist/conf/type/__install_bootloader_grub/gencode-remote
Executable file
73
cdist/conf/type/__install_bootloader_grub/gencode-remote
Executable file
|
@ -0,0 +1,73 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
device="$(cat "$__object/parameter/device")"
|
||||
chroot="$(cat "$__object/parameter/chroot")"
|
||||
|
||||
|
||||
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
|
||||
[ -d "${chroot}/tmp" ] || mkdir -m 1777 "${chroot}/tmp"
|
||||
# Generate script to run in chroot
|
||||
script=\$(mktemp "${chroot}/tmp/__install_bootloader_grub.XXXXXXXXXX")
|
||||
# Link file descriptor #6 with stdout
|
||||
exec 6>&1
|
||||
# Link stdout with \$script
|
||||
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
|
||||
chmod +x "\$script"
|
||||
|
||||
# Run script in chroot
|
||||
relative_script="\${script#$chroot}"
|
||||
chroot "$chroot" "\$relative_script"
|
||||
DONE
|
0
cdist/conf/type/__install_bootloader_grub/install
Normal file
0
cdist/conf/type/__install_bootloader_grub/install
Normal file
47
cdist/conf/type/__install_bootloader_grub/man.text
Normal file
47
cdist/conf/type/__install_bootloader_grub/man.text
Normal file
|
@ -0,0 +1,47 @@
|
|||
cdist-type__install_bootloader_grub(7)
|
||||
======================================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__install_bootloader_grub - install grub2 bootloader on given disk
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This cdist type allows you to install grub2 bootloader on given disk.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
device::
|
||||
The device to install grub to. Defaults to object_id
|
||||
|
||||
chroot::
|
||||
where to chroot before running grub-install. Defaults to /target.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__install_bootloader_grub /dev/sda
|
||||
__install_bootloader_grub /dev/sda --chroot /mnt/foobar
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
25
cdist/conf/type/__install_bootloader_grub/manifest
Executable file
25
cdist/conf/type/__install_bootloader_grub/manifest
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
# set defaults
|
||||
device="$(cat "$__object/parameter/device" 2>/dev/null \
|
||||
|| echo "/$__object_id" | tee "$__object/parameter/device")"
|
||||
chroot="$(cat "$__object/parameter/chroot" 2>/dev/null \
|
||||
|| echo "/target" | tee "$__object/parameter/chroot")"
|
|
@ -0,0 +1,2 @@
|
|||
device
|
||||
chroot
|
1
cdist/conf/type/__install_chroot_mount/gencode-remote
Symbolic link
1
cdist/conf/type/__install_chroot_mount/gencode-remote
Symbolic link
|
@ -0,0 +1 @@
|
|||
../__chroot_mount/gencode-remote
|
0
cdist/conf/type/__install_chroot_mount/install
Normal file
0
cdist/conf/type/__install_chroot_mount/install
Normal file
1
cdist/conf/type/__install_chroot_mount/man.text
Symbolic link
1
cdist/conf/type/__install_chroot_mount/man.text
Symbolic link
|
@ -0,0 +1 @@
|
|||
../__chroot_mount/man.text
|
1
cdist/conf/type/__install_chroot_umount/gencode-remote
Symbolic link
1
cdist/conf/type/__install_chroot_umount/gencode-remote
Symbolic link
|
@ -0,0 +1 @@
|
|||
../__chroot_umount/gencode-remote
|
0
cdist/conf/type/__install_chroot_umount/install
Normal file
0
cdist/conf/type/__install_chroot_umount/install
Normal file
1
cdist/conf/type/__install_chroot_umount/man.text
Symbolic link
1
cdist/conf/type/__install_chroot_umount/man.text
Symbolic link
|
@ -0,0 +1 @@
|
|||
../__chroot_umount/man.text
|
48
cdist/conf/type/__install_config/files/remote/copy
Executable file
48
cdist/conf/type/__install_config/files/remote/copy
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
#
|
||||
# __remote_copy script to run cdist against a chroot on a remote host via ssh.
|
||||
#
|
||||
# Usage:
|
||||
# __remote_copy="/path/to/this/script /path/to/your/chroot" cdist config target-id
|
||||
#
|
||||
|
||||
log() {
|
||||
echo "$@" | logger -t "__install_config copy"
|
||||
:
|
||||
}
|
||||
|
||||
chroot="$1"; shift
|
||||
target_host="$__target_host"
|
||||
|
||||
scp="scp -o User=root -q"
|
||||
|
||||
# postfix target_host with chroot location
|
||||
code="$(echo "$@" | sed "s|$target_host:|$target_host:$chroot|g")"
|
||||
|
||||
log "target_host: $target_host"
|
||||
log "chroot: $chroot"
|
||||
log "@: $@"
|
||||
log "code: $code"
|
||||
|
||||
# copy files into chroot
|
||||
$scp $code
|
||||
|
||||
log "-----"
|
73
cdist/conf/type/__install_config/files/remote/exec
Executable file
73
cdist/conf/type/__install_config/files/remote/exec
Executable file
|
@ -0,0 +1,73 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
#
|
||||
# __remote_exec script to run cdist against a chroot on a remote host via ssh.
|
||||
#
|
||||
# Usage:
|
||||
# __remote_exec="/path/to/this/script /path/to/your/chroot" cdist config target-id
|
||||
#
|
||||
|
||||
log() {
|
||||
echo "$@" | logger -t "__install_config exec"
|
||||
:
|
||||
}
|
||||
|
||||
chroot="$1"; shift
|
||||
target_host="$__target_host"
|
||||
# In exec mode the first argument is the __target_host which we already got from env. Get rid of it.
|
||||
shift
|
||||
|
||||
ssh="ssh -o User=root -q $target_host"
|
||||
scp="scp -o User=root -q"
|
||||
|
||||
local_script=$(mktemp "/tmp/chroot-${0##*/}.XXXXXXXXXX")
|
||||
remote_script=$($ssh mktemp "${chroot}/tmp/chroot-${0##*/}.XXXXXXXXXX")
|
||||
relative_script="${remote_script#$chroot}"
|
||||
trap cleanup INT TERM EXIT
|
||||
cleanup() {
|
||||
[ $__cdist_debug ] || {
|
||||
rm "$local_script"
|
||||
$ssh "rm $remote_script";
|
||||
}
|
||||
}
|
||||
|
||||
log "chroot: $chroot"
|
||||
log "target_host: $target_host"
|
||||
log "local_script: $local_script"
|
||||
log "remote_script: $remote_script"
|
||||
log "relative_script: $relative_script"
|
||||
log "@: $@"
|
||||
cat > "$local_script" << DONE
|
||||
#!/bin/sh -l
|
||||
# FIXME: fix the dependency bug, then test if the below is required or not
|
||||
#if [ -f /etc/environment ]; then
|
||||
# . /etc/environment
|
||||
#fi
|
||||
$@
|
||||
DONE
|
||||
|
||||
# Upload script to target
|
||||
$scp $local_script $target_host:$remote_script
|
||||
$ssh "chmod +x $remote_script"
|
||||
|
||||
# run in chroot
|
||||
$ssh "chroot $chroot $relative_script"
|
||||
|
||||
log "-----"
|
50
cdist/conf/type/__install_config/gencode-local
Executable file
50
cdist/conf/type/__install_config/gencode-local
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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="$(cat "$__object/parameter/chroot")"
|
||||
remote_exec="$__type/files/remote/exec"
|
||||
remote_copy="$__type/files/remote/copy"
|
||||
|
||||
cdist_args="-v"
|
||||
[ "$__debug" = "yes" ] && cdist_args="$cdist_args -d"
|
||||
|
||||
cat << DONE
|
||||
echo "__apt_noautostart --state present" \
|
||||
| cdist $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-copy="$remote_copy $chroot" \
|
||||
$__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
|
0
cdist/conf/type/__install_config/install
Normal file
0
cdist/conf/type/__install_config/install
Normal file
47
cdist/conf/type/__install_config/man.text
Normal file
47
cdist/conf/type/__install_config/man.text
Normal file
|
@ -0,0 +1,47 @@
|
|||
cdist-type__install_config(7)
|
||||
=============================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__install_config - run cdist config as part of the installation
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This cdist type allows you to run cdist config as part of the installation.
|
||||
It does this by using a custom __remote_{copy,exec} prefix which runs
|
||||
cdist config against the /target chroot on the remote host.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
chroot::
|
||||
where to chroot before running grub-install. Defaults to /target.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__install_config
|
||||
|
||||
__install_config --chroot /mnt/somewhere
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
23
cdist/conf/type/__install_config/manifest
Executable file
23
cdist/conf/type/__install_config/manifest
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
# set defaults
|
||||
chroot="$(cat "$__object/parameter/chroot" 2>/dev/null \
|
||||
|| echo "/target" | tee "$__object/parameter/chroot")"
|
1
cdist/conf/type/__install_config/parameter/optional
Normal file
1
cdist/conf/type/__install_config/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
|||
chroot
|
0
cdist/conf/type/__install_config/singleton
Normal file
0
cdist/conf/type/__install_config/singleton
Normal file
1
cdist/conf/type/__install_file/explorer
Symbolic link
1
cdist/conf/type/__install_file/explorer
Symbolic link
|
@ -0,0 +1 @@
|
|||
../__file/explorer
|
1
cdist/conf/type/__install_file/gencode-local
Symbolic link
1
cdist/conf/type/__install_file/gencode-local
Symbolic link
|
@ -0,0 +1 @@
|
|||
../__file/gencode-local
|
1
cdist/conf/type/__install_file/gencode-remote
Symbolic link
1
cdist/conf/type/__install_file/gencode-remote
Symbolic link
|
@ -0,0 +1 @@
|
|||
../__file/gencode-remote
|
0
cdist/conf/type/__install_file/install
Normal file
0
cdist/conf/type/__install_file/install
Normal file
1
cdist/conf/type/__install_file/man.text
Symbolic link
1
cdist/conf/type/__install_file/man.text
Symbolic link
|
@ -0,0 +1 @@
|
|||
../__file/man.text
|
1
cdist/conf/type/__install_file/parameter
Symbolic link
1
cdist/conf/type/__install_file/parameter
Symbolic link
|
@ -0,0 +1 @@
|
|||
../__file/parameter
|
0
cdist/conf/type/__install_fstab/install
Normal file
0
cdist/conf/type/__install_fstab/install
Normal file
48
cdist/conf/type/__install_fstab/man.text
Normal file
48
cdist/conf/type/__install_fstab/man.text
Normal file
|
@ -0,0 +1,48 @@
|
|||
cdist-type__install_fstab(7)
|
||||
============================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__install_fstab - generate /etc/fstab during installation
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Uses __install_generate_fstab to generate a /etc/fstab file and uploads it
|
||||
to the target machine at ${prefix}/etc/fstab.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
prefix::
|
||||
The prefix under which to generate the /etc/fstab file.
|
||||
Defaults to /target.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__install_fstab
|
||||
__install_fstab --prefix /mnt/target
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
- cdist-type__install_mount(7)
|
||||
- cdist-type__install_generate_fstab(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
29
cdist/conf/type/__install_fstab/manifest
Executable file
29
cdist/conf/type/__install_fstab/manifest
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
prefix="$(cat "$__object/parameter/prefix" 2>/dev/null || echo "/target")"
|
||||
|
||||
[ -d "$__object/files" ] || mkdir "$__object/files"
|
||||
__install_generate_fstab --uuid --destination "$__object/files/fstab"
|
||||
require="__install_generate_fstab" \
|
||||
__install_file "${prefix}/etc/fstab" --source "$__object/files/fstab" \
|
||||
--mode 644 \
|
||||
--owner root \
|
||||
--group root
|
1
cdist/conf/type/__install_fstab/parameter/optional
Normal file
1
cdist/conf/type/__install_fstab/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
|||
file
|
0
cdist/conf/type/__install_fstab/singleton
Normal file
0
cdist/conf/type/__install_fstab/singleton
Normal file
|
@ -0,0 +1 @@
|
|||
# Generated by cdist __install_generate_fstab
|
59
cdist/conf/type/__install_generate_fstab/gencode-local
Executable file
59
cdist/conf/type/__install_generate_fstab/gencode-local
Executable file
|
@ -0,0 +1,59 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
destination="$(cat "$__object/parameter/destination")"
|
||||
cat "$__type/files/fstab.header" > "$destination"
|
||||
|
||||
mkdir "$__object/files"
|
||||
# get current UUID's from target_host
|
||||
$__remote_exec $__target_host blkid > "$__object/files/blkid"
|
||||
|
||||
for object in $(find "$__global/object/__install_mount" -path "*.cdist"); do
|
||||
device="$(cat "$object/parameter/device")"
|
||||
dir="$(cat "$object/parameter/dir")"
|
||||
prefix="$(cat "$object/parameter/prefix")"
|
||||
type="$(cat "$object/parameter/type")"
|
||||
if [ -f "$object/parameter/options" ]; then
|
||||
options="$(cat "$object/parameter/options")"
|
||||
else
|
||||
options="defaults"
|
||||
fi
|
||||
dump=0
|
||||
case "$type" in
|
||||
swap)
|
||||
pass=0
|
||||
dir="$type"
|
||||
;;
|
||||
tmpfs)
|
||||
pass=0
|
||||
;;
|
||||
*)
|
||||
pass=1
|
||||
;;
|
||||
esac
|
||||
if [ -f "$__object/parameter/uuid" ]; then
|
||||
uuid="$(grep -w $device "$__object/files/blkid" | awk '{print $2}')"
|
||||
if [ -n "$uuid" ]; then
|
||||
echo "# $dir was on $device during installation" >> "$destination"
|
||||
device="$uuid"
|
||||
fi
|
||||
fi
|
||||
echo "$device $dir $type $options $dump $pass" >> "$destination"
|
||||
done
|
0
cdist/conf/type/__install_generate_fstab/install
Normal file
0
cdist/conf/type/__install_generate_fstab/install
Normal file
52
cdist/conf/type/__install_generate_fstab/man.text
Normal file
52
cdist/conf/type/__install_generate_fstab/man.text
Normal file
|
@ -0,0 +1,52 @@
|
|||
cdist-type__install_generate_fstab(7)
|
||||
=====================================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__install_generate_fstab - generate /etc/fstab during installation
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Generates a /etc/fstab file from information retreived from
|
||||
__install_mount definitions.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
destination::
|
||||
The path where to store the generated fstab file.
|
||||
Note that this is a path on the server, where cdist is running, not the target host.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
BOOLEAN PARAMETERS
|
||||
-------------------
|
||||
uuid::
|
||||
use UUID instead of device in fstab
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__install_generate_fstab --destination /path/where/you/want/fstab
|
||||
__install_generate_fstab --uuid --destination /path/where/you/want/fstab
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2012 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
|
@ -0,0 +1 @@
|
|||
uuid
|
|
@ -0,0 +1 @@
|
|||
destination
|
0
cdist/conf/type/__install_generate_fstab/singleton
Normal file
0
cdist/conf/type/__install_generate_fstab/singleton
Normal file
71
cdist/conf/type/__install_mkfs/gencode-remote
Executable file
71
cdist/conf/type/__install_mkfs/gencode-remote
Executable file
|
@ -0,0 +1,71 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
device="$(cat "$__object/parameter/device")"
|
||||
type="$(cat "$__object/parameter/type")"
|
||||
|
||||
# show command output in debug mode
|
||||
cat << DONE
|
||||
__debug=$__cdist_debug
|
||||
if [ "\$__debug" != "yes" ]; then
|
||||
# Link file descriptor #6 with stdout
|
||||
exec 6>&1
|
||||
# redirect all output to /dev/null
|
||||
exec > /dev/null
|
||||
fi
|
||||
DONE
|
||||
|
||||
case "$type" in
|
||||
swap)
|
||||
echo "mkswap $device"
|
||||
;;
|
||||
xfs)
|
||||
command="mkfs.xfs -f -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"
|
||||
;;
|
||||
*)
|
||||
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
|
||||
|
||||
cat << DONE
|
||||
if [ "\$__debug" != "yes" ]; then
|
||||
# Restore stdout and close file descriptor #6.
|
||||
exec 1>&6 6>&-
|
||||
fi
|
||||
DONE
|
0
cdist/conf/type/__install_mkfs/install
Normal file
0
cdist/conf/type/__install_mkfs/install
Normal file
57
cdist/conf/type/__install_mkfs/man.text
Normal file
57
cdist/conf/type/__install_mkfs/man.text
Normal file
|
@ -0,0 +1,57 @@
|
|||
cdist-type__install_mkfs(7)
|
||||
===========================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__install_mkfs - build a linux file system
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This cdist type is a wrapper for the mkfs command.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
type::
|
||||
The filesystem type to use. Same as used with mkfs -t.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
device::
|
||||
defaults to object_id
|
||||
|
||||
options::
|
||||
file system-specific options to be passed to the mkfs command
|
||||
|
||||
blocks::
|
||||
the number of blocks to be used for the file system
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
# reiserfs /dev/sda5
|
||||
__install_mkfs /dev/sda5 --type reiserfs
|
||||
# same thing with explicit device
|
||||
__install_mkfs whatever --device /dev/sda5 --type reiserfs
|
||||
|
||||
# jfs with journal on /dev/sda2
|
||||
__install_mkfs /dev/sda1 --type jfs --options "-j /dev/sda2"
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
- mkfs(8)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
31
cdist/conf/type/__install_mkfs/manifest
Executable file
31
cdist/conf/type/__install_mkfs/manifest
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
# set defaults
|
||||
if [ -f "$__object/parameter/device" ]; then
|
||||
device="(cat "$__object/parameter/device")"
|
||||
else
|
||||
device="/$__object_id"
|
||||
echo "$device" > "$__object/parameter/device"
|
||||
fi
|
||||
|
||||
type="(cat "$__object/parameter/type")"
|
||||
|
||||
options="(cat "$__object/parameter/options")"
|
3
cdist/conf/type/__install_mkfs/parameter/optional
Normal file
3
cdist/conf/type/__install_mkfs/parameter/optional
Normal file
|
@ -0,0 +1,3 @@
|
|||
device
|
||||
options
|
||||
blocks
|
1
cdist/conf/type/__install_mkfs/parameter/required
Normal file
1
cdist/conf/type/__install_mkfs/parameter/required
Normal file
|
@ -0,0 +1 @@
|
|||
type
|
78
cdist/conf/type/__install_mount/gencode-remote
Executable file
78
cdist/conf/type/__install_mount/gencode-remote
Executable file
|
@ -0,0 +1,78 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
# show command output in debug mode
|
||||
cat << DONE
|
||||
__debug=$__cdist_debug
|
||||
if [ "\$__debug" != "yes" ]; then
|
||||
# Link file descriptor #6 with stdout
|
||||
exec 6>&1
|
||||
# redirect all output to /dev/null
|
||||
exec > /dev/null
|
||||
fi
|
||||
DONE
|
||||
|
||||
|
||||
get_type_from_mkfs() {
|
||||
_device="$1"
|
||||
for mkfs_object in $(find "$__global/object/__install_mkfs" -path "*.cdist"); do
|
||||
mkfs_device="$(cat "$mkfs_object/parameter/device")"
|
||||
if [ "$_device" = "$mkfs_device" ]; then
|
||||
cat "$mkfs_object/parameter/type"
|
||||
break
|
||||
fi
|
||||
done
|
||||
unset _device
|
||||
unset mkfs_device
|
||||
unset mkfs_object
|
||||
}
|
||||
|
||||
device="$(cat "$__object/parameter/device")"
|
||||
dir="$(cat "$__object/parameter/dir")"
|
||||
prefix="$(cat "$__object/parameter/prefix")"
|
||||
if [ -f "$__object/parameter/type" ]; then
|
||||
type="$(cat "$__object/parameter/type")"
|
||||
else
|
||||
type="$(get_type_from_mkfs "$device")"
|
||||
# store for later use by others
|
||||
echo "$type" > "$__object/parameter/type"
|
||||
fi
|
||||
[ -n "$type" ] || die "Can't determine type for $__object"
|
||||
if [ "$type" = "swap" ]; then
|
||||
echo "swapon \"$device\""
|
||||
else
|
||||
if [ -f "$__object/parameter/options" ]; then
|
||||
options="$(cat "$__object/parameter/options")"
|
||||
else
|
||||
options=""
|
||||
fi
|
||||
[ -n "$options" ] && options="-o $options"
|
||||
mount_point="${prefix}${dir}"
|
||||
|
||||
echo "[ -d \"$mount_point\" ] || mkdir -p \"$mount_point\""
|
||||
echo "mount -t \"$type\" $options \"$device\" \"$mount_point\""
|
||||
fi
|
||||
|
||||
cat << DONE
|
||||
if [ "\$__debug" != "yes" ]; then
|
||||
# Restore stdout and close file descriptor #6.
|
||||
exec 1>&6 6>&-
|
||||
fi
|
||||
DONE
|
0
cdist/conf/type/__install_mount/install
Normal file
0
cdist/conf/type/__install_mount/install
Normal file
61
cdist/conf/type/__install_mount/man.text
Normal file
61
cdist/conf/type/__install_mount/man.text
Normal file
|
@ -0,0 +1,61 @@
|
|||
cdist-type__install_mount(7)
|
||||
============================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__install_mount - mount filesystems in the installer
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Mounts filesystems in the installer. Collects data to generate /etc/fstab.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
device::
|
||||
the device to mount
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
dir::
|
||||
where to mount device. Defaults to object_id.
|
||||
|
||||
options::
|
||||
mount options passed to mount(8) and used in /etc/fstab
|
||||
|
||||
type::
|
||||
filesystem type passed to mount(8) and used in /etc/fstab.
|
||||
If type is swap, 'dir' is ignored.
|
||||
Defaults to the filesystem used in __install_mkfs for the same 'device'.
|
||||
|
||||
prefix::
|
||||
the prefix to prepend to 'dir' when mounting in the installer.
|
||||
Defaults to /target.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__install_mount slash --dir / --device /dev/sda5 --options noatime
|
||||
require="__install_mount/slash" __install_mount /boot --device /dev/sda1
|
||||
__install_mount swap --device /dev/sda2 --type swap
|
||||
require="__install_mount/slash" __install_mount /tmp --device tmpfs --type tmpfs
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
- cdist-type__install_mount_apply(7)
|
||||
- cdist-type__install_mkfs(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
29
cdist/conf/type/__install_mount/manifest
Executable file
29
cdist/conf/type/__install_mount/manifest
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
# set defaults
|
||||
if [ ! -f "$__object/parameter/dir" ]; then
|
||||
dir="/$__object_id"
|
||||
echo "$dir" > "$__object/parameter/dir"
|
||||
fi
|
||||
if [ ! -f "$__object/parameter/prefix" ]; then
|
||||
prefix="/target"
|
||||
echo "$prefix" > "$__object/parameter/prefix"
|
||||
fi
|
3
cdist/conf/type/__install_mount/parameter/optional
Normal file
3
cdist/conf/type/__install_mount/parameter/optional
Normal file
|
@ -0,0 +1,3 @@
|
|||
dir
|
||||
type
|
||||
options
|
1
cdist/conf/type/__install_mount/parameter/required
Normal file
1
cdist/conf/type/__install_mount/parameter/required
Normal file
|
@ -0,0 +1 @@
|
|||
device
|
0
cdist/conf/type/__install_partition_msdos/install
Normal file
0
cdist/conf/type/__install_partition_msdos/install
Normal file
62
cdist/conf/type/__install_partition_msdos/man.text
Normal file
62
cdist/conf/type/__install_partition_msdos/man.text
Normal file
|
@ -0,0 +1,62 @@
|
|||
cdist-type__install_partition_msdos(7)
|
||||
==============================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__install_partition_msdos - creates msdos partitions
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This cdist type allows you to create msdos paritions.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
type::
|
||||
the partition type used in fdisk (such as 82 or 83) or "extended"
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
partition::
|
||||
defaults to object_id
|
||||
bootable::
|
||||
mark partition as bootable, true or false, defaults to false
|
||||
size::
|
||||
the size of the partition (such as 32M or 15G, whole numbers
|
||||
only), '+' for remaining space, or 'n%' for percentage of remaining
|
||||
(these should only be used after all specific partition sizes are
|
||||
specified). Defaults to +.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
# 128MB, linux, bootable
|
||||
__install_partition_msdos /dev/sda1 --type 83 --size 128M --bootable true
|
||||
# 512MB, swap
|
||||
__install_partition_msdos /dev/sda2 --type 82 --size 512M
|
||||
# 100GB, extended
|
||||
__install_partition_msdos /dev/sda3 --type extended --size 100G
|
||||
# 10GB, linux
|
||||
__install_partition_msdos /dev/sda5 --type 83 --size 10G
|
||||
# 50% of the free space of the extended partition, linux
|
||||
__install_partition_msdos /dev/sda6 --type 83 --size 50%
|
||||
# rest of the extended partition, linux
|
||||
__install_partition_msdos /dev/sda7 --type 83 --size +
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
41
cdist/conf/type/__install_partition_msdos/manifest
Executable file
41
cdist/conf/type/__install_partition_msdos/manifest
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
# set defaults
|
||||
if [ -f "$__object/parameter/partition" ]; then
|
||||
partition="(cat "$__object/parameter/partition")"
|
||||
else
|
||||
partition="/$__object_id"
|
||||
echo "$partition" > "$__object/parameter/partition"
|
||||
fi
|
||||
device="$(echo "$partition" | sed 's/[0-9]//g')"
|
||||
echo "$device" > "$__object/parameter/device"
|
||||
minor="$(echo "$partition" | sed 's/[^0-9]//g')"
|
||||
echo "$minor" > "$__object/parameter/minor"
|
||||
|
||||
if [ ! -f "$__object/parameter/bootable" ]; then
|
||||
echo "false" > "$__object/parameter/bootable"
|
||||
fi
|
||||
if [ ! -f "$__object/parameter/size" ]; then
|
||||
echo "+" > "$__object/parameter/size"
|
||||
fi
|
||||
|
||||
# pull in the type that actually does something with the above parameters
|
||||
require="$__object_name" __install_partition_msdos_apply
|
|
@ -0,0 +1,3 @@
|
|||
partition
|
||||
bootable
|
||||
size
|
|
@ -0,0 +1 @@
|
|||
type
|
3
cdist/conf/type/__install_partition_msdos_apply/explorer/partitions
Executable file
3
cdist/conf/type/__install_partition_msdos_apply/explorer/partitions
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
cat /proc/partitions
|
68
cdist/conf/type/__install_partition_msdos_apply/files/lib.sh
Normal file
68
cdist/conf/type/__install_partition_msdos_apply/files/lib.sh
Normal file
|
@ -0,0 +1,68 @@
|
|||
die() {
|
||||
echo "[__install_partition_msdos_apply] $@" >&2
|
||||
exit 1
|
||||
}
|
||||
debug() {
|
||||
#echo "[__install_partition_msdos_apply] $@" >&2
|
||||
:
|
||||
}
|
||||
|
||||
fdisk_command() {
|
||||
local device="$1"
|
||||
local cmd="$2"
|
||||
|
||||
debug fdisk_command "running fdisk command '${cmd}' on device ${device}"
|
||||
printf "${cmd}\nw\n" | fdisk -c -u "$device"
|
||||
ret=$?
|
||||
# give disk some time
|
||||
sleep 1
|
||||
return $ret
|
||||
}
|
||||
|
||||
create_disklabel() {
|
||||
local device=$1
|
||||
|
||||
debug create_disklabel "creating new msdos disklabel"
|
||||
fdisk_command ${device} "o"
|
||||
return $?
|
||||
}
|
||||
|
||||
toggle_bootable() {
|
||||
local device="$1"
|
||||
local minor="$2"
|
||||
fdisk_command ${device} "a\n${minor}\n"
|
||||
return $?
|
||||
}
|
||||
|
||||
create_partition() {
|
||||
local device="$1"
|
||||
local minor="$2"
|
||||
local size="$3"
|
||||
local type="$4"
|
||||
local primary_count="$5"
|
||||
|
||||
if [ "$type" = "extended" -o "$type" = "5" ]; then
|
||||
# Extended partition
|
||||
primary_extended="e\n"
|
||||
first_minor="${minor}\n"
|
||||
[ "${minor}" = "4" ] && first_minor=""
|
||||
type_minor="${minor}\n"
|
||||
[ "${minor}" = "1" ] && type_minor=""
|
||||
type="5"
|
||||
elif [ "${minor}" -lt "5" ]; then
|
||||
primary_extended="p\n"
|
||||
first_minor="${minor}\n"
|
||||
[ "${minor}" = "4" ] && first_minor=""
|
||||
type_minor="${minor}\n"
|
||||
[ "${minor}" = "1" ] && type_minor=""
|
||||
else
|
||||
# Logical partitions
|
||||
first_minor="${minor}\n"
|
||||
type_minor="${minor}\n"
|
||||
primary_extended="l\n"
|
||||
[ "$primary_count" -gt "3" ] && primary_extended=""
|
||||
fi
|
||||
[ -n "${size}" ] && size="+${size}M"
|
||||
fdisk_command ${device} "n\n${primary_extended}${first_minor}\n${size}\nt\n${type_minor}${type}\n"
|
||||
return $?
|
||||
}
|
175
cdist/conf/type/__install_partition_msdos_apply/gencode-remote
Executable file
175
cdist/conf/type/__install_partition_msdos_apply/gencode-remote
Executable file
|
@ -0,0 +1,175 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
die() {
|
||||
echo "[__install_partition_msdos_apply] $@" >&2
|
||||
exit 1
|
||||
}
|
||||
debug() {
|
||||
#echo "[__install_partition_msdos_apply] $@" >&2
|
||||
:
|
||||
}
|
||||
|
||||
# Convert a size specifier 1G 100M or 50% into the corresponding numeric MB.
|
||||
size_to_mb() {
|
||||
local size=$1
|
||||
local available_size="$2"
|
||||
|
||||
local number_suffix="$(echo ${size} | sed -e 's:\.[0-9]\+::' -e 's:\([0-9]\+\)\([KkMmGg%]\)[Bb]\?:\1|\2:')"
|
||||
local number="$(echo ${number_suffix} | cut -d '|' -f1)"
|
||||
local suffix="$(echo ${number_suffix} | cut -d '|' -f2)"
|
||||
|
||||
case "$suffix" in
|
||||
K|k)
|
||||
size="$(( $number / 1024 ))"
|
||||
;;
|
||||
M|m)
|
||||
size="$number"
|
||||
;;
|
||||
G|g)
|
||||
size="$(( $number * 1024 ))"
|
||||
;;
|
||||
%)
|
||||
size="$(( $available_size * $number / 100 ))"
|
||||
;;
|
||||
*)
|
||||
size="-1"
|
||||
esac
|
||||
echo "$size"
|
||||
}
|
||||
|
||||
get_objects() {
|
||||
objects_file=$(mktemp)
|
||||
for object in $(find "$__global/object/__install_partition_msdos" -path "*.cdist"); do
|
||||
object_device="$(cat "$object/parameter/device")"
|
||||
object_minor="$(cat "$object/parameter/minor")"
|
||||
echo "$object_device $object_minor $object" >> $objects_file
|
||||
done
|
||||
sort -k 1,2 $objects_file | cut -d' ' -f 3
|
||||
rm $objects_file
|
||||
unset objects_file
|
||||
unset object
|
||||
unset object_device
|
||||
unset object_minor
|
||||
}
|
||||
|
||||
# include function library for use on target
|
||||
cat << DONE
|
||||
__debug=$__cdist_debug
|
||||
if [ "\$__debug" != "yes" ]; then
|
||||
# Link file descriptor #6 with stdout
|
||||
exec 6>&1
|
||||
# redirect all output to /dev/null
|
||||
exec > /dev/null
|
||||
fi
|
||||
DONE
|
||||
cat "$__type/files/lib.sh"
|
||||
|
||||
partitions="$__object/explorer/partitions"
|
||||
objects=$(get_objects)
|
||||
current_device=""
|
||||
available_device_size=
|
||||
available_extended_size=
|
||||
available_size=
|
||||
primary_count=0
|
||||
for object in $objects; do
|
||||
device="$(cat "$object/parameter/device")"
|
||||
if [ "$current_device" != "$device" ]; then
|
||||
echo "create_disklabel \"$device\" || die 'Failed to create disklabel for $device'"
|
||||
current_device="$device"
|
||||
device_name=$(echo ${device} | sed -e 's:^/dev/::;s:/:\\/:g')
|
||||
available_device_size=$(( $(awk "/${device_name}\$/ { print \$3; }" "$partitions") / 1024))
|
||||
# make sure we don't go past the end of the drive
|
||||
available_device_size=$((available_device_size - 2))
|
||||
available_extended_size=0
|
||||
primary_count=0
|
||||
debug "----- $device"
|
||||
debug "current_device=$current_device"
|
||||
debug "available_device_size=$available_device_size"
|
||||
fi
|
||||
|
||||
type="$(cat "$object/parameter/type")"
|
||||
partition="$(cat "$object/parameter/partition")"
|
||||
minor="$(cat "$object/parameter/minor")"
|
||||
|
||||
bootable="$(cat "$object/parameter/bootable")"
|
||||
size="$(cat "$object/parameter/size")"
|
||||
|
||||
|
||||
if [ "${minor}" -lt "5" ]; then
|
||||
# Primary partitions
|
||||
primary_count=$(( $primary_count + 1 ))
|
||||
available_size=$available_device_size
|
||||
else
|
||||
# Logical partitions
|
||||
available_size=$available_extended_size
|
||||
fi
|
||||
|
||||
if [ "$size" = "+" ]; then
|
||||
# use rest of device
|
||||
partition_size=""
|
||||
available_size=0
|
||||
else
|
||||
partition_size=$(size_to_mb "$size" "$available_size")
|
||||
available_size="$(( $available_size - $partition_size ))"
|
||||
fi
|
||||
|
||||
if [ "${minor}" -lt "5" ]; then
|
||||
# Primary partitions
|
||||
available_device_size=$available_size
|
||||
if [ "$type" = "extended" -o "$type" = "5" ]; then
|
||||
# Extended partition
|
||||
available_extended_size=$partition_size
|
||||
fi
|
||||
else
|
||||
# Logical paritions
|
||||
available_extended_size=$available_size
|
||||
fi
|
||||
|
||||
[ "$partition_size" = "-1" ] && die "could not translate size '$size' to a usable value"
|
||||
debug "----- $partition"
|
||||
debug "primary_count=$primary_count"
|
||||
debug "current_device=$current_device"
|
||||
debug "device=$device"
|
||||
debug "type=$type"
|
||||
debug "partition=$partition"
|
||||
debug "minor=$minor"
|
||||
debug "bootable=$bootable"
|
||||
debug "size=$size"
|
||||
debug "partition_size=$partition_size"
|
||||
debug "available_size=$available_size"
|
||||
debug "available_device_size=$available_device_size"
|
||||
debug "available_extended_size=$available_extended_size"
|
||||
debug "----------"
|
||||
|
||||
echo "create_partition '$device' '$minor' '$partition_size' '$type' '$primary_count' \
|
||||
|| die 'Failed to create partition: $partition'"
|
||||
|
||||
if [ "$bootable" = "true" ]; then
|
||||
echo "toggle_bootable '$device' '$minor' || die 'Failed to toogle bootable flag for partition: $partition'"
|
||||
fi
|
||||
done
|
||||
|
||||
cat << DONE
|
||||
if [ "\$__debug" != "yes" ]; then
|
||||
# Restore stdout and close file descriptor #6.
|
||||
exec 1>&6 6>&-
|
||||
fi
|
||||
DONE
|
0
cdist/conf/type/__install_partition_msdos_apply/install
Normal file
0
cdist/conf/type/__install_partition_msdos_apply/install
Normal file
42
cdist/conf/type/__install_partition_msdos_apply/man.text
Normal file
42
cdist/conf/type/__install_partition_msdos_apply/man.text
Normal file
|
@ -0,0 +1,42 @@
|
|||
cdist-type__install_partition_msdos_apply(7)
|
||||
============================================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__install_partition_msdos_apply - Apply dos partition settings
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Create the partitions defined with __install_partition_msdos
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__install_partition_msdos_apply
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
- cdist-type__install_partition_msdos_apply(7)
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
23
cdist/conf/type/__install_reboot/gencode-remote
Executable file
23
cdist/conf/type/__install_reboot/gencode-remote
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
options="$(cat "$__object/parameter/options")"
|
||||
|
||||
echo "reboot $options"
|
0
cdist/conf/type/__install_reboot/install
Normal file
0
cdist/conf/type/__install_reboot/install
Normal file
43
cdist/conf/type/__install_reboot/man.text
Normal file
43
cdist/conf/type/__install_reboot/man.text
Normal file
|
@ -0,0 +1,43 @@
|
|||
cdist-type__install_reboot(7)
|
||||
=============================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__install_reboot - run reboot
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This cdist type allows you to reboot a machine.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
options::
|
||||
options to pass to the reboot command. e.g. -f
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__install_reboot
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
23
cdist/conf/type/__install_reboot/manifest
Executable file
23
cdist/conf/type/__install_reboot/manifest
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
# set defaults
|
||||
options="$(cat "$__object/parameter/options" 2>/dev/null \
|
||||
|| echo "" | tee "$__object/parameter/options")"
|
0
cdist/conf/type/__install_reboot/singleton
Normal file
0
cdist/conf/type/__install_reboot/singleton
Normal file
65
cdist/conf/type/__install_reset_disk/gencode-remote
Executable file
65
cdist/conf/type/__install_reset_disk/gencode-remote
Executable file
|
@ -0,0 +1,65 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2012 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/>.
|
||||
#
|
||||
|
||||
disk="/$__object_id"
|
||||
disk_name="${disk##*/}"
|
||||
|
||||
cat << DONE
|
||||
# stop mdadm raids if any
|
||||
if [ -r /proc/mdstat ]; then
|
||||
md_name="\$(awk "/$disk_name/ {print \$1}" /proc/mdstat)"
|
||||
if [ -n "\$md_name" ]; then
|
||||
if command -v mdadm >/dev/null; then
|
||||
mdadm --stop "/dev/\$md_name"
|
||||
else
|
||||
echo "WARNING: mdadm command not found" >&2
|
||||
echo "WARNING: could not stop active mdadm raid for disk $disk" >&2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# stop lvm's if any
|
||||
if find /sys/class/block/$disk_name*/holders/ -mindepth 1 | grep -q holders/dm; then
|
||||
if command -v vgchange >/dev/null; then
|
||||
vgchange -a n
|
||||
else
|
||||
echo "WARNING: vgchange command not found" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
# clean disks from any legacy signatures
|
||||
if command -v wipefs >/dev/null; then
|
||||
wipefs -a "$disk" || true
|
||||
fi
|
||||
if command -v mdadm >/dev/null; then
|
||||
mdadm --zero-superblock --force "$disk" || true
|
||||
else
|
||||
echo "WARNING: mdadm command not found" >&2
|
||||
fi
|
||||
if command -v pvremove >/dev/null; then
|
||||
pvremove --force --force --yes "$disk" || true
|
||||
else
|
||||
echo "WARNING: pvremove command not found" >&2
|
||||
fi
|
||||
|
||||
# erase partition table
|
||||
dd if=/dev/zero of=$disk bs=512 count=1
|
||||
printf 'w\n' | fdisk -u -c $disk || true
|
||||
DONE
|
0
cdist/conf/type/__install_reset_disk/install
Normal file
0
cdist/conf/type/__install_reset_disk/install
Normal file
43
cdist/conf/type/__install_reset_disk/man.text
Normal file
43
cdist/conf/type/__install_reset_disk/man.text
Normal file
|
@ -0,0 +1,43 @@
|
|||
cdist-type__install_reset_disk(7)
|
||||
=================================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__install_reset_disk - reset a disk
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Remove partition table.
|
||||
Remove all lvm labels.
|
||||
Remove mdadm superblock.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__install_reset_disk /dev/sdb
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2012 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
65
cdist/conf/type/__install_stage/gencode-remote
Executable file
65
cdist/conf/type/__install_stage/gencode-remote
Executable file
|
@ -0,0 +1,65 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
# show command output in debug mode
|
||||
cat << DONE
|
||||
__debug=$__cdist_debug
|
||||
if [ "\$__debug" != "yes" ]; then
|
||||
# Link file descriptor #6 with stdout
|
||||
exec 6>&1
|
||||
# redirect all output to /dev/null
|
||||
exec > /dev/null
|
||||
fi
|
||||
DONE
|
||||
|
||||
uri="$(cat "$__object/parameter/uri")"
|
||||
target="$(cat "$__object/parameter/target")"
|
||||
post_install="$(cat "$__object/parameter/post_install" 2>/dev/null || true)"
|
||||
|
||||
|
||||
[ "$__debug" = "yes" ] && curl="curl" || curl="curl -s"
|
||||
[ "$__debug" = "yes" ] && tar="tar -xvzp" || tar="tar -xzp"
|
||||
|
||||
echo "$curl '$uri' | $tar -C '$target'"
|
||||
if [ -n "$post_install" ]; then
|
||||
post_install_script="$(cat "$__object/parameter/post_install_script")"
|
||||
cat << DONE
|
||||
[ -d "${target}/proc" ] || mkdir "${target}/proc"
|
||||
mount -t proc none "${target}/proc"
|
||||
[ -d "${target}/sys" ] || mkdir "${target}/sys"
|
||||
mount -t sysfs none "${target}/sys"
|
||||
[ -d "${target}/dev" ] || mkdir "${target}/dev"
|
||||
mount --rbind /dev "${target}/dev"
|
||||
[ -d "${target}/tmp" ] || mkdir -m 1777 "${target}/tmp"
|
||||
mount -t tmpfs none "${target}/tmp"
|
||||
cp "$post_install_script" "${target}/tmp/post_install"
|
||||
chmod +x "${target}/tmp/post_install"
|
||||
cp /etc/resolv.conf "${target}/etc/"
|
||||
chroot "$target" /tmp/post_install
|
||||
umount -l "${target}/tmp" "${target}/dev" "${target}/sys" "${target}/proc"
|
||||
DONE
|
||||
fi
|
||||
|
||||
cat << DONE
|
||||
if [ "\$__debug" != "yes" ]; then
|
||||
# Restore stdout and close file descriptor #6.
|
||||
exec 1>&6 6>&-
|
||||
fi
|
||||
DONE
|
0
cdist/conf/type/__install_stage/install
Normal file
0
cdist/conf/type/__install_stage/install
Normal file
58
cdist/conf/type/__install_stage/man.text
Normal file
58
cdist/conf/type/__install_stage/man.text
Normal file
|
@ -0,0 +1,58 @@
|
|||
cdist-type__install_stage(7)
|
||||
============================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__install_stage - download and unpack a stage file
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Downloads a operating system stage using curl and unpacks it to /target
|
||||
using tar. The stage tarball is expected to be gzip compressed.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
uri::
|
||||
The uri from which to fetch the tarball.
|
||||
Can be anything understood by curl, e.g:
|
||||
http://path/to/stage.tgz
|
||||
tftp:///path/to/stage.tgz
|
||||
file:///local/path/stage.tgz
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
target::
|
||||
where to unpack the tarball to. Defaults to /target.
|
||||
|
||||
post_install::
|
||||
path to an optional local script. The script is uploaded to the target and
|
||||
executed inside (chroot) the target after the stage has been unpacked.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__install_stage --uri tftp:///path/to/stage.tgz
|
||||
__install_stage --uri http://path/to/stage.tgz --target /mnt/foobar
|
||||
__install_stage --uri file:///path/to/stage.tgz --target /target
|
||||
__install_stage --uri file:///path/to/stage.tgz \
|
||||
--target /target \
|
||||
--post_install /path/to/file/on/server
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
33
cdist/conf/type/__install_stage/manifest
Executable file
33
cdist/conf/type/__install_stage/manifest
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
# set defaults
|
||||
uri="$(cat "$__object/parameter/uri" 2>/dev/null \
|
||||
|| echo "$__object_id" | tee "$__object/parameter/uri")"
|
||||
target="$(cat "$__object/parameter/target" 2>/dev/null \
|
||||
|| echo "/target" | tee "$__object/parameter/target")"
|
||||
|
||||
if [ -f "$__object/parameter/post_install" ]; then
|
||||
post_install="$(cat "$__object/parameter/post_install")"
|
||||
post_install_script="/tmp/post_install"
|
||||
__install_file $post_install_script --source $post_install
|
||||
echo "$post_install_script" > "$__object/parameter/post_install_script"
|
||||
fi
|
||||
|
2
cdist/conf/type/__install_stage/parameter/optional
Normal file
2
cdist/conf/type/__install_stage/parameter/optional
Normal file
|
@ -0,0 +1,2 @@
|
|||
target
|
||||
post_install
|
1
cdist/conf/type/__install_stage/parameter/required
Normal file
1
cdist/conf/type/__install_stage/parameter/required
Normal file
|
@ -0,0 +1 @@
|
|||
uri
|
0
cdist/conf/type/__install_stage/singleton
Normal file
0
cdist/conf/type/__install_stage/singleton
Normal file
25
cdist/conf/type/__install_umount/gencode-remote
Executable file
25
cdist/conf/type/__install_umount/gencode-remote
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
target="$(cat "$__object/parameter/target")"
|
||||
|
||||
echo "swapoff -a"
|
||||
echo "umount -l ${target}/* || true"
|
||||
echo "umount -l ${target}"
|
0
cdist/conf/type/__install_umount/install
Normal file
0
cdist/conf/type/__install_umount/install
Normal file
43
cdist/conf/type/__install_umount/man.text
Normal file
43
cdist/conf/type/__install_umount/man.text
Normal file
|
@ -0,0 +1,43 @@
|
|||
cdist-type__install_umount(7)
|
||||
=============================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__install_umount - umount target directory
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This cdist type allows you to recursively umount the given target directory.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
target::
|
||||
the mount point to umount. Defaults to object_id
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__install_umount /target
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
23
cdist/conf/type/__install_umount/manifest
Executable file
23
cdist/conf/type/__install_umount/manifest
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 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/>.
|
||||
#
|
||||
|
||||
# set defaults
|
||||
target="$(cat "$__object/parameter/target" 2>/dev/null \
|
||||
|| echo "/target" | tee "$__object/parameter/target")"
|
Loading…
Reference in a new issue