pkg: Fix promt for y|n

This commit is contained in:
tschettervictor
2025-05-05 13:27:08 -06:00
committed by GitHub
parent b440678cc2
commit 55c5495313

View File

@@ -40,6 +40,7 @@ usage() {
-a | --auto Auto mode. Start/stop jail(s) if required.
-H | --host Use the hosts 'pkg' instead of the jails.
-y | --yes Assume always yes for pkg command. Do not prompt.
-x | --debug Enable debug mode.
EOF
@@ -48,6 +49,7 @@ EOF
# Handle options.
AUTO=0
AUTO_YES=0
USE_HOST_PKG=0
while [ "$#" -gt 0 ]; do
case "${1}" in
@@ -62,6 +64,10 @@ while [ "$#" -gt 0 ]; do
USE_HOST_PKG=1
shift
;;
-y|--yes)
AUTO_YES=1
shift
;;
-x|--debug)
enable_debug
shift
@@ -71,6 +77,7 @@ while [ "$#" -gt 0 ]; do
case ${_opt} in
a) AUTO=1 ;;
H) USE_HOST_PKG=1 ;;
y) AUTO_YES=1 ;;
x) enable_debug ;;
*) error_exit "[ERROR]: Unknown Option: \"${1}\"" ;;
esac
@@ -90,14 +97,13 @@ fi
TARGET="${1}"
shift
OPTION=""
BLA="$@"
bastille_root_check
set_target "${TARGET}"
errors=0
for _jail in ${JAILS}; do
(
pkg_run_command() {
# Validate jail state
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
@@ -120,18 +126,49 @@ for _jail in ${JAILS}; do
if ! jexec -l "${_jail}" /usr/bin/apt "$@"; then
errors=1
fi
elif [ "${USE_HOST_PKG}" = 1 ]; then
if ! /usr/sbin/pkg -j "${_jail}" "$@"; then
elif [ "${USE_HOST_PKG}" -eq 1 ]; then
if [ "${AUTO_YES}" -eq 1 ]; then
_jail_cmd="env ASSUME_ALWAYS_YES=yes /usr/sbin/pkg -j "${_jail}" "$@""
else
_jail_cmd="/usr/sbin/pkg -j "${_jail}" "$@""
fi
if ! ${_jail_cmd}; then
errors=1
fi
else
if ! jexec -l -U root "${_jail}" /usr/sbin/pkg "$@"; then
if [ "${AUTO_YES}" -eq 1 ]; then
_jail_cmd="jexec -l -U root "${_jail}" env ASSUME_ALWAYS_YES=yes /usr/sbin/pkg "$@""
else
_jail_cmd="jexec -l -U root "${_jail}" /usr/sbin/pkg "$@""
fi
if ! ${_jail_cmd}; then
errors=1
fi
fi
}
errors=0
for _jail in ${JAILS}; do
if [ "${AUTO_YES}" -eq 1 ]; then
(
pkg_run_command "$@"
) &
else
(
pkg_run_command "$@"
)
fi
bastille_running_jobs "${bastille_process_limit}"
done