rework blank line

This commit is contained in:
tschettervictor
2025-04-29 21:51:24 -06:00
parent f21bedb53c
commit 046cf87e79
16 changed files with 113 additions and 77 deletions

View File

@@ -90,15 +90,18 @@ set_target "${TARGET}"
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
echo ""
info "[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
bastille start "${_jail}" bastille start "${_jail}"
else else
info "[${_jail}]:"
error_notify "Jail is not running." error_notify "Jail is not running."
error_continue "Use [-a|--auto] to auto-start the jail." error_continue "Use [-a|--auto] to auto-start the jail."
fi fi
# Print blank line in front of first jail
[ "${_jail}" = "${_FIRST_JAIL}" ] && echo ""
info "[${_jail}]:"
COUNT=$(($COUNT+1)) COUNT=$(($COUNT+1))
if grep -qw "linsysfs" "${bastille_jailsdir}/${_jail}/fstab"; then if grep -qw "linsysfs" "${bastille_jailsdir}/${_jail}/fstab"; then
@@ -117,8 +120,8 @@ for _jail in ${JAILS}; do
RETURN=$(($RETURN+$ERROR_CODE)) RETURN=$(($RETURN+$ERROR_CODE))
fi fi
# Print blank line on last jail # Print blank line
[ "${_jail}" = "${_LAST_JAIL}" ] && echo "" echo ""
done done

View File

