Start a jail task which creates the zfs datasets and installs a new_jail script.

This commit is contained in:
Tom Alexander
2022-10-28 21:05:26 -04:00
parent 9bf06cc90e
commit 33d2118c15
10 changed files with 160 additions and 21 deletions

View File

@@ -0,0 +1,40 @@
#!/usr/bin/env bash
#
# Create a new jail
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
: ${JAIL_MOUNTPOINT:="{{ jail_zfs_dataset_mountpoint }}/jails"}
function die {
echo >&2 "$@"
exit 1
}
[ "$#" -eq 2 ] || die "1 argument required, $# provided"
JAIL_NAME="$2"
export DESTDIR="${JAIL_MOUNTPOINT}/$JAIL_NAME"
function by_src {
cd /usr/src
make -j 16 buildworld
make installworld DESTDIR=$DESTDIR
make distribution DESTDIR=$DESTDIR
}
function by_bin {
DESTRELEASE=13.1-RELEASE
DESTARCH=`uname -m`
SOURCEURL=http://ftp.freebsd.org/pub/FreeBSD/releases/$DESTARCH/$DESTRELEASE/
for component in base ports; do fetch $SOURCEURL/$component.txz -o - | tar -xf - -C "$DESTDIR" ; done
}
if [ "$1" = "src" ]; then
by_src
elif [ "$1" = "bin" ]; then
by_bin
else
die "First argument must be either 'src' or 'bin', got $1"
fi