Merge pull request #991 from BastilleBSD/fix-blank-line

Fix blank line
This commit is contained in:
tschettervictor
2025-04-29 21:59:25 -06:00
committed by GitHub
16 changed files with 64 additions and 80 deletions

View File

@@ -90,15 +90,15 @@ 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
else
info "[${_jail}]:"
error_notify "Jail is not running."
error_continue "Use [-a|--auto] to auto-start the jail."
fi
info "[${_jail}]:"
COUNT=$(($COUNT+1))
if grep -qw "linsysfs" "${bastille_jailsdir}/${_jail}/fstab"; then
@@ -117,8 +117,8 @@ for _jail in ${JAILS}; do
RETURN=$(($RETURN+$ERROR_CODE))
fi
# Print blank line on last jail
[ "${_jail}" = "${_LAST_JAIL}" ] && echo ""
# Print blank line
echo ""
done

View File

@@ -67,9 +67,6 @@ fi
# Notify message on error, and continue to next jail
error_continue() {
error_notify "$@"
# Print blank line on last jail
# We can use _TARGET from check_target_is_(running|stopped) for this
[ "${_TARGET}" = "${_LAST_JAIL}" ] && echo ""
# shellcheck disable=SC2104
continue
}
@@ -211,10 +208,8 @@ 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
}
@@ -241,10 +236,8 @@ 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() {
@@ -260,9 +253,7 @@ 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() {

View File

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

View File

@@ -88,7 +88,6 @@ set_target "${TARGET}"
for _jail in ${JAILS}; do
echo ""
info "[${_jail}]:"
host_path="${HOST_PATH}"
@@ -98,7 +97,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 ""
# Print blank line
echo ""
done

View File

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

View File

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

View File

@@ -102,15 +102,15 @@ 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
else
info "[${_jail}]:"
error_notify "Jail is not running."
error_continue "Use [-a|--auto] to auto-start the jail."
fi
info "[${_jail}]:"
case "${ACTION}" in
add)

View File

@@ -142,16 +142,16 @@ fi
for _jail in ${JAILS}; do
echo ""
info "[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
bastille start "${_jail}"
else
info "[${_jail}]:"
error_notify "Jail is not running."
error_exit "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}"
@@ -199,7 +199,7 @@ for _jail in ${JAILS}; do
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 ""
# Print blank line
echo ""
done

View File

@@ -96,15 +96,15 @@ errors=0
for _jail in ${JAILS}; do
echo ""
info "[${_jail}]:"
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
bastille start "${_jail}"
else
else
info "[${_jail}]:"
error_notify "Jail is not running."
error_continue "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,8 +125,8 @@ for _jail in ${JAILS}; do
fi
fi
# Print blank line on last jail
[ "${_jail}" = "${_LAST_JAIL}" ] && echo ""
# Print blank line
echo ""
done

View File

@@ -86,20 +86,20 @@ 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
else
info "[${_jail}]:"
error_notify "Jail is not running."
error_continue "Use [-a|--auto] to auto-start the jail."
fi
info "[${_jail}]:"
jexec -l "${_jail}" /usr/sbin/service "$@"
# Print blank line on last jail
[ "${_jail}" = "${_LAST_JAIL}" ] && echo ""
# Print blank line
echo ""
done

View File

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

View File

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

View File

@@ -86,20 +86,20 @@ 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
else
info "[${_jail}]:"
error_notify "Jail is not running."
error_continue "Use [-a|--auto] to auto-start the jail."
fi
info "[${_jail}]:"
jexec -l "${_jail}" /usr/sbin/sysrc "$@"
# Print blank line on last jail
[ "${_jail}" = "${_LAST_JAIL}" ] && echo ""
# Print blank line
echo ""
done

View File

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

View File

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

View File

@@ -87,15 +87,15 @@ 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
info "[${_jail}]:"
error_notify "Jail is not running."
error_exit "Use [-a|--auto] to auto-start the jail."
fi
info "[${_jail}]:"
_jailpath="$( echo "${bastille_jailsdir}/${_jail}/root/${MOUNT_PATH}" 2>/dev/null | sed 's#//#/#' | sed 's#\\##g')"
_mount="$( mount | grep -Eo "[[:blank:]]${_jailpath}[[:blank:]]" )"
@@ -126,7 +126,7 @@ for _jail in ${JAILS}; do
echo "Unmounted: ${_jailpath}"
# Print blank line on last jail
[ "${_jail}" = "${_LAST_JAIL}" ] && echo ""
# Print blank line
echo ""
done