diff --git a/usr/local/share/bastille/cmd.sh b/usr/local/share/bastille/cmd.sh index 263988ca..015f4c53 100644 --- a/usr/local/share/bastille/cmd.sh +++ b/usr/local/share/bastille/cmd.sh @@ -87,7 +87,6 @@ COUNT=0 RETURN=0 set_target "${TARGET}" -_last_jail="$(echo ${JAILS} | awk '{print $NF}')" for _jail in ${JAILS}; do @@ -119,7 +118,7 @@ for _jail in ${JAILS}; do fi # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done diff --git a/usr/local/share/bastille/common.sh b/usr/local/share/bastille/common.sh index a5430a5a..e932c059 100644 --- a/usr/local/share/bastille/common.sh +++ b/usr/local/share/bastille/common.sh @@ -208,8 +208,10 @@ set_target() { TARGET="$(list_jail_priority "${TARGET}" | sort -k2 -nr | awk '{print $1}')" JAILS="$(list_jail_priority "${TARGET}" | sort -k2 -nr | awk '{print $1}')" fi + _LAST_JAIL="$(echo ${JAILS} | awk '{print $NF}')" export TARGET export JAILS + export _LAST_JAIL fi } @@ -236,8 +238,10 @@ set_target_single() { fi TARGET="${_TARGET}" JAILS="${_TARGET}" + _LAST_JAIL="$(echo ${JAILS} | awk '{print $NF}')" export TARGET export JAILS + export _LAST_JAIL } target_all_jails() { @@ -253,7 +257,9 @@ target_all_jails() { elif [ "${_order}" = "reverse" ]; then JAILS="$(list_jail_priority "${JAILS}" | sort -k2 -nr | awk '{print $1}')" fi + _LAST_JAIL="$(echo ${JAILS} | awk '{print $NF}')" export JAILS + export _LAST_JAIL } update_fstab() { diff --git a/usr/local/share/bastille/console.sh b/usr/local/share/bastille/console.sh index 98f93001..a50e5c3b 100644 --- a/usr/local/share/bastille/console.sh +++ b/usr/local/share/bastille/console.sh @@ -84,7 +84,6 @@ USER="${2}" bastille_root_check set_target "${TARGET}" -_last_jail="$(echo ${JAILS} | awk '{print $NF}')" validate_user() { local _jail="${1}" @@ -136,6 +135,6 @@ for _jail in ${JAILS}; do fi # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done diff --git a/usr/local/share/bastille/cp.sh b/usr/local/share/bastille/cp.sh index 7fdcd6cc..51454f47 100644 --- a/usr/local/share/bastille/cp.sh +++ b/usr/local/share/bastille/cp.sh @@ -85,7 +85,6 @@ JAIL_PATH="${3}" bastille_root_check set_target "${TARGET}" -_last_jail="$(echo ${JAILS} | awk '{print $NF}')" for _jail in ${JAILS}; do @@ -100,6 +99,6 @@ for _jail in ${JAILS}; do fi # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done \ No newline at end of file diff --git a/usr/local/share/bastille/destroy.sh b/usr/local/share/bastille/destroy.sh index 27d13a3b..af55236f 100644 --- a/usr/local/share/bastille/destroy.sh +++ b/usr/local/share/bastille/destroy.sh @@ -112,7 +112,7 @@ destroy_jail() { fi # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done } @@ -302,7 +302,6 @@ case "${TARGET}" in *) ## just destroy a jail set_target "${TARGET}" "reverse" - _last_jail="$(echo ${JAILS} | awk '{print $NF}')" destroy_jail "${JAILS}" ;; esac diff --git a/usr/local/share/bastille/jcp.sh b/usr/local/share/bastille/jcp.sh index ff50f0ad..7c3dbaf9 100644 --- a/usr/local/share/bastille/jcp.sh +++ b/usr/local/share/bastille/jcp.sh @@ -87,7 +87,6 @@ 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 @@ -106,7 +105,7 @@ for _jail in ${DEST_TARGET}; do fi # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" fi done \ No newline at end of file diff --git a/usr/local/share/bastille/limits.sh b/usr/local/share/bastille/limits.sh index 0bd89cb1..569d8ca8 100644 --- a/usr/local/share/bastille/limits.sh +++ b/usr/local/share/bastille/limits.sh @@ -99,7 +99,6 @@ fi bastille_root_check set_target "${TARGET}" -_last_jail="$(echo ${JAILS} | awk '{print $NF}')" for _jail in ${JAILS}; do @@ -191,6 +190,6 @@ for _jail in ${JAILS}; do esac # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done diff --git a/usr/local/share/bastille/mount.sh b/usr/local/share/bastille/mount.sh index d1676c28..4642478c 100644 --- a/usr/local/share/bastille/mount.sh +++ b/usr/local/share/bastille/mount.sh @@ -90,7 +90,6 @@ fi bastille_root_check set_target "${TARGET}" -_last_jail="$(echo ${JAILS} | awk '{print $NF}')" # Assign variables _hostpath_fstab=$(echo "${_fstab}" | awk '{print $1}') @@ -201,6 +200,6 @@ for _jail in ${JAILS}; do echo "Added: ${_fstab_entry}" # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done diff --git a/usr/local/share/bastille/pkg.sh b/usr/local/share/bastille/pkg.sh index 05f60db8..0b6d4927 100644 --- a/usr/local/share/bastille/pkg.sh +++ b/usr/local/share/bastille/pkg.sh @@ -91,7 +91,6 @@ shift bastille_root_check set_target "${TARGET}" -_last_jail="$(echo ${JAILS} | awk '{print $NF}')" errors=0 @@ -127,7 +126,7 @@ for _jail in ${JAILS}; do fi # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done diff --git a/usr/local/share/bastille/service.sh b/usr/local/share/bastille/service.sh index b29d66d7..6bd5cfd8 100644 --- a/usr/local/share/bastille/service.sh +++ b/usr/local/share/bastille/service.sh @@ -84,7 +84,6 @@ shift bastille_root_check set_target "${TARGET}" -_last_jail="$(echo ${JAILS} | awk '{print $NF}')" for _jail in ${JAILS}; do @@ -101,6 +100,6 @@ for _jail in ${JAILS}; do jexec -l "${_jail}" /usr/sbin/service "$@" # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done diff --git a/usr/local/share/bastille/start.sh b/usr/local/share/bastille/start.sh index 209a59a1..221760a7 100644 --- a/usr/local/share/bastille/start.sh +++ b/usr/local/share/bastille/start.sh @@ -100,7 +100,6 @@ TARGET="${1}" bastille_root_check set_target "${TARGET}" -_last_jail="$(echo ${JAILS} | awk '{print $NF}')" for _jail in ${JAILS}; do @@ -190,6 +189,6 @@ for _jail in ${JAILS}; do sleep "${DELAY_TIME}" # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done diff --git a/usr/local/share/bastille/stop.sh b/usr/local/share/bastille/stop.sh index 74643995..7bf99f28 100644 --- a/usr/local/share/bastille/stop.sh +++ b/usr/local/share/bastille/stop.sh @@ -83,7 +83,6 @@ TARGET="${1}" bastille_root_check set_target "${TARGET}" "reverse" -_last_jail="$(echo ${JAILS} | awk '{print $NF}')" for _jail in ${JAILS}; do @@ -136,6 +135,6 @@ for _jail in ${JAILS}; do fi # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done diff --git a/usr/local/share/bastille/sysrc.sh b/usr/local/share/bastille/sysrc.sh index d25cb4fa..360a02ba 100644 --- a/usr/local/share/bastille/sysrc.sh +++ b/usr/local/share/bastille/sysrc.sh @@ -84,7 +84,6 @@ shift bastille_root_check set_target "${TARGET}" -_last_jail="$(echo ${JAILS} | awk '{print $NF}')" for _jail in ${JAILS}; do @@ -101,6 +100,6 @@ for _jail in ${JAILS}; do jexec -l "${_jail}" /usr/sbin/sysrc "$@" # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done diff --git a/usr/local/share/bastille/tags.sh b/usr/local/share/bastille/tags.sh index b753d50d..ef9254a9 100644 --- a/usr/local/share/bastille/tags.sh +++ b/usr/local/share/bastille/tags.sh @@ -73,7 +73,6 @@ TAGS="${3}" bastille_root_check set_target "${TARGET}" -_last_jail="$(echo ${JAILS} | awk '{print $NF}')" for _jail in ${JAILS}; do @@ -121,7 +120,7 @@ for _jail in ${JAILS}; do esac # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done diff --git a/usr/local/share/bastille/template.sh b/usr/local/share/bastille/template.sh index 5d0d76c0..875078d2 100644 --- a/usr/local/share/bastille/template.sh +++ b/usr/local/share/bastille/template.sh @@ -221,7 +221,6 @@ if [ "${TARGET}" = '--convert' ]; then exit 0 else set_target "${TARGET}" - _last_jail="$(echo ${JAILS} | awk '{print $NF}')" fi case ${TEMPLATE} in @@ -472,7 +471,7 @@ for _jail in ${JAILS}; do done # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" info "Template applied: ${TEMPLATE}" diff --git a/usr/local/share/bastille/umount.sh b/usr/local/share/bastille/umount.sh index d569e731..0b89e202 100644 --- a/usr/local/share/bastille/umount.sh +++ b/usr/local/share/bastille/umount.sh @@ -84,7 +84,6 @@ MOUNT_PATH="${2}" bastille_root_check set_target "${TARGET}" -_last_jail="$(echo ${JAILS} | awk '{print $NF}')" for _jail in ${JAILS}; do @@ -128,6 +127,6 @@ for _jail in ${JAILS}; do echo "Unmounted: ${_jailpath}" # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done diff --git a/usr/local/share/bastille/zfs.sh b/usr/local/share/bastille/zfs.sh index 58d07793..182f69ec 100644 --- a/usr/local/share/bastille/zfs.sh +++ b/usr/local/share/bastille/zfs.sh @@ -53,7 +53,7 @@ for _jail in ${JAILS}; do zfs snapshot -r "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"@"${TAG}" # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done } @@ -68,7 +68,7 @@ for _jail in ${JAILS}; do zfs destroy -r "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"@"${TAG}" # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done } @@ -82,7 +82,7 @@ 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 "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done } @@ -95,7 +95,7 @@ for _jail in ${JAILS}; do zfs get "${ATTRIBUTE}" "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}" # Print blank line on last jail - [ "${_jail}" = "${_last_jail}" ] && echo "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done } @@ -109,7 +109,7 @@ for _jail in ${JAILS}; do 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 "" + [ "${_jail}" = "${_LAST_JAIL}" ] && echo "" done } @@ -144,7 +144,6 @@ 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