Add -b|--boot for start/stop/restart

This commit is contained in:
tschettervictor
2025-03-15 21:35:03 -06:00
parent eae87b9218
commit aad1158146
4 changed files with 61 additions and 5 deletions

View File

@@ -38,20 +38,26 @@ usage() {
cat << EOF
Options:
-v | --verbose Print every action on jail stop.
-x | --debug Enable debug mode.
-b | --boot Respect jail boot setting.
-v | --verbose Print every action on jail stop.
-x | --debug Enable debug mode.
EOF
exit 1
}
# Handle options.
BOOT=0
OPTION=""
while [ "$#" -gt 0 ]; do
case "${1}" in
-h|--help|help)
usage
;;
-b|--boot)
BOOT=1
shift
;;
-v|--verbose)
OPTION="-v"
shift
@@ -63,6 +69,7 @@ while [ "$#" -gt 0 ]; do
-*)
for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do
case ${_opt} in
b) BOOT="1" ;;
v) OPTION="-v" ;;
x) enable_debug ;;
*) error_exit "Unknown Option: \"${1}\"" ;;
@@ -87,6 +94,14 @@ set_target "${TARGET}"
for _jail in ${JAILS}; do
# Continue if '-b|--boot' is set and 'boot=off'
if [ "${BOOT}" -eq 1 ]; then
BOOT_ENABLED="$(sysrc -f ${bastille_jailsdir}/${_jail}/boot.conf -n boot)"
if [ "${BOOT_ENABLED}" = "off" ]; then
continue
fi
fi
info "[${_jail}]:"
check_target_is_running "${_jail}" || error_continue "Jail is already stopped."