From 7cbcdabb916225b51d62b7d2db5be5ec44b69847 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Sun, 22 Jun 2025 12:06:04 -0600 Subject: [PATCH] pkg: Add exit code check and return --- usr/local/share/bastille/pkg.sh | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/usr/local/share/bastille/pkg.sh b/usr/local/share/bastille/pkg.sh index 302c56ce..4ab84a96 100644 --- a/usr/local/share/bastille/pkg.sh +++ b/usr/local/share/bastille/pkg.sh @@ -116,35 +116,25 @@ pkg_run_command() { bastille_jail_path="${bastille_jailsdir}/${_jail}/root" if [ -f "/usr/sbin/mport" ]; then - if ! jexec -l -U root "${_jail}" /usr/sbin/mport "$@"; then - errors=1 - fi + jexec -l -U root "${_jail}" /usr/sbin/mport "$@" elif [ -f "${bastille_jail_path}/usr/bin/apt" ]; then - if ! jexec -l "${_jail}" /usr/bin/apt "$@"; then - errors=1 - fi + jexec -l "${_jail}" /usr/bin/apt "$@" 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} $@" + 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 + /usr/sbin/pkg -j ${_jail} $@ fi else if [ "${AUTO_YES}" -eq 1 ]; then - _jail_cmd="jexec -l -U root ${_jail} env ASSUME_ALWAYS_YES=yes /usr/sbin/pkg $@" + 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 + jexec -l -U root ${_jail} /usr/sbin/pkg $@ fi fi -} -errors=0 + bastille_check_exit_code "${_jail}" "$?" +} for _jail in ${JAILS}; do @@ -171,8 +161,4 @@ for _jail in ${JAILS}; do done wait -if [ $errors -ne 0 ]; then - error_exit "[ERROR]: Failed to apply on some jails, please check logs" -else - echo -fi +bastille_return_exit_code