mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-20 17:20:12 +01:00
restart: Pass only options that are allowed to stop
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user