mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-21 17:52:01 +01:00
htop: add auto mod
This commit is contained in:
@@ -34,29 +34,41 @@
|
|||||||
. /usr/local/etc/bastille/bastille.conf
|
. /usr/local/etc/bastille/bastille.conf
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
error_exit "Usage: bastille htop [option(s)] TARGET"
|
error_notify "Usage: bastille htop [option(s)] TARGET"
|
||||||
cat << EOF
|
cat << EOF
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
-f | --force -- Start the jail if it is stopped.
|
-a | --auto Auto mode. Start/stop jail(s) if required.
|
||||||
|
-x | --debug Enable debug mode.
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle options.
|
# Handle options.
|
||||||
FORCE=0
|
AUTO=0
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
-h|--help|help)
|
-h|--help|help)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
-f|--force)
|
-a|--auto)
|
||||||
FORCE=1
|
AUTO=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-x|--debug)
|
||||||
|
enable_debug
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
error_exit "Unknown option: \"${1}\""
|
for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do
|
||||||
|
case ${_opt} in
|
||||||
|
a) AUTO=1 ;;
|
||||||
|
x) enable_debug ;;
|
||||||
|
*) error_exit "Unknown Option: \"${1}\""
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
break
|
break
|
||||||
@@ -74,15 +86,14 @@ bastille_root_check
|
|||||||
set_target_single "${TARGET}"
|
set_target_single "${TARGET}"
|
||||||
|
|
||||||
info "[${TARGET}]:"
|
info "[${TARGET}]:"
|
||||||
check_target_is_running "${TARGET}" || if [ "${FORCE}" -eq 1 ]; then
|
check_target_is_running "${TARGET}" || if [ "${AUTO}" -eq 1 ]; then
|
||||||
bastille start "${TARGET}"
|
bastille start "${TARGET}"
|
||||||
else
|
else
|
||||||
error_notify "Jail is not running."
|
error_notify "Jail is not running."
|
||||||
error_continue "Use [-f|--force] to force start the jail."
|
error_continue "Use [-a|--auto] to auto-start the jail."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bastille_jail_path="${bastille_jailsdir}/${TARGET}/root"
|
if [ ! -x "${bastille_jailsdir}/${TARGET}/root/usr/local/bin/htop" ]; then
|
||||||
if [ ! -x "${bastille_jail_path}/usr/local/bin/htop" ]; then
|
|
||||||
error_notify "htop not found on ${TARGET}."
|
error_notify "htop not found on ${TARGET}."
|
||||||
elif [ -x "${bastille_jail_path}/usr/local/bin/htop" ]; then
|
elif [ -x "${bastille_jail_path}/usr/local/bin/htop" ]; then
|
||||||
jexec -l ${TARGET} /usr/local/bin/htop
|
jexec -l ${TARGET} /usr/local/bin/htop
|
||||||
|
|||||||
Reference in New Issue
Block a user