Merge pull request #988 from BastilleBSD/blank-line-after-last-jail

print blank line after last jail
This commit is contained in:
tschettervictor
2025-04-29 20:54:04 -06:00
committed by GitHub
17 changed files with 87 additions and 2 deletions

View File

@@ -87,6 +87,7 @@ COUNT=0
RETURN=0
set_target "${TARGET}"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
for _jail in ${JAILS}; do
@@ -116,6 +117,10 @@ for _jail in ${JAILS}; do
else
RETURN=$(($RETURN+$ERROR_CODE))
fi
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done
# Check when a command is executed in all running jails. (bastille cmd ALL ...)

View File

@@ -67,6 +67,7 @@ fi
# Notify message on error, and continue to next jail
error_continue() {
error_notify "$@"
echo ""
# shellcheck disable=SC2104
continue
}

View File

@@ -84,6 +84,7 @@ USER="${2}"
bastille_root_check
set_target "${TARGET}"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
validate_user() {
local _jail="${1}"
@@ -133,5 +134,8 @@ for _jail in ${JAILS}; do
LOGIN="$(jexec -l "${_jail}" which login)"
${_setfib} jexec -l "${_jail}" $LOGIN -f root
fi
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done

View File

@@ -85,6 +85,7 @@ JAIL_PATH="${3}"
bastille_root_check
set_target "${TARGET}"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
for _jail in ${JAILS}; do
@@ -98,4 +99,7 @@ for _jail in ${JAILS}; do
error_continue "CP failed: ${host_path} -> ${jail_path}"
fi
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done

View File

@@ -110,6 +110,10 @@ destroy_jail() {
pfctl -a "rdr/${_jail}" -Fn
fi
fi
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done
}
@@ -298,6 +302,7 @@ case "${TARGET}" in
*)
## just destroy a jail
set_target "${TARGET}" "reverse"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
destroy_jail "${JAILS}"
;;
esac

View File

@@ -87,6 +87,7 @@ DEST_PATH="${4}"
bastille_root_check
set_target_single "${SOURCE_TARGET}" && SOURCE_TARGET="${TARGET}"
set_target "${DEST_TARGET}" && DEST_TARGET="${JAILS}"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
for _jail in ${DEST_TARGET}; do
@@ -103,5 +104,9 @@ for _jail in ${DEST_TARGET}; do
if ! cp "${OPTION}" "${source_path}" "${dest_path}"; then
error_continue "JCP failed: ${source_path} -> ${dest_path}"
fi
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
fi
done

View File

@@ -99,6 +99,7 @@ fi
bastille_root_check
set_target "${TARGET}"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
for _jail in ${JAILS}; do
@@ -188,4 +189,8 @@ for _jail in ${JAILS}; do
fi
;;
esac
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done

View File

@@ -90,6 +90,7 @@ fi
bastille_root_check
set_target "${TARGET}"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
# Assign variables
_hostpath_fstab=$(echo "${_fstab}" | awk '{print $1}')
@@ -198,4 +199,8 @@ for _jail in ${JAILS}; do
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 on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done

View File

@@ -91,6 +91,7 @@ shift
bastille_root_check
set_target "${TARGET}"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
errors=0
@@ -124,6 +125,10 @@ for _jail in ${JAILS}; do
errors=1
fi
fi
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done
if [ $errors -ne 0 ]; then

View File

@@ -84,6 +84,7 @@ shift
bastille_root_check
set_target "${TARGET}"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
for _jail in ${JAILS}; do
@@ -99,4 +100,7 @@ for _jail in ${JAILS}; do
jexec -l "${_jail}" /usr/sbin/service "$@"
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done

View File

@@ -100,6 +100,7 @@ TARGET="${1}"
bastille_root_check
set_target "${TARGET}"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
for _jail in ${JAILS}; do
@@ -187,5 +188,8 @@ for _jail in ${JAILS}; do
# Delay between jail action
sleep "${DELAY_TIME}"
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done

View File

@@ -83,6 +83,7 @@ TARGET="${1}"
bastille_root_check
set_target "${TARGET}" "reverse"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
for _jail in ${JAILS}; do
@@ -133,5 +134,8 @@ for _jail in ${JAILS}; do
pfctl -q -t "${bastille_network_pf_table}" -T delete "${_ip}"
done
fi
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done

View File

@@ -84,6 +84,7 @@ shift
bastille_root_check
set_target "${TARGET}"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
for _jail in ${JAILS}; do
@@ -99,4 +100,7 @@ for _jail in ${JAILS}; do
jexec -l "${_jail}" /usr/sbin/sysrc "$@"
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done

View File

@@ -73,6 +73,7 @@ TAGS="${3}"
bastille_root_check
set_target "${TARGET}"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
for _jail in ${JAILS}; do
@@ -118,5 +119,9 @@ for _jail in ${JAILS}; do
usage
;;
esac
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done

View File

@@ -221,6 +221,7 @@ if [ "${TARGET}" = '--convert' ]; then
exit 0
else
set_target "${TARGET}"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
fi
case ${TEMPLATE} in
@@ -469,6 +470,10 @@ for _jail in ${JAILS}; do
echo
fi
done
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
info "Template applied: ${TEMPLATE}"
info "Template applied: ${TEMPLATE}"
done

View File

@@ -84,6 +84,7 @@ MOUNT_PATH="${2}"
bastille_root_check
set_target "${TARGET}"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
for _jail in ${JAILS}; do
@@ -126,4 +127,7 @@ for _jail in ${JAILS}; do
echo "Unmounted: ${_jailpath}"
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done

View File

@@ -52,6 +52,9 @@ for _jail in ${JAILS}; do
# shellcheck disable=SC2140
zfs snapshot -r "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"@"${TAG}"
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done
}
@@ -64,6 +67,9 @@ for _jail in ${JAILS}; do
# shellcheck disable=SC2140
zfs destroy -r "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"@"${TAG}"
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done
}
@@ -75,6 +81,9 @@ for _jail in ${JAILS}; do
zfs "${ATTRIBUTE}" "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done
}
@@ -85,6 +94,9 @@ for _jail in ${JAILS}; do
info "[${_jail}]:"
zfs get "${ATTRIBUTE}" "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"
# Print blank line on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done
}
@@ -95,7 +107,10 @@ for _jail in ${JAILS}; do
info "[${_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 on last jail
[ "${_jail}" = "${_last_jail}" ] && echo ""
done
}
@@ -129,6 +144,7 @@ ACTION="${2}"
bastille_root_check
set_target "${TARGET}"
_last_jail="$(echo ${JAILS} | awk '{print $NF}')"
# Check if ZFS is enabled
if ! checkyesno bastille_zfs_enable; then