final run through

This commit is contained in:
tschettervictor
2025-04-30 13:39:05 -06:00
parent bb47671cf0
commit 2b5f239050
20 changed files with 133 additions and 132 deletions

View File

@@ -103,15 +103,16 @@ set_target "${TARGET}"
for _jail in ${JAILS}; do
info "\n[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
echo "Auto-starting ${_jail}..."
bastille start "${_jail}"
else
info "[${_jail}]:"
error_notify "Jail is not running."
error_continue_next_jail "Use [-a|--auto] to auto-start the jail."
error_continue "Use [-a|--auto] to auto-start the jail."
fi
info "[${_jail}]:"
case "${ACTION}" in
add)
@@ -154,43 +155,42 @@ for _jail in ${JAILS}; do
while read _limits; do
rctl -r "${_limits}" 2>/dev/null
done < "${bastille_jailsdir}/${_jail}/rctl.conf"
info "[${_jail}]: RCTL limits cleared."
echo "RCTL limits cleared."
fi
;;
list|show)
# Show limits
if [ -s "${bastille_jailsdir}/${_jail}/rctl.conf" ]; then
if [ "${1}" = "active" ]; then
rctl jail:${_jail} 2>/dev/null
else
cat "${bastille_jailsdir}/${_jail}/rctl.conf"
fi
if [ "${1}" = "active" ]; then
rctl jail:${_jail} 2>/dev/null
else
cat "${bastille_jailsdir}/${_jail}/rctl.conf"
fi
fi
;;
stats)
# Show statistics
if [ -s "${bastille_jailsdir}/${_jail}/rctl.conf" ]; then
rctl -hu jail:${_jail} 2>/dev/null
rctl -hu jail:${_jail} 2>/dev/null
fi
;;
reset)
# Remove limits and delete rctl.conf
if [ -s "${bastille_jailsdir}/${_jail}/rctl.conf" ]; then
if [ -s "${bastille_jailsdir}/${_jail}/rctl.conf" ]; then
while read _limits; do
rctl -r "${_limits}" 2>/dev/null
done < "${bastille_jailsdir}/${_jail}/rctl.conf"
info "[${TARGET}]: RCTL limits cleared."
echo "RCTL limits cleared."
fi
if [ -s "${bastille_jailsdir}/${_jail}/rctl.conf" ]; then
rm -f "${bastille_jailsdir}/${_jail}/rctl.conf"
info "[${TARGET}]: rctl.conf removed."
echo "rctl.conf removed."
else
error_continue_next_jail "[${TARGET}]: rctl.conf not found."
error_continue "rctl.conf not found."
fi
;;
esac
# Print blank line
echo
done
echo

View File

