updating Usage format; allowing non-root console option

This commit is contained in:
Christer Edwards
2019-11-22 22:00:58 -07:00
parent 6a7a08b714
commit d9f4972f59
+8 -6
View File
@@ -31,7 +31,7 @@
. /usr/local/share/bastille/colors.pre.sh . /usr/local/share/bastille/colors.pre.sh
usage() { usage() {
echo -e "${COLOR_RED}Usage: bastille console [ALL|glob]'.${COLOR_RESET}" echo -e "${COLOR_RED}Usage: bastille console TARGET [user]'.${COLOR_RESET}"
exit 1 exit 1
} }
@@ -47,18 +47,20 @@ if [ $# -gt 2 ] || [ $# -lt 1 ]; then
fi fi
TARGET="${1}" TARGET="${1}"
shift
USER="${1}"
if [ "$TARGET" = 'ALL' ]; then if [ "${TARGET}" = 'ALL' ]; then
JAILS=$(jls name) JAILS=$(jls name)
fi fi
if [ "$TARGET" != 'ALL' ]; then if [ "${TARGET}" != 'ALL' ]; then
JAILS=$(jls name | grep -w "${1}") JAILS=$(jls name | grep -w "${TARGET}")
fi fi
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}" echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
if [ ! -z "${2}" ]; then if [ ! -z "${USER}" ]; then
jexec -l ${_jail} /usr/bin/login -f "${2}" jexec -l ${_jail} /usr/bin/login -f "${USER}"
else else
jexec -l ${_jail} /usr/bin/login -f root jexec -l ${_jail} /usr/bin/login -f root
fi fi