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

@@ -46,6 +46,7 @@ usage() {
-E | --empty Creates an empty container, intended for custom jail builds (thin/thick/linux or unsupported).
-L | --linux This option is intended for testing with Linux jails, this is considered experimental.
-M | --static-mac Generate a static MAC address for jail (VNET only).
--no-boot Create jail with boot=off.
--no-validate Do not validate the release when creating the jail.
-p | --priority VALUE Sets the priority value for jail startup and shutdown.
-T | --thick Creates a thick container, they consume more space as they are self contained and independent.
@@ -657,7 +658,7 @@ create_jail() {
fi
# Apply priority and boot settings
sysrc -f "${bastille_jailsdir}/${NAME}/boot.conf" boot=on
sysrc -f "${bastille_jailsdir}/${NAME}/boot.conf" boot=${BOOT}
sysrc -f "${bastille_jailsdir}/${NAME}/boot.conf" priority="${PRIORITY}"
}
@@ -671,6 +672,7 @@ if echo "${3}" | grep '@'; then
fi
# Handle options.
BOOT="on"
EMPTY_JAIL=""
THICK_JAIL=""
CLONE_JAIL=""
@@ -719,6 +721,10 @@ while [ $# -gt 0 ]; do
error_exit "Not a valid priority value: \"${2}\""
fi
;;
--no-boot)
BOOT="off"
shift
;;
--no-validate|no-validate)
VALIDATE_RELEASE=""
shift

View File

@@ -30,5 +30,25 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
usage() {
error_notify "Usage: bastille restart [option(s)] TARGET"
cat << EOF
Options:
-b | --boot Respect jail boot setting.
-v | --verbose Print every action on jail start.
-x | --debug Enable debug mode.
EOF
exit 1
}
# Handle options.
case "${1}" in
-h|--help|help)
usage
;;
esac
bastille stop "$@"
bastille start "$@"

View File

@@ -38,20 +38,26 @@ usage() {
cat << EOF
Options:
-v | --verbose Print every action on jail start.
-x | --debug Enable debug mode.
-b | --boot Respect jail boot setting.
-v | --verbose Print every action on jail start.
-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_stopped "${_jail}" || error_continue "Jail is already running."

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."