evobackup/lib/bkctld-init

32 lines
696 B
Bash
Executable file

#!/bin/sh
#
# Init jail <jailname>
# Usage: init <jailname>
#
# shellcheck source=./includes
LIBDIR="$(dirname $0)" && . "${LIBDIR}/includes"
jail_name="${1:?}"
if [ -z "${jail_name}" ]; then
"${LIBDIR}/bkctld-help" && exit 1
fi
jail_path=$(jail_path "${jail_name}")
test -d "${jail_path}" && error "${jail_name}: jail already exists."
# Create config and jails directory
mkdir --parents "${CONFDIR}" "${JAILDIR}"
if is_btrfs "$(dirname "${JAILDIR}")" || is_btrfs "${JAILDIR}"; then
/bin/btrfs subvolume create "${jail_path}"
else
mkdir --parents "${jail_path}"
fi
setup_jail_chroot "${jail_name}"
setup_jail_config "${jail_name}"
notice "${jail_name}: jail has been created"