@@ -67,9 +67,7 @@ fi
# Notify message on error, and continue to next jail # Notify message on error, and continue to next jail
error_continue() { error_continue() {
error_notify "$@" error_notify "$@"
# Print blank line on last jail echo ""
# We can use _TARGET from check_target_is_(running|stopped) for this
[ "${_TARGET}" = "${_LAST_JAIL}" ] && echo ""
# shellcheck disable=SC2104 # shellcheck disable=SC2104
continue continue
} }
@@ -211,10 +209,10 @@ set_target() {
TARGET="$(list_jail_priority "${TARGET}" | sort -k2 -nr | awk '{print $1}')" TARGET="$(list_jail_priority "${TARGET}" | sort -k2 -nr | awk '{print $1}')"
JAILS="$(list_jail_priority "${TARGET}" | sort -k2 -nr | awk '{print $1}')" JAILS="$(list_jail_priority "${TARGET}" | sort -k2 -nr | awk '{print $1}')"
fi fi
_LAST_JAIL="$(echo ${JAILS} | awk '{print $NF}')" _FIRST_JAIL="$(echo ${JAILS} | awk '{print $1}')"
export TARGET export TARGET
export JAILS export JAILS
export _LAST_JAIL export _FIRST_JAIL
fi fi
} }
@@ -241,10 +239,10 @@ set_target_single() {
fi fi
TARGET="${_TARGET}" TARGET="${_TARGET}"
JAILS="${_TARGET}" JAILS="${_TARGET}"
_LAST_JAIL="$(echo ${JAILS} | awk '{print $NF}')" _FIRST_JAIL="$(echo ${JAILS} | awk '{print $1}')"
export TARGET export TARGET
export JAILS export JAILS
export _LAST_JAIL export _FIRST_JAIL
} }
target_all_jails() { target_all_jails() {
@@ -260,9 +258,9 @@ target_all_jails() {
elif [ "${_order}" = "reverse" ]; then elif [ "${_order}" = "reverse" ]; then
JAILS="$(list_jail_priority "${JAILS}" | sort -k2 -nr | awk '{print $1}')" JAILS="$(list_jail_priority "${JAILS}" | sort -k2 -nr | awk '{print $1}')"
fi fi
_LAST_JAIL="$(echo ${JAILS} | awk '{print $NF}')" _FIRST_JAIL="$(echo ${JAILS} | awk '{print $1}')"
export JAILS export JAILS
export _LAST_JAIL export _FIRST_JAIL
} }
update_fstab() { update_fstab() {

View File

@@ -115,15 +115,18 @@ check_fib() {
} }
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
echo ""
info "[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
bastille start "${_jail}" bastille start "${_jail}"
else else
info "[${_jail}]:"
error_notify "Jail is not running." error_notify "Jail is not running."
error_continue "Use [-a|--auto] to auto-start the jail." error_continue "Use [-a|--auto] to auto-start the jail."
fi fi
# Print blank line in front of first jail
[ "${_jail}" = "${_FIRST_JAIL}" ] && echo ""
info "[${_jail}]:"
LOGIN="$(jexec -l "${_jail}" which login)" LOGIN="$(jexec -l "${_jail}" which login)"
if [ -n "${USER}" ]; then if [ -n "${USER}" ]; then
@@ -134,7 +137,7 @@ for _jail in ${JAILS}; do
${_setfib} jexec -l "${_jail}" $LOGIN -f root ${_setfib} jexec -l "${_jail}" $LOGIN -f root
fi fi
# Print blank line on last jail # Print blank line
[ "${_jail}" = "${_LAST_JAIL}" ] && echo "" echo ""
done done

View File

@@ -88,7 +88,9 @@ set_target "${TARGET}"
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
echo "" # Print blank line in front of first jail
[ "${_jail}" = "${_FIRST_JAIL}" ] && echo ""
info "[${_jail}]:" info "[${_jail}]:"
host_path="${HOST_PATH}" host_path="${HOST_PATH}"
@@ -98,7 +100,7 @@ for _jail in ${JAILS}; do
error_continue "CP failed: ${host_path} -> ${jail_path}" error_continue "CP failed: ${host_path} -> ${jail_path}"
fi fi
# Print blank line on last jail # Print blank line
[ "${_jail}" = "${_LAST_JAIL}" ] && echo "" echo ""
done done

View File

@@ -52,7 +52,8 @@ destroy_jail() {
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
echo "" # Print blank line in front of first jail
[ "${_jail}" = "${_FIRST_JAIL}" ] && echo ""
bastille_jail_base="${bastille_jailsdir}/${_jail}" bastille_jail_base="${bastille_jailsdir}/${_jail}"
bastille_jail_log="${bastille_logsdir}/${_jail}_console.log" bastille_jail_log="${bastille_logsdir}/${_jail}_console.log"
@@ -60,6 +61,7 @@ destroy_jail() {
check_target_is_stopped "${_jail}" || if [ "${AUTO}" -eq 1 ]; then check_target_is_stopped "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
bastille stop "${_jail}" bastille stop "${_jail}"
else else
info "[${_jail}]:"
error_notify "Jail is running." error_notify "Jail is running."
error_continue "Use [-a|--auto] to auto-stop the jail." error_continue "Use [-a|--auto] to auto-stop the jail."
fi fi
@@ -111,8 +113,8 @@ destroy_jail() {
fi fi
fi fi
# Print blank line on last jail # Print blank line
[ "${_jail}" = "${_LAST_JAIL}" ] && echo "" echo ""
done done
} }

View File

@@ -94,7 +94,9 @@ for _jail in ${DEST_TARGET}; do
continue continue
else else
echo "" # Print blank line in front of first jail
[ "${_jail}" = "${_FIRST_JAIL}" ] && echo ""
info "[${_jail}]:" info "[${_jail}]:"
source_path="$(echo ${bastille_jailsdir}/${SOURCE_TARGET}/root/${SOURCE_PATH} | sed 's#//#/#g')" source_path="$(echo ${bastille_jailsdir}/${SOURCE_TARGET}/root/${SOURCE_PATH} | sed 's#//#/#g')"
@@ -104,8 +106,8 @@ for _jail in ${DEST_TARGET}; do
error_continue "JCP failed: ${source_path} -> ${dest_path}" error_continue "JCP failed: ${source_path} -> ${dest_path}"
fi fi
# Print blank line on last jail # Print blank line
[ "${_jail}" = "${_LAST_JAIL}" ] && echo "" echo ""
fi fi
done done

View File

@@ -102,15 +102,18 @@ set_target "${TARGET}"
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
echo ""
info "[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
bastille start "${_jail}" bastille start "${_jail}"
else else
info "[${_jail}]:"
error_notify "Jail is not running." error_notify "Jail is not running."
error_continue "Use [-a|--auto] to auto-start the jail." error_continue "Use [-a|--auto] to auto-start the jail."
fi fi
# Print blank line in front of first jail
[ "${_jail}" = "${_FIRST_JAIL}" ] && echo ""
info "[${_jail}]:"
case "${ACTION}" in case "${ACTION}" in
add) add)

View File

@@ -142,16 +142,19 @@ fi
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
echo ""
info "[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
bastille start "${_jail}" bastille start "${_jail}"
else else
info "[${_jail}]:"
error_notify "Jail is not running." error_notify "Jail is not running."
error_exit "Use [-a|--auto] to auto-start the jail." error_exit "Use [-a|--auto] to auto-start the jail."
fi fi
# Print blank line in front of first jail
[ "${_jail}" = "${_FIRST_JAIL}" ] && echo ""
info "[${_jail}]:"
_fullpath_fstab="$( echo "${bastille_jailsdir}/${_jail}/root/${_jailpath_fstab}" 2>/dev/null | sed 's#//#/#' )" _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#//#/#' )" _fullpath="$( echo "${bastille_jailsdir}/${_jail}/root/${_jailpath}" 2>/dev/null | sed 's#//#/#' )"
_fstab_entry="${_hostpath_fstab} ${_fullpath_fstab} ${_type} ${_perms} ${_checks}" _fstab_entry="${_hostpath_fstab} ${_fullpath_fstab} ${_type} ${_perms} ${_checks}"
@@ -199,7 +202,7 @@ for _jail in ${JAILS}; do
mount -F "${bastille_jailsdir}/${_jail}/fstab" -a || error_continue "Failed to mount volume: ${_fullpath}" mount -F "${bastille_jailsdir}/${_jail}/fstab" -a || error_continue "Failed to mount volume: ${_fullpath}"
echo "Added: ${_fstab_entry}" echo "Added: ${_fstab_entry}"
# Print blank line on last jail # Print blank line
[ "${_jail}" = "${_LAST_JAIL}" ] && echo "" echo ""
done done

View File

@@ -96,15 +96,18 @@ errors=0
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
echo ""
info "[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
bastille start "${_jail}" bastille start "${_jail}"
else else
info "[${_jail}]:"
error_notify "Jail is not running." error_notify "Jail is not running."
error_continue "Use [-a|--auto] to auto-start the jail." error_continue "Use [-a|--auto] to auto-start the jail."
fi fi
# Print blank line in front of first jail
[ "${_jail}" = "${_FIRST_JAIL}" ] && echo ""
info "[${_jail}]:"
bastille_jail_path="${bastille_jailsdir}/${_jail}/root" bastille_jail_path="${bastille_jailsdir}/${_jail}/root"
if [ -f "/usr/sbin/mport" ]; then if [ -f "/usr/sbin/mport" ]; then
@@ -125,8 +128,8 @@ for _jail in ${JAILS}; do
fi fi
fi fi
# Print blank line on last jail # Print blank line
[ "${_jail}" = "${_LAST_JAIL}" ] && echo "" echo ""
done done

View File

@@ -86,20 +86,23 @@ bastille_root_check
set_target "${TARGET}" set_target "${TARGET}"
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
echo ""
info "[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
bastille start "${_jail}" bastille start "${_jail}"
else else
info "[${_jail}]:"
error_notify "Jail is not running." error_notify "Jail is not running."
error_continue "Use [-a|--auto] to auto-start the jail." error_continue "Use [-a|--auto] to auto-start the jail."
fi fi
# Print blank line in front of first jail
[ "${_jail}" = "${_FIRST_JAIL}" ] && echo ""
info "[${_jail}]:"
jexec -l "${_jail}" /usr/sbin/service "$@" jexec -l "${_jail}" /usr/sbin/service "$@"
# Print blank line on last jail # Print blank line
[ "${_jail}" = "${_LAST_JAIL}" ] && echo "" echo ""
done done

View File

@@ -111,7 +111,9 @@ for _jail in ${JAILS}; do
fi fi
fi fi
echo "" # Print blank line in front of first jail
[ "${_jail}" = "${_FIRST_JAIL}" ] && echo ""
info "[${_jail}]:" info "[${_jail}]:"
check_target_is_stopped "${_jail}" || error_continue "Jail is already running." check_target_is_stopped "${_jail}" || error_continue "Jail is already running."
@@ -188,7 +190,7 @@ for _jail in ${JAILS}; do
# Delay between jail action # Delay between jail action
sleep "${DELAY_TIME}" sleep "${DELAY_TIME}"
# Print blank line on last jail # Print blank line
[ "${_jail}" = "${_LAST_JAIL}" ] && echo "" echo ""
done done

View File

@@ -86,7 +86,9 @@ set_target "${TARGET}" "reverse"
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
echo "" # Print blank line in front of first jail
[ "${_jail}" = "${_FIRST_JAIL}" ] && echo ""
info "[${_jail}]:" info "[${_jail}]:"
check_target_is_running "${_jail}" || error_continue "Jail is already stopped." check_target_is_running "${_jail}" || error_continue "Jail is already stopped."
@@ -134,7 +136,7 @@ for _jail in ${JAILS}; do
done done
fi fi
# Print blank line on last jail # Print blank line
[ "${_jail}" = "${_LAST_JAIL}" ] && echo "" echo ""
done done

View File

@@ -86,20 +86,23 @@ bastille_root_check
set_target "${TARGET}" set_target "${TARGET}"
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
echo ""
info "[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
bastille start "${_jail}" bastille start "${_jail}"
else else
info "[${_jail}]:"
error_notify "Jail is not running." error_notify "Jail is not running."
error_continue "Use [-a|--auto] to auto-start the jail." error_continue "Use [-a|--auto] to auto-start the jail."
fi fi
# Print blank line in front of first jail
[ "${_jail}" = "${_FIRST_JAIL}" ] && echo ""
info "[${_jail}]:"
jexec -l "${_jail}" /usr/sbin/sysrc "$@" jexec -l "${_jail}" /usr/sbin/sysrc "$@"
# Print blank line on last jail # Print blank line
[ "${_jail}" = "${_LAST_JAIL}" ] && echo "" echo ""
done done

View File

@@ -76,7 +76,8 @@ set_target "${TARGET}"
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
echo "" # Print blank line in front of first jail
[ "${_jail}" = "${_FIRST_JAIL}" ] && echo ""
bastille_jail_tags="${bastille_jailsdir}/${_jail}/tags" bastille_jail_tags="${bastille_jailsdir}/${_jail}/tags"
case ${ACTION} in case ${ACTION} in
@@ -119,8 +120,8 @@ for _jail in ${JAILS}; do
;; ;;
esac esac
# Print blank line on last jail # Print blank line
[ "${_jail}" = "${_LAST_JAIL}" ] && echo "" echo ""
done done

View File

@@ -270,15 +270,18 @@ fi
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
echo ""
info "[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
bastille start "${_jail}" bastille start "${_jail}"
else else
info "[${_jail}]:"
error_notify "Jail is not running." error_notify "Jail is not running."
error_continue "Use [-a|--auto] to auto-start the jail." error_continue "Use [-a|--auto] to auto-start the jail."
fi fi
# Print blank line in front of first jail
[ "${_jail}" = "${_FIRST_JAIL}" ] && echo ""
info "[${_jail}]:"
info "Applying template: ${TEMPLATE}..." info "Applying template: ${TEMPLATE}..."
@@ -470,8 +473,8 @@ for _jail in ${JAILS}; do
fi fi
done done
# Print blank line on last jail # Print blank line
[ "${_jail}" = "${_LAST_JAIL}" ] && echo "" echo ""
info "Template applied: ${TEMPLATE}" info "Template applied: ${TEMPLATE}"

View File

@@ -87,15 +87,18 @@ set_target "${TARGET}"
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
echo ""
info "[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
bastille start "${_jail}" bastille start "${_jail}"
else else
info "[${_jail}]:"
error_notify "Jail is not running." error_notify "Jail is not running."
error_exit "Use [-a|--auto] to auto-start the jail." error_exit "Use [-a|--auto] to auto-start the jail."
fi fi
# Print blank line in front of first jail
[ "${_jail}" = "${_FIRST_JAIL}" ] && echo ""
info "[${_jail}]:"
_jailpath="$( echo "${bastille_jailsdir}/${_jail}/root/${MOUNT_PATH}" 2>/dev/null | sed 's#//#/#' | sed 's#\\##g')" _jailpath="$( echo "${bastille_jailsdir}/${_jail}/root/${MOUNT_PATH}" 2>/dev/null | sed 's#//#/#' | sed 's#\\##g')"
_mount="$( mount | grep -Eo "[[:blank:]]${_jailpath}[[:blank:]]" )" _mount="$( mount | grep -Eo "[[:blank:]]${_jailpath}[[:blank:]]" )"
@@ -126,7 +129,7 @@ for _jail in ${JAILS}; do
echo "Unmounted: ${_jailpath}" echo "Unmounted: ${_jailpath}"
# Print blank line on last jail # Print blank line
[ "${_jail}" = "${_LAST_JAIL}" ] && echo "" echo ""
done done