Merge pull request #588 from yaazkal/all-target-fix
[FIX] Support `ALL` in `pkg` command when using the -H or --host option.
This commit is contained in:
@@ -119,6 +119,23 @@ EOF
|
|||||||
CMD=$1
|
CMD=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
target_all_jails() {
|
||||||
|
_JAILS=$(/usr/sbin/jls name)
|
||||||
|
JAILS=""
|
||||||
|
for _jail in ${_JAILS}; do
|
||||||
|
_JAILPATH=$(/usr/sbin/jls -j "${_jail}" path)
|
||||||
|
if [ -z ${_JAILPATH##${bastille_jailsdir}*} ]; then
|
||||||
|
JAILS="${JAILS} ${_jail}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
check_target_is_running() {
|
||||||
|
if [ ! "$(/usr/sbin/jls name | awk "/^${TARGET}$/")" ]; then
|
||||||
|
error_exit "[${TARGET}]: Not started. See 'bastille start ${TARGET}'."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Handle special-case commands first.
|
# Handle special-case commands first.
|
||||||
case "${CMD}" in
|
case "${CMD}" in
|
||||||
version|-v|--version)
|
version|-v|--version)
|
||||||
@@ -140,24 +157,17 @@ clone|config|cmd|console|convert|cp|edit|htop|limits|mount|pkg|rename|service|st
|
|||||||
shift
|
shift
|
||||||
|
|
||||||
if [ "${TARGET}" = 'ALL' ]; then
|
if [ "${TARGET}" = 'ALL' ]; then
|
||||||
_JAILS=$(/usr/sbin/jls name)
|
target_all_jails
|
||||||
JAILS=""
|
|
||||||
for _jail in ${_JAILS}; do
|
|
||||||
_JAILPATH=$(/usr/sbin/jls -j "${_jail}" path)
|
|
||||||
if [ -z ${_JAILPATH##${bastille_jailsdir}*} ]; then
|
|
||||||
JAILS="${JAILS} ${_jail}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
elif [ "${CMD}" = "pkg" ] && [ "${TARGET}" = '-H' ] || [ "${TARGET}" = '--host' ]; then
|
elif [ "${CMD}" = "pkg" ] && [ "${TARGET}" = '-H' ] || [ "${TARGET}" = '--host' ]; then
|
||||||
TARGET="${1}"
|
TARGET="${1}"
|
||||||
USE_HOST_PKG=1
|
USE_HOST_PKG=1
|
||||||
JAILS="${TARGET}"
|
if [ "${TARGET}" = 'ALL' ]; then
|
||||||
shift
|
target_all_jails
|
||||||
|
else
|
||||||
# Require the target to be running
|
JAILS="${TARGET}"
|
||||||
if [ ! "$(/usr/sbin/jls name | awk "/^${TARGET}$/")" ]; then
|
check_target_is_running
|
||||||
error_exit "[${TARGET}]: Not started. See 'bastille start ${TARGET}'."
|
|
||||||
fi
|
fi
|
||||||
|
shift
|
||||||
elif [ "${CMD}" = 'template' ] && [ "${TARGET}" = '--convert' ]; then
|
elif [ "${CMD}" = 'template' ] && [ "${TARGET}" = '--convert' ]; then
|
||||||
# This command does not act on a jail, so we are temporarily bypassing the presence/started
|
# This command does not act on a jail, so we are temporarily bypassing the presence/started
|
||||||
# checks. The command will simply convert a template from hooks to a Bastillefile. -- cwells
|
# checks. The command will simply convert a template from hooks to a Bastillefile. -- cwells
|
||||||
@@ -171,10 +181,7 @@ clone|config|cmd|console|convert|cp|edit|htop|limits|mount|pkg|rename|service|st
|
|||||||
|
|
||||||
case "${CMD}" in
|
case "${CMD}" in
|
||||||
cmd|console|htop|pkg|service|stop|sysrc|template|top)
|
cmd|console|htop|pkg|service|stop|sysrc|template|top)
|
||||||
# Require the target to be running. -- cwells
|
check_target_is_running
|
||||||
if [ ! "$(/usr/sbin/jls name | awk "/^${TARGET}$/")" ]; then
|
|
||||||
error_exit "[${TARGET}]: Not started. See 'bastille start ${TARGET}'."
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
convert|rename)
|
convert|rename)
|
||||||
# Require the target to be stopped. -- cwells
|
# Require the target to be stopped. -- cwells
|
||||||
|
|||||||
Reference in New Issue
Block a user