Jérémy Lecour
89b0636cf6
All checks were successful
continuous-integration/drone/push Build is passing
38 lines
932 B
Bash
Executable file
38 lines
932 B
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Description: Initialize a new jail
|
|
# Usage: init <jailname>
|
|
#
|
|
|
|
# shellcheck source=./includes
|
|
LIBDIR="$(dirname $0)" && . "${LIBDIR}/includes"
|
|
|
|
jail_name="${1:?}"
|
|
if [ -z "${jail_name}" ]; then
|
|
show_help && exit 1
|
|
fi
|
|
jail_path=$(jail_path "${jail_name}")
|
|
incs_path=$(incs_path "${jail_name}")
|
|
|
|
test -d "${jail_path}" && error "Skip jail \`${jail_name}' : it already exists"
|
|
|
|
# Create config, jails and incs directories
|
|
mkdir --parents "${CONFDIR}" "${JAILDIR}" "${INCDIR}"
|
|
|
|
if is_btrfs "$(dirname "${JAILDIR}")" || is_btrfs "${JAILDIR}"; then
|
|
btrfs_bin=$(command -v btrfs)
|
|
if [ -z "${btrfs_bin}" ]; then
|
|
error "btrfs not found. Please install btrfs-progs."
|
|
fi
|
|
${btrfs_bin} subvolume create "${jail_path}"
|
|
else
|
|
mkdir --parents "${jail_path}"
|
|
fi
|
|
|
|
mkdir --parents "${incs_path}"
|
|
|
|
setup_jail_chroot "${jail_name}"
|
|
setup_jail_config "${jail_name}"
|
|
|
|
notice "Create jail \`${jail_name}' : OK"
|