@@ -35,6 +35,7 @@
usage() {
error_notify "Usage: bastille mount [option(s)] TARGET HOST_PATH JAIL_PATH [filesystem_type options dump pass_number]"
cat << EOF
Options:
-a | --auto Auto mode. Start/stop jail(s) if required.
@@ -142,16 +143,16 @@ fi
for _jail in ${JAILS}; do
info "\n[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
echo "Auto-starting ${_jail}..."
bastille start "${_jail}"
else
info "[${_jail}]:"
error_notify "Jail is not running."
error_continue_next_jail "Use [-a|--auto] to auto-start the jail."
error_continue "Use [-a|--auto] to auto-start the jail."
fi
info "[${_jail}]:"
_fullpath_fstab="$( echo "${bastille_jailsdir}/${_jail}/root/${_jailpath_fstab}" 2>/dev/null | sed 's#//#/#' )"
_fullpath="$( echo "${bastille_jailsdir}/${_jail}/root/${_jailpath}" 2>/dev/null | sed 's#//#/#' )"
_fstab_entry="${_hostpath_fstab} ${_fullpath_fstab} ${_type} ${_perms} ${_checks}"
@@ -167,13 +168,13 @@ for _jail in ${JAILS}; do
# Create mount point if it does not exist
if [ -d "${_hostpath}" ] && [ ! -d "${_fullpath}" ]; then
mkdir -p "${_fullpath}" || error_continue_next_jail "Failed to create mount point."
mkdir -p "${_fullpath}" || error_continue "Failed to create mount point."
elif [ -f "${_hostpath}" ] ; then
_filename="$( basename ${_hostpath} )"
if echo "${_fullpath}" 2>/dev/null | grep -qow "${_filename}"; then
mkdir -p "$( dirname "${_fullpath}" )" || error_continue_next_jail "Failed to create mount point."
mkdir -p "$( dirname "${_fullpath}" )" || error_continue "Failed to create mount point."
if [ ! -f "${_fullpath}" ]; then
touch "${_fullpath}" || error_continue_next_jail "Failed to create mount point."
touch "${_fullpath}" || error_continue "Failed to create mount point."
else
error_notify "Failed. File exists at mount point."
warn "${_fullpath}"
@@ -183,9 +184,9 @@ for _jail in ${JAILS}; do
_fullpath_fstab="$( echo "${bastille_jailsdir}/${_jail}/root/${_jailpath_fstab}/${_filename}" 2>/dev/null | sed 's#//#/#' )"
_fullpath="$( echo "${bastille_jailsdir}/${_jail}/root/${_jailpath}/${_filename}" 2>/dev/null | sed 's#//#/#' )"
_fstab_entry="${_hostpath_fstab} ${_fullpath_fstab} ${_type} ${_perms} ${_checks}"
mkdir -p "$( dirname "${_fullpath}" )" || error_continue_next_jail "Failed to create mount point."
mkdir -p "$( dirname "${_fullpath}" )" || error_continue "Failed to create mount point."
if [ ! -f "${_fullpath}" ]; then
touch "${_fullpath}" || error_continue_next_jail "Failed to create mount point."
touch "${_fullpath}" || error_continue "Failed to create mount point."
else
error_notify "Failed. File exists at mount point."
warn "${_fullpath}"
@@ -195,11 +196,10 @@ for _jail in ${JAILS}; do
fi
# Add entry to fstab and mount
echo "${_fstab_entry}" >> "${bastille_jailsdir}/${_jail}/fstab" || error_continue_next_jail "Failed to create fstab entry: ${_fstab_entry}"
mount -F "${bastille_jailsdir}/${_jail}/fstab" -a || error_continue_next_jail "Failed to mount volume: ${_fullpath}"
echo "${_fstab_entry}" >> "${bastille_jailsdir}/${_jail}/fstab" || error_continue "Failed to create fstab entry: ${_fstab_entry}"
mount -F "${bastille_jailsdir}/${_jail}/fstab" -a || error_continue "Failed to mount volume: ${_fullpath}"
echo "Added: ${_fstab_entry}"
# Print blank line
echo
done
echo

View File

@@ -36,6 +36,7 @@
usage() {
error_notify "Usage: bastille network [option(s)] TARGET [remove|add] INTERFACE [IP_ADDRESS]"
cat << EOF
Options:
-a | --auto Start/stop the jail(s) if required.
@@ -135,7 +136,6 @@ if [ "${ACTION}" = "add" ] && [ "${NO_IP}" -eq 0 ] && [ -n "${4}" ]; then
IP="${4}"
elif [ "${NO_IP}" -eq 1 ] && [ -n "${4}" ]; then
error_notify "IP should not be present when using -n|--no-ip."
usage
else
IP=""
fi
@@ -165,7 +165,9 @@ fi
bastille_root_check
set_target_single "${TARGET}"
check_target_is_stopped "${TARGET}" || if [ "${AUTO}" -eq 1 ]; then
echo "Auto-stopping ${TARGET}..."
bastille stop "${TARGET}"
else
error_notify "Jail is running."
@@ -301,7 +303,6 @@ EOF
fi
fi
info "[${_jailname}]:"
echo "Added interface: \"${_if}\""
elif [ "${VNET}" -eq 1 ]; then
@@ -349,7 +350,6 @@ EOF
fi
fi
info "[${_jailname}]:"
echo "Added VNET interface: \"${_if}\""
elif [ "${bastille_network_vnet_type}" = "netgraph" ]; then
for _num in $(seq 0 "${_bastille_if_num_range}"); do
@@ -391,8 +391,6 @@ EOF
sysrc -f "${_jail_rc_config}" ifconfig_${_if_vnet}="inet ${_ip}"
fi
fi
info "[${_jailname}]:"
echo "Added VNET interface: \"${_if}\""
fi
elif [ "${PASSTHROUGH}" -eq 1 ]; then
@@ -414,7 +412,6 @@ EOF
fi
fi
info "[${_jailname}]:"
echo "Added Passthrough interface: \"${_if}\""
elif [ "${CLASSIC}" -eq 1 ]; then
@@ -425,7 +422,6 @@ EOF
fi
fi
info "[${_jailname}]:"
echo "Added interface: \"${_if}\""
}
@@ -525,8 +521,7 @@ remove_interface() {
error_exit "Failed to remove interface from jail.conf"
fi
fi
info "[${_jailname}]:"
echo "Removed interface: \"${_if}\""
}
@@ -554,10 +549,11 @@ add_vlan() {
bastille restart "${_jailname}"
fi
info "[${_jailname}]:"
info "Added VLAN ${_vlan_id} to interface: \"${_jail_vnet}\""
echo "Added VLAN ${_vlan_id} to interface: \"${_jail_vnet}\""
}
info "\n[${TARGET}]:"
case "${ACTION}" in
add)
validate_netconf
@@ -566,6 +562,7 @@ case "${ACTION}" in
error_exit "Interface is already added: \"${INTERFACE}\""
elif { [ "${VNET}" -eq 1 ] || [ "${BRIDGE}" -eq 1 ] || [ "${PASSTHROUGH}" -eq 1 ]; } && [ -n "${VLAN_ID}" ]; then
add_vlan "${TARGET}" "${INTERFACE}" "${IP}" "${VLAN_ID}"
echo
exit 0
fi
## validate IP if not empty

