begin moving functions to common.sh

This commit is contained in:
tschettervictor
2024-12-16 12:18:40 -07:00
committed by GitHub
parent fb21ff1be3
commit e4fb6e3ca6

View File

@@ -70,6 +70,36 @@ warn() {
echo -e "${COLOR_YELLOW}$*${COLOR_RESET}"
}
# This is where I am placing all new functions.
check_if_jail_exists() {
TARGET="${1}"
JAILS=""
if [ -d "${bastille_jailsdir}/${TARGET}" ]; then
JAILS="${TARGET}"
return 0
else
error_exit "Jail not found."
fi
}
check_target_is_running() {
TARGET="${1}"
if [ ! "$(/usr/sbin/jls name | awk "/^${TARGET}$/")" ]; then
error_exit "[${TARGET}]: Not started. See 'bastille start ${TARGET}'."
fi
}
target_all_jails() {
_JAILS=$(/usr/sbin/jls name)
JAILS=""
for _jail in ${_JAILS}; do
_JAILPATH=$(/usr/sbin/jls -j "${_jail}" path)
if [ -z ${_JAILPATH##${bastille_jailsdir}*} ]; then
JAILS="${JAILS} ${_jail}"
fi
done
}
generate_vnet_jail_netblock() {
local jail_name="$1"
local use_unique_bridge="$2"