move help into options block

This commit is contained in:
tschettervictor
2024-12-24 07:40:02 -07:00
committed by GitHub
parent d293db2c54
commit 54bf9d6d53

View File

@@ -32,15 +32,35 @@
. /usr/local/etc/bastille/bastille.conf
usage() {
error_exit "Usage: bastille htop TARGET"
error_exit "Usage: bastille htop [option(s)] TARGET"
cat << EOF
Options:
-f | --force -- Start the jail if it is stopped.
EOF
exit 1
}
# Handle special-case commands first.
case "${1}" in
help|-h|--help)
usage
;;
esac
# Handle options.
FORCE=0
while [ "$#" -gt 0 ]; do
case "${1}" in
-h|--help|help)
usage
;;
-f|--force)
FORCE=1
shift
;;
-*)
error_exit "Unknown option: \"${1}\""
;;
*)
break
;;
esac
done
if [ $# -ne 1 ]; then
usage
@@ -50,13 +70,16 @@ TARGET="${1}"
bastille_root_check
set_target_single "${TARGET}"
check_target_is_running "${TARGET}" || exit
bastille_jail_path=$(/usr/sbin/jls -j "${_jail}" path)
if [ ! -x "${bastille_jail_path}/usr/local/bin/htop" ]; then
error_notify "htop not found on ${_jail}."
elif [ -x "${bastille_jail_path}/usr/local/bin/htop" ]; then
info "[${_jail}]:"
jexec -l ${_jail} /usr/local/bin/htop
check_target_is_running "${TARGET}" || if [ "${FORCE}" -eq 1 ]; then
bastille start "${TARGET}"
else
exit
fi
bastille_jail_path="${bastille_jailsdir}/${TARGET}/root"
if [ ! -x "${bastille_jail_path}/usr/local/bin/htop" ]; then
error_notify "htop not found on ${TARGET}."
elif [ -x "${bastille_jail_path}/usr/local/bin/htop" ]; then
info "[${TARGET}]:"
jexec -l ${TARGET} /usr/local/bin/htop
fi
echo -e "${COLOR_RESET}"