Ensure target is specified and exists in 1 place instead of many.

Require target to be running for commands that need it.
Closes #239.
This commit is contained in:
Chris Wells
2020-08-30 15:37:54 -04:00
parent aaffc882f9
commit c6aded8d0a
20 changed files with 162 additions and 320 deletions
+1 -17
View File
@@ -42,26 +42,10 @@ help|-h|--help)
;;
esac
if [ $# -gt 1 ] || [ $# -lt 1 ]; then
if [ $# -ne 0 ]; then
usage
fi
TARGET="${1}"
shift
if [ "${TARGET}" = 'ALL' ]; then
JAILS=$(jls name)
fi
if [ "${TARGET}" != 'ALL' ]; then
JAILS=$(jls name | awk "/^${TARGET}$/")
## check if exist or not running
if [ ! -d "${bastille_jailsdir}/${TARGET}" ]; then
error_exit "[${TARGET}]: Not found."
elif [ ! "$(jls name | awk "/^${TARGET}$/")" ]; then
error_exit "[${TARGET}]: Not started."
fi
fi
for _jail in ${JAILS}; do
## test if running
if [ "$(jls name | awk "/^${_jail}$/")" ]; then