From 08c51a216ac91b5d21b22f33ccddb2c1f7a9ccd2 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Mon, 12 May 2025 11:14:23 -0600 Subject: [PATCH] list: Add -u and -d --- usr/local/share/bastille/list.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/usr/local/share/bastille/list.sh b/usr/local/share/bastille/list.sh index 94301c57..73b79209 100644 --- a/usr/local/share/bastille/list.sh +++ b/usr/local/share/bastille/list.sh @@ -37,9 +37,11 @@ usage() { error_notify " [path(s)] [port(s)] [prio|priority] [state(s)] [template(s)]" cat << EOF Options: - + + -d | --down List stopped jails only. -j | --json List jails or sub-arg(s) in json format. -p | --pretty Print JSON in columns. + -u | --up List running jails only. -x | --debug Enable debug mode. EOF @@ -246,6 +248,11 @@ get_jail_info() { fi fi + # Continue if STATE doesnt match chosen options + if [ "${OPT_STATE}" != "all" ] && [ "${JAIL_STATE}" != "${OPT_STATE}" ]; then + continue + fi + # Add ... if JAIL_PORTS is too long JAIL_PORTS_FULL="${JAIL_PORTS}" if [ "${#JAIL_PORTS}" -gt "${MAX_LENGTH_JAIL_PORTS}" ]; then JAIL_PORTS="$(echo ${JAIL_PORTS} | cut -c-$((${MAX_LENGTH_JAIL_PORTS} - 3)))..."; fi @@ -633,11 +640,16 @@ TARGET="" # Handle options. OPT_JSON=0 OPT_PRETTY=0 +OPT_STATE="all" while [ "$#" -gt 0 ]; do case "${1}" in -h|--help|help) usage ;; + -d|--down) + OPT_STATE="Down" + shift + ;; -j|--json) OPT_JSON=1 shift @@ -646,16 +658,22 @@ while [ "$#" -gt 0 ]; do OPT_PRETTY=1 shift ;; + -u|--up) + OPT_STATE="Up" + shift + ;; -x|--debug) enable_debug - shift + shift ;; -*) for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do case ${_opt} in - a) ;; + a) error_exit "[ERROR]: \"-a\" is deprecated. Use \"all\" instead." ;; + d) OPT_STATE="Down" ;; j) OPT_JSON=1 ;; p) OPT_PRETTY=1 ;; + u) OPT_STATE="Up" ;; x) enable_debug ;; *) error_exit "[ERROR]: Unknown Option: \"${1}\"" esac