pkg: Add exit code check and return

This commit is contained in:
tschettervictor
2025-06-22 12:06:04 -06:00
committed by GitHub
parent d5d4fdd589
commit 7cbcdabb91

View File

@@ -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