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

View File

@@ -31,7 +31,7 @@
. /usr/local/share/bastille/common.sh
usage() {
error_exit "Usage: bastille console TARGET [user]'."
error_exit "Usage: bastille console TARGET [user]'"
}
# Handle special-case commands first.
@@ -41,21 +41,12 @@ help|-h|--help)
;;
esac
if [ $# -gt 2 ] || [ $# -lt 1 ]; then
if [ $# -gt 1 ]; then
usage
fi
TARGET="${1}"
shift
USER="${1}"
if [ "${TARGET}" = 'ALL' ]; then
JAILS=$(jls name)
fi
if [ "${TARGET}" != 'ALL' ]; then
JAILS=$(jls name | awk "/^${TARGET}$/")
fi
validate_user() {
if jexec -l "${_jail}" id "${USER}" >/dev/null 2>&1; then
USER_SHELL="$(jexec -l "${_jail}" getent passwd "${USER}" | cut -d: -f7)"