From a168505223842e601cdafef1c07a9d8878f339fc Mon Sep 17 00:00:00 2001 From: tschettervictor Date: Sat, 26 Apr 2025 20:36:17 -0600 Subject: [PATCH] restart: Pass only options that are allowed to stop --- docs/chapters/subcommands/stop.rst | 1 - usr/local/share/bastille/restart.sh | 35 ++++++++++++++++++++--------- usr/local/share/bastille/stop.sh | 27 ---------------------- 3 files changed, 24 insertions(+), 39 deletions(-) diff --git a/docs/chapters/subcommands/stop.rst b/docs/chapters/subcommands/stop.rst index 1b993718..9e56aa0d 100644 --- a/docs/chapters/subcommands/stop.rst +++ b/docs/chapters/subcommands/stop.rst @@ -15,6 +15,5 @@ Stop jail(s). Usage: bastille stop [option(s)] TARGET Options: - -b | --boot Respect jail boot setting. -v | --verbose Print every action on jail stop. -x | --debug Enable debug mode. diff --git a/usr/local/share/bastille/restart.sh b/usr/local/share/bastille/restart.sh index a6c7ca04..2d370c4e 100644 --- a/usr/local/share/bastille/restart.sh +++ b/usr/local/share/bastille/restart.sh @@ -48,35 +48,48 @@ EOF # Handle options. # We pass these to start and stop. -_options="" +_start_options="" +_stop_options="" while [ "$#" -gt 0 ]; do case "${1}" in -h|--help|help) usage ;; -b|--boot) - _options="${_options} -b" + _start_options="${_start_options} -b" shift ;; -d|--delay) - _options="${_options} -d ${2}" + _start_options="${_start_options} -d ${2}" shift 2 ;; -v|--verbose) - _options="${_options} -v" + _start_options="${_start_options} -v" + _stop_options="${_stop_options} -v" shift ;; -x|--debug) - _options="${_options} -x" + _start_options="${_start_options} -x" + _stop_options="${_stop_options} -x" shift ;; -*) for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do case ${_opt} in - b) _options="${_options} -b" ;; - v) _options="${_options} -v" ;; - x) _options="${_options} -x" ;; - *) error_exit "Unknown Option: \"${1}\"" ;; + b) + _start_options="${_start_options} -b" + ;; + v) + _start_options="${_start_options} -v" + _stop_options="${_stop_options} -v" + ;; + x) + _start_options="${_start_options} -x" + _stop_options="${_stop_options} -x" + ;; + *) + error_exit "Unknown Option: \"${1}\"" + ;; esac done shift @@ -100,8 +113,8 @@ for _jail in ${JAILS}; do # Only restart running jails if check_target_is_running "${_jail}"; then - bastille stop ${_options} ${_jail} - bastille start ${_options} ${_jail} + bastille stop ${_stop_options} ${_jail} + bastille start ${_start_options} ${_jail} fi done diff --git a/usr/local/share/bastille/stop.sh b/usr/local/share/bastille/stop.sh index e4728f8a..fe0643a0 100644 --- a/usr/local/share/bastille/stop.sh +++ b/usr/local/share/bastille/stop.sh @@ -37,7 +37,6 @@ usage() { cat << EOF Options: - -b | --boot Respect jail boot setting. -v | --verbose Print every action on jail stop. -x | --debug Enable debug mode. @@ -46,26 +45,12 @@ EOF } # Handle options. -BOOT=0 -DELAY_TIME=0 OPTION="" while [ "$#" -gt 0 ]; do case "${1}" in -h|--help|help) usage ;; - -b|--boot) - BOOT=1 - shift - ;; - -d|--delay) - if [ -z "${2}" ] && ! echo "${2}" | grep -Eq '^[0-9]+$'; then - error_exit "[-d|--delay] requires a value." - else - DELAY_TIME="${2}" - fi - shift 2 - ;; -v|--verbose) OPTION="-v" shift @@ -77,7 +62,6 @@ 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}\"" ;; @@ -102,14 +86,6 @@ set_target "${TARGET}" "reverse" 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." @@ -156,7 +132,4 @@ for _jail in ${JAILS}; do done fi - # Delay between jail action - sleep "${DELAY_TIME}" - done