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 1/4] 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 From 654e7aafaa3d67a10326a70455bb9e8a8dea608e Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Mon, 12 May 2025 11:17:29 -0600 Subject: [PATCH 2/4] Fix shell check --- usr/local/share/bastille/list.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/usr/local/share/bastille/list.sh b/usr/local/share/bastille/list.sh index 73b79209..10d79b65 100644 --- a/usr/local/share/bastille/list.sh +++ b/usr/local/share/bastille/list.sh @@ -250,6 +250,7 @@ get_jail_info() { # Continue if STATE doesnt match chosen options if [ "${OPT_STATE}" != "all" ] && [ "${JAIL_STATE}" != "${OPT_STATE}" ]; then + # shellcheck disable=SC2046 continue fi From c2887b3e31f3e366ea22f18711e38b77224c22c7 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Mon, 12 May 2025 11:18:44 -0600 Subject: [PATCH 3/4] Fix shellcheck again --- usr/local/share/bastille/list.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/share/bastille/list.sh b/usr/local/share/bastille/list.sh index 10d79b65..946a9aea 100644 --- a/usr/local/share/bastille/list.sh +++ b/usr/local/share/bastille/list.sh @@ -250,7 +250,7 @@ get_jail_info() { # Continue if STATE doesnt match chosen options if [ "${OPT_STATE}" != "all" ] && [ "${JAIL_STATE}" != "${OPT_STATE}" ]; then - # shellcheck disable=SC2046 + # shellcheck disable=SC2104 continue fi From 53ec32b50f8ab0d88254936e8b70f8173c9af4e3 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Mon, 12 May 2025 11:21:59 -0600 Subject: [PATCH 4/4] docs: Update list for -u and -d --- docs/chapters/subcommands/list.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/chapters/subcommands/list.rst b/docs/chapters/subcommands/list.rst index f6b29a95..38fd6aa1 100644 --- a/docs/chapters/subcommands/list.rst +++ b/docs/chapters/subcommands/list.rst @@ -16,6 +16,8 @@ to print in columns instead of rows. [path(s)] [port(s)] [prio|priority] [state(s)] [template(s)] Options: + -d | --down List stopped jails only. -j | --json List jails or sub-arg(s) in json format. - -p | --pretty List JSON in columns. - -x | --debug Enable debug mode. + -p | --pretty Print JSON in columns. + -u | --up List running jails only. + -x | --debug Enable debug mode. \ No newline at end of file