From f4234463704186058de0fd62bb66595fc7bdc403 Mon Sep 17 00:00:00 2001 From: tschettervictor Date: Tue, 29 Apr 2025 18:54:34 -0600 Subject: [PATCH] add blank line after each jail on multiple targets --- usr/local/share/bastille/cmd.sh | 1 + usr/local/share/bastille/console.sh | 1 + usr/local/share/bastille/cp.sh | 5 +++++ usr/local/share/bastille/destroy.sh | 2 ++ usr/local/share/bastille/htop.sh | 1 + usr/local/share/bastille/jcp.sh | 5 +++++ usr/local/share/bastille/limits.sh | 1 + usr/local/share/bastille/mount.sh | 1 + usr/local/share/bastille/network.sh | 2 +- usr/local/share/bastille/pkg.sh | 1 + usr/local/share/bastille/service.sh | 5 +++++ usr/local/share/bastille/start.sh | 4 +++- usr/local/share/bastille/stop.sh | 2 ++ usr/local/share/bastille/sysrc.sh | 5 +++++ usr/local/share/bastille/tags.sh | 3 +++ usr/local/share/bastille/template.sh | 1 + usr/local/share/bastille/top.sh | 2 ++ usr/local/share/bastille/umount.sh | 1 + usr/local/share/bastille/zfs.sh | 24 +++++++++++++++++++----- 19 files changed, 60 insertions(+), 7 deletions(-) diff --git a/usr/local/share/bastille/cmd.sh b/usr/local/share/bastille/cmd.sh index 21fe6722..3d21f52e 100644 --- a/usr/local/share/bastille/cmd.sh +++ b/usr/local/share/bastille/cmd.sh @@ -90,6 +90,7 @@ set_target "${TARGET}" for _jail in ${JAILS}; do + echo "" info "[${_jail}]:" check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then diff --git a/usr/local/share/bastille/console.sh b/usr/local/share/bastille/console.sh index 44872012..8539ec63 100644 --- a/usr/local/share/bastille/console.sh +++ b/usr/local/share/bastille/console.sh @@ -115,6 +115,7 @@ check_fib() { } for _jail in ${JAILS}; do + echo "" info "[${_jail}]:" check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then diff --git a/usr/local/share/bastille/cp.sh b/usr/local/share/bastille/cp.sh index 314cb239..41771ed6 100644 --- a/usr/local/share/bastille/cp.sh +++ b/usr/local/share/bastille/cp.sh @@ -87,10 +87,15 @@ bastille_root_check set_target "${TARGET}" for _jail in ${JAILS}; do + + echo "" info "[${_jail}]:" + host_path="${HOST_PATH}" jail_path="$(echo ${bastille_jailsdir}/${_jail}/root/${JAIL_PATH} | sed 's#//#/#g')" + if ! cp "${OPTION}" "${host_path}" "${jail_path}"; then error_continue "CP failed: ${host_path} -> ${jail_path}" fi + done \ No newline at end of file diff --git a/usr/local/share/bastille/destroy.sh b/usr/local/share/bastille/destroy.sh index 53435d80..06392a7e 100644 --- a/usr/local/share/bastille/destroy.sh +++ b/usr/local/share/bastille/destroy.sh @@ -51,6 +51,8 @@ destroy_jail() { local OPTIONS for _jail in ${JAILS}; do + + echo "" bastille_jail_base="${bastille_jailsdir}/${_jail}" bastille_jail_log="${bastille_logsdir}/${_jail}_console.log" diff --git a/usr/local/share/bastille/htop.sh b/usr/local/share/bastille/htop.sh index 6aeaa3cf..54247674 100644 --- a/usr/local/share/bastille/htop.sh +++ b/usr/local/share/bastille/htop.sh @@ -85,6 +85,7 @@ bastille_root_check set_target_single "${TARGET}" info "[${TARGET}]:" + check_target_is_running "${TARGET}" || if [ "${AUTO}" -eq 1 ]; then bastille start "${TARGET}" else diff --git a/usr/local/share/bastille/jcp.sh b/usr/local/share/bastille/jcp.sh index 391511cf..bb10434b 100644 --- a/usr/local/share/bastille/jcp.sh +++ b/usr/local/share/bastille/jcp.sh @@ -89,12 +89,17 @@ set_target_single "${SOURCE_TARGET}" && SOURCE_TARGET="${TARGET}" set_target "${DEST_TARGET}" && DEST_TARGET="${JAILS}" for _jail in ${DEST_TARGET}; do + if [ "${_jail}" = "${SOURCE_TARGET}" ]; then continue else + + echo "" info "[${_jail}]:" + source_path="$(echo ${bastille_jailsdir}/${SOURCE_TARGET}/root/${SOURCE_PATH} | sed 's#//#/#g')" dest_path="$(echo ${bastille_jailsdir}/${_jail}/root/${DEST_PATH} | sed 's#//#/#g')" + if ! cp "${OPTION}" "${source_path}" "${dest_path}"; then error_continue "JCP failed: ${source_path} -> ${dest_path}" fi diff --git a/usr/local/share/bastille/limits.sh b/usr/local/share/bastille/limits.sh index c061d647..7c1e0123 100644 --- a/usr/local/share/bastille/limits.sh +++ b/usr/local/share/bastille/limits.sh @@ -102,6 +102,7 @@ set_target "${TARGET}" for _jail in ${JAILS}; do + echo "" info "[${_jail}]:" check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then diff --git a/usr/local/share/bastille/mount.sh b/usr/local/share/bastille/mount.sh index ee6e289e..1352a776 100644 --- a/usr/local/share/bastille/mount.sh +++ b/usr/local/share/bastille/mount.sh @@ -142,6 +142,7 @@ fi for _jail in ${JAILS}; do + echo "" info "[${_jail}]:" check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then diff --git a/usr/local/share/bastille/network.sh b/usr/local/share/bastille/network.sh index 92bef8a1..e9d89243 100644 --- a/usr/local/share/bastille/network.sh +++ b/usr/local/share/bastille/network.sh @@ -567,7 +567,7 @@ case "${ACTION}" in add_interface "${TARGET}" "${INTERFACE}" "${IP}" fi if [ -n "${VLAN_ID}" ]; then - add_vlan "${TARGET}" "${INTERFACE}" "${IP}" "${VLAN_ID}" + add_vlan "${TARGET}" "${INTERFACE}" "${IP}" "${VLAN_ID}" fi if [ "${AUTO}" -eq 1 ]; then bastille start "${TARGET}" diff --git a/usr/local/share/bastille/pkg.sh b/usr/local/share/bastille/pkg.sh index c51b9ea4..f95ac81f 100644 --- a/usr/local/share/bastille/pkg.sh +++ b/usr/local/share/bastille/pkg.sh @@ -96,6 +96,7 @@ errors=0 for _jail in ${JAILS}; do + echo "" info "[${_jail}]:" check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then diff --git a/usr/local/share/bastille/service.sh b/usr/local/share/bastille/service.sh index 40551def..4c58a0db 100644 --- a/usr/local/share/bastille/service.sh +++ b/usr/local/share/bastille/service.sh @@ -86,12 +86,17 @@ bastille_root_check set_target "${TARGET}" for _jail in ${JAILS}; do + + echo "" info "[${_jail}]:" + check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then bastille start "${_jail}" else error_notify "Jail is not running." error_continue "Use [-a|--auto] to auto-start the jail." fi + jexec -l "${_jail}" /usr/sbin/service "$@" + done diff --git a/usr/local/share/bastille/start.sh b/usr/local/share/bastille/start.sh index 8514bba8..ba2d7738 100644 --- a/usr/local/share/bastille/start.sh +++ b/usr/local/share/bastille/start.sh @@ -111,7 +111,9 @@ for _jail in ${JAILS}; do fi fi - info "[${_jail}]:" + echo "" + info "[${_jail}]:" + check_target_is_stopped "${_jail}" || error_continue "Jail is already running." # Validate interfaces and add IPs to firewall table diff --git a/usr/local/share/bastille/stop.sh b/usr/local/share/bastille/stop.sh index fe0643a0..0d82c7f5 100644 --- a/usr/local/share/bastille/stop.sh +++ b/usr/local/share/bastille/stop.sh @@ -86,7 +86,9 @@ set_target "${TARGET}" "reverse" for _jail in ${JAILS}; do + echo "" info "[${_jail}]:" + check_target_is_running "${_jail}" || error_continue "Jail is already stopped." # Remove RDR rules diff --git a/usr/local/share/bastille/sysrc.sh b/usr/local/share/bastille/sysrc.sh index de715e13..b1e388d1 100644 --- a/usr/local/share/bastille/sysrc.sh +++ b/usr/local/share/bastille/sysrc.sh @@ -86,12 +86,17 @@ bastille_root_check set_target "${TARGET}" for _jail in ${JAILS}; do + + echo "" info "[${_jail}]:" + check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then bastille start "${_jail}" else error_notify "Jail is not running." error_continue "Use [-a|--auto] to auto-start the jail." fi + jexec -l "${_jail}" /usr/sbin/sysrc "$@" + done diff --git a/usr/local/share/bastille/tags.sh b/usr/local/share/bastille/tags.sh index be0fc13a..44258671 100644 --- a/usr/local/share/bastille/tags.sh +++ b/usr/local/share/bastille/tags.sh @@ -75,6 +75,9 @@ bastille_root_check set_target "${TARGET}" for _jail in ${JAILS}; do + + echo "" + bastille_jail_tags="${bastille_jailsdir}/${_jail}/tags" case ${ACTION} in add) diff --git a/usr/local/share/bastille/template.sh b/usr/local/share/bastille/template.sh index c3092f28..f3b988c9 100644 --- a/usr/local/share/bastille/template.sh +++ b/usr/local/share/bastille/template.sh @@ -270,6 +270,7 @@ fi for _jail in ${JAILS}; do + echo "" info "[${_jail}]:" check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then diff --git a/usr/local/share/bastille/top.sh b/usr/local/share/bastille/top.sh index 9c767079..238f7114 100644 --- a/usr/local/share/bastille/top.sh +++ b/usr/local/share/bastille/top.sh @@ -85,10 +85,12 @@ bastille_root_check set_target_single "${TARGET}" info "[${TARGET}]:" + check_target_is_running "${TARGET}" || if [ "${AUTO}" -eq 1 ]; then bastille start "${TARGET}" else error_notify "Jail is not running." error_continue "Use [-a|--auto] to auto-start the jail." fi + jexec -l "${TARGET}" /usr/bin/top diff --git a/usr/local/share/bastille/umount.sh b/usr/local/share/bastille/umount.sh index 57c3081c..8e9c604b 100644 --- a/usr/local/share/bastille/umount.sh +++ b/usr/local/share/bastille/umount.sh @@ -87,6 +87,7 @@ set_target "${TARGET}" for _jail in ${JAILS}; do + echo "" info "[${_jail}]:" check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then diff --git a/usr/local/share/bastille/zfs.sh b/usr/local/share/bastille/zfs.sh index 675cb0e1..d3df3533 100644 --- a/usr/local/share/bastille/zfs.sh +++ b/usr/local/share/bastille/zfs.sh @@ -45,43 +45,57 @@ EOF zfs_snapshot() { for _jail in ${JAILS}; do + + echo "" info "[${_jail}]:" + # shellcheck disable=SC2140 zfs snapshot -r "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"@"${TAG}" - echo + done } zfs_destroy_snapshot() { for _jail in ${JAILS}; do + + echo "" info "[${_jail}]:" + # shellcheck disable=SC2140 zfs destroy -r "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"@"${TAG}" - echo + done } zfs_set_value() { for _jail in ${JAILS}; do + + echo "" info "[${_jail}]:" + zfs "${ATTRIBUTE}" "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}" - echo + done } zfs_get_value() { for _jail in ${JAILS}; do + + echo "" info "[${_jail}]:" zfs get "${ATTRIBUTE}" "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}" - echo + done } zfs_disk_usage() { for _jail in ${JAILS}; do + + echo "" info "[${_jail}]:" + zfs list -t all -o name,used,avail,refer,mountpoint,compress,ratio -r "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}" - echo + done }