View File

@@ -35,6 +35,7 @@
usage() {
error_notify "Usage: bastille pkg [option(s)] TARGET COMMAND args"
cat << EOF
Options:
-a | --auto Auto mode. Start/stop jail(s) if required.
@@ -96,15 +97,15 @@ errors=0
for _jail in ${JAILS}; do
info "\n[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
echo "Auto-starting ${_jail}..."
bastille start "${_jail}"
else
info "[${_jail}]:"
error_notify "Jail is not running."
error_continue_next_jail "Use [-a|--auto] to auto-start the jail."
fi
info "[${_jail}]:"
bastille_jail_path="${bastille_jailsdir}/${_jail}/root"
if [ -f "/usr/sbin/mport" ]; then
@@ -125,11 +126,10 @@ for _jail in ${JAILS}; do
fi
fi
# Print blank line
echo
done
if [ $errors -ne 0 ]; then
error_exit "Failed to apply on some jails, please check logs"
fi
echo

View File

@@ -35,6 +35,7 @@
usage() {
error_notify "Usage: bastille rcp [option(s)] TARGET JAIL_PATH HOST_PATH"
cat << EOF
Options:
-q | --quiet Suppress output.
@@ -86,7 +87,7 @@ HOST_PATH="${3}"
bastille_root_check
set_target_single "${TARGET}"
info "[${TARGET}]:"
info "\n[${TARGET}]:"
host_path="${HOST_PATH}"
jail_path="$(echo ${bastille_jailsdir}/${TARGET}/root/${JAIL_PATH} | sed 's#//#/#g')"

View File

@@ -35,6 +35,7 @@
usage() {
error_notify "Usage: bastille rdr [option(s)] TARGET [clear|reset|list|(tcp|udp)] HOST_PORT JAIL_PORT [log ['(' logopts ')'] ]"
cat << EOF
Options:
-d | --destination [destination ip] Limit rdr to a destination IP. Useful if you have multiple IPs on one interface.
@@ -159,7 +160,6 @@ load_rdr_rule() {
| pfctl -a "rdr/${TARGET}" -f-; then
error_exit "Failed to create IPv4 rdr rule \"${if_name} ${src} ${dst} ${proto} ${host_port} ${jail_port}\""
else
info "[${TARGET}]:"
echo "IPv4 ${proto}/${host_port}:${jail_port} on ${if_name}"
fi
fi
@@ -171,7 +171,6 @@ load_rdr_rule() {
| pfctl -a "rdr/${TARGET}" -f-; then
error_exit "Failed to create IPv6 rdr rule \"${if_name} ${src} ${dst} ${proto} ${host_port} ${jail_port}\""
else
info "[${TARGET}]:"
echo "IPv6 ${proto}/${host_port}:${jail_port} on ${if_name}"
fi
fi
@@ -196,7 +195,6 @@ load_rdr_log_rule() {
| pfctl -a "rdr/${TARGET}" -f-; then
error_exit "Failed to create logged IPv4 rdr rule \"${if_name} ${src} ${dst} ${proto} ${host_port} ${jail_port}\""
else
info "[${TARGET}]:"
echo "IPv4 ${proto}/${host_port}:${jail_port} on ${if_name}"
fi
fi
@@ -208,7 +206,6 @@ load_rdr_log_rule() {
| pfctl -a "rdr/${TARGET}" -f-; then
error_exit "Failed to create logged IPv6 rdr rule \"${if_name} ${src} ${dst} ${proto} ${host_port} ${jail_port}\""
else
info "[${TARGET}]:"
echo "IPv6 ${proto}/${host_port}:${jail_port} on ${if_name}"
fi
fi
@@ -286,6 +283,8 @@ shift
bastille_root_check
set_target_single "${TARGET}"
info "\n[${TARGET}]:"
while [ "$#" -gt 0 ]; do
case "${1}" in
list)
@@ -320,9 +319,9 @@ while [ "$#" -gt 0 ]; do
check_jail_validity
echo "${TARGET} redirects:"
pfctl -a "rdr/${TARGET}" -Fn
if rm -f "${bastille_jailsdir}/${TARGET}/rdr.conf"; then
info "[${TARGET}]: rdr.conf removed"
fi
if rm -f "${bastille_jailsdir}/${TARGET}/rdr.conf"; then
echo "rdr.conf removed"
fi
fi
shift
;;
@@ -403,3 +402,5 @@ while [ "$#" -gt 0 ]; do
;;
esac
done
echo

View File

@@ -78,7 +78,9 @@ NEWNAME="${2}"
bastille_root_check
set_target_single "${TARGET}"
check_target_is_stopped "${TARGET}" || if [ "${AUTO}" -eq 1 ]; then
echo "Auto-stopping ${TARGET}..."
bastille stop "${TARGET}"
else
error_notify "Jail is running."
@@ -225,4 +227,6 @@ if [ -d "${bastille_jailsdir}/${NEWNAME}" ]; then
error_exit "Jail: ${NEWNAME} already exists."
fi
change_name
change_name
echo

View File

@@ -35,6 +35,7 @@
usage() {
error_notify "Usage: bastille restart [option(s)] TARGET"
cat << EOF
Options:
-b | --boot Respect jail boot setting.

View File

@@ -35,6 +35,7 @@
usage() {
error_notify "Usage: bastille service [options(s)] TARGET SERVICE_NAME ACTION"
cat << EOF
Options:
-a | --auto Auto mode. Start/stop jail(s) if required.
@@ -86,20 +87,19 @@ bastille_root_check
set_target "${TARGET}"
for _jail in ${JAILS}; do
info "\n[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
echo "Auto-starting ${_jail}..."
bastille start "${_jail}"
else
info "[${_jail}]:"
error_notify "Jail is not running."
error_continue_next_jail "Use [-a|--auto] to auto-start the jail."
fi
info "[${_jail}]:"
jexec -l "${_jail}" /usr/sbin/service "$@"
# Print blank line
echo
done
echo

View File

@@ -35,6 +35,7 @@
usage() {
error_notify "Usage: bastille start [option(s)] TARGET"
cat << EOF
Options:
-b | --boot Respect jail boot setting.
@@ -110,14 +111,13 @@ for _jail in ${JAILS}; do
continue
fi
fi
info "\n[${_jail}]:"
if check_target_is_running "${_jail}"; then
info "[${_jail}]:"
error_continue_next_jail "Jail is already running."
error_continue "Jail is already running."
fi
info "[${_jail}]:"
# Validate interfaces and add IPs to firewall table
if [ "$(bastille config ${_jail} get vnet)" != 'enabled' ]; then
_ip4_interfaces="$(bastille config ${_jail} get ip4.addr | sed 's/,/ /g')"
@@ -141,7 +141,7 @@ for _jail in ${JAILS}; do
pfctl -q -t "${bastille_network_pf_table}" -T add "${_ip}"
fi
else
error_continue_next_jail "Error: ${_if} interface does not exist."
error_continue "Error: ${_if} interface does not exist."
fi
done
fi
@@ -164,7 +164,7 @@ for _jail in ${JAILS}; do
pfctl -q -t "${bastille_network_pf_table}" -T add "${_ip}"
fi
else
error_continue_next_jail "Error: ${_if} interface does not exist."
error_continue "Error: ${_if} interface does not exist."
fi
done
fi
@@ -189,8 +189,7 @@ for _jail in ${JAILS}; do
# Delay between jail action
sleep "${DELAY_TIME}"
# Print blank line
echo
done
echo

View File

@@ -35,6 +35,7 @@
usage() {
error_notify "Usage: bastille stop [option(s)] TARGET"
cat << EOF
Options:
-v | --verbose Print every action on jail stop.
@@ -86,13 +87,12 @@ set_target "${TARGET}" "reverse"
for _jail in ${JAILS}; do
info "\n[${_jail}]:"
if check_target_is_stopped "${_jail}"; then
info "[${_jail}]:"
error_continue_next_jail "Jail is already stopped."
error_continue "Jail is already stopped."
fi
info "[${_jail}]:"
# Remove RDR rules
if [ "$(bastille config ${_jail} get vnet)" != "enabled" ] && [ -f "${bastille_pf_conf}" ]; then
_ip4="$(bastille config ${_jail} get ip4.addr | sed 's/,/ /g')"
@@ -135,8 +135,7 @@ for _jail in ${JAILS}; do
pfctl -q -t "${bastille_network_pf_table}" -T delete "${_ip}"
done
fi
# Print blank line
echo
done
echo

View File

@@ -35,6 +35,7 @@
usage() {
error_notify "Usage: bastille sysrc [option(s)] TARGET args"
cat << EOF
Options:
-a | --auto Auto mode. Start/stop jail(s) if required.
@@ -86,20 +87,17 @@ bastille_root_check
set_target "${TARGET}"
for _jail in ${JAILS}; do
info "\n[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
echo "Auto-starting ${_jail}..."
bastille start "${_jail}"
else
info "[${_jail}]:"
error_notify "Jail is not running."
error_continue_next_jail "Use [-a|--auto] to auto-start the jail."
error_continue "Use [-a|--auto] to auto-start the jail."
fi
info "[${_jail}]:"
jexec -l "${_jail}" /usr/sbin/sysrc "$@"
# Print blank line
echo
done

View File

@@ -36,6 +36,7 @@
usage() {
error_notify "Usage: bastille tags TARGET [add|delete|list] [tag1,tag2]"
cat << EOF
Options:
-x | --debug Enable debug mode.
@@ -117,8 +118,5 @@ for _jail in ${JAILS}; do
;;
esac
# Print blank line
echo
done

View File

@@ -270,15 +270,15 @@ fi
for _jail in ${JAILS}; do
info "\n[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
echo "Auto-starting ${_jail}..."
bastille start "${_jail}"
else
info "[${_jail}]:"
error_notify "Jail is not running."
error_continue_next_jail "Use [-a|--auto] to auto-start the jail."
error_continue "Use [-a|--auto] to auto-start the jail."
fi
info "[${_jail}]:"
info "Applying template: ${TEMPLATE}..."
@@ -469,10 +469,9 @@ for _jail in ${JAILS}; do
echo
fi
done
# Print blank line
echo
info "Template applied: ${TEMPLATE}"
done
echo

View File

@@ -35,6 +35,7 @@
usage() {
error_notify "Usage: bastille top [options(s)] TARGET"
cat << EOF
Options:
-a | --auto Auto mode. Start/stop jail(s) if required.
@@ -84,9 +85,10 @@ TARGET="${1}"
bastille_root_check
set_target_single "${TARGET}"
info "[${TARGET}]:"
info "\n[${TARGET}]:"
check_target_is_running "${TARGET}" || if [ "${AUTO}" -eq 1 ]; then
echo "Auto-starting ${TARGET}..."
bastille start "${TARGET}"
else
error_notify "Jail is not running."
@@ -94,3 +96,5 @@ else
fi
jexec -l "${TARGET}" /usr/bin/top
echo

View File

@@ -35,6 +35,7 @@
usage() {
error_notify "Usage: bastille umount [option(s)] TARGET JAIL_PATH"
cat << EOF
Options:
-a | --auto Auto mode. Start/stop jail(s) if required.
@@ -87,12 +88,14 @@ set_target "${TARGET}"
for _jail in ${JAILS}; do
info "\n[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
echo "Auto-starting ${_jail}..."
bastille start "${_jail}"
else
info "[${_jail}]:"
error_notify "Jail is not running."
error_continue_next_jail "Use [-a|--auto] to auto-start the jail."
error_continue "Use [-a|--auto] to auto-start the jail."
fi
info "[${_jail}]:"
@@ -104,29 +107,28 @@ for _jail in ${JAILS}; do
# Exit if mount point non-existent
if [ -z "${_mount}" ] && [ -z "${_fstab_entry}" ]; then
error_continue_next_jail "The specified mount point does not exist."
error_continue "The specified mount point does not exist."
fi
# Unmount
if [ -n "${_mount}" ]; then
umount "${_jailpath}" || error_continue_next_jail "Failed to unmount volume: ${MOUNT_PATH}"
umount "${_jailpath}" || error_continue "Failed to unmount volume: ${MOUNT_PATH}"
fi
# Remove entry from fstab
if [ -n "${_fstab_entry}" ]; then
if ! sed -E -i '' "\, +${_jailpath_fstab} +,d" "${bastille_jailsdir}/${_jail}/fstab"; then
error_continue_next_jail "Failed to delete fstab entry: ${MOUNT_PATH}"
error_continue "Failed to delete fstab entry: ${MOUNT_PATH}"
fi
fi
# Delete if mount point was a file
if [ -f "${_jailpath}" ]; then
rm -f "${_jailpath}" || error_continue_next_jail "Failed to unmount volume: ${MOUNT_PATH}"
rm -f "${_jailpath}" || error_continue "Failed to unmount volume: ${MOUNT_PATH}"
fi
echo "Unmounted: ${_jailpath}"
# Print blank line
echo
done
echo

View File

@@ -110,14 +110,13 @@ jail_check() {
# Check if the jail is thick and is running
set_target_single "${TARGET}"
check_target_is_running "${TARGET}" || if [ "${AUTO}" -eq 1 ]; then
echo "Auto-starting ${TARGET}..."
bastille start "${TARGET}"
else
info "[${TARGET}]:"
error_notify "Jail is not running."
error_exit "Use [-a|--auto] to auto-start the jail."
fi
if grep -qw "${bastille_jailsdir}/${TARGET}/root/.bastille" "${bastille_jailsdir}/${TARGET}/fstab"; then
info "[${TARGET}]:"
error_notify "${TARGET} is not a thick container."
error_exit "See 'bastille update RELEASE' to update thin jails."
fi
@@ -217,6 +216,9 @@ elif echo "${TARGET}" | grep -q "[0-9]\{2\}.[0-9]-RELEASE"; then
arch_check
release_update
else
info "\n[${TARGET}]:"
jail_check
jail_update "${TARGET}"
fi
echo

View File

@@ -35,6 +35,7 @@
usage() {
error_notify "Usage: bastille upgrade [option(s)] TARGET [NEWRELEASE|install]"
cat << EOF
Options:
-a | --auto Auto mode. Start/stop jail(s) if required.
@@ -106,9 +107,9 @@ thick_jail_check() {
local _jail="${1}"
# Check if the jail is thick and is running
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
echo "Auto-starting ${_jail}..."
bastille start "${_jail}"
else
info "[${TARGET}]:"
error_notify "Jail is not running."
error_exit "Use [-a|--auto] to auto-start the jail."
fi
@@ -118,9 +119,9 @@ thin_jail_check() {
local _jail="${1}"
# Check if the jail is thick and is running
check_target_is_stopped "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
echo "Auto-stopping ${_jail}..."
bastille stop "${_jail}"
else
info "[${TARGET}]:"
error_notify "Jail is running."
error_exit "Use [-a|--auto] to auto-stop the jail."
fi
@@ -206,6 +207,8 @@ if grep -qw "${bastille_jailsdir}/${TARGET}/root/.bastille" "${bastille_jailsdir
THIN_JAIL=1
fi
info "\n[${TARGET}]:"
# Check what we should upgrade
if [ "${NEWRELEASE}" = "install" ]; then
if [ "${THIN_JAIL}" -eq 1 ]; then
@@ -223,3 +226,5 @@ else
fi
jail_upgrade "${TARGET}" "${NEWRELEASE}"
fi
echo

View File

@@ -35,6 +35,7 @@
usage() {
error_notify "Usage: bastille verify [RELEASE|TEMPLATE]"
cat << EOF
Options:
-x | --debug Enable debug mode.
@@ -198,3 +199,5 @@ case "${1}" in
usage
;;
esac
echo

View File

@@ -35,6 +35,7 @@
usage() {
error_notify "Usage: bastille zfs TARGET [set|get|snap|destroy_snap|df|usage] [key=value|date]"
cat << EOF
Options:
-x | --debug Enable debug mode.
@@ -46,40 +47,31 @@ EOF
zfs_snapshot() {
for _jail in ${JAILS}; do
info "[${_jail}]:"
info "\n[${_jail}]:"
# shellcheck disable=SC2140
zfs snapshot -r "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"@"${TAG}"
# Print blank line
echo
done
}
zfs_destroy_snapshot() {
for _jail in ${JAILS}; do
info "[${_jail}]:"
info "\n[${_jail}]:"
# shellcheck disable=SC2140
zfs destroy -r "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"@"${TAG}"
# Print blank line
echo
done
}
zfs_set_value() {
for _jail in ${JAILS}; do
info "[${_jail}]:"
info "\n[${_jail}]:"
zfs "${ATTRIBUTE}" "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"
# Print blank line
echo
done
}
@@ -87,11 +79,8 @@ done
zfs_get_value() {
for _jail in ${JAILS}; do
info "[${_jail}]:"
info "\n[${_jail}]:"
zfs get "${ATTRIBUTE}" "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"
# Print blank line
echo
done
}
@@ -99,12 +88,9 @@ done
zfs_disk_usage() {
for _jail in ${JAILS}; do
info "[${_jail}]:"
info "\n[${_jail}]:"
zfs list -t all -o name,used,avail,refer,mountpoint,compress,ratio -r "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"
# Print blank line
echo
done
}
@@ -174,3 +160,5 @@ case "${ACTION}" in
usage
;;
esac
echo