mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-27 07:51:09 +01:00
PKG::ADDED:: return error code and print error message when 'bastille pkg' fails
This allows better integration of 'bastille pkg' in scripts, and permits to catch errors during 'bastille template' commands
This commit is contained in:
@@ -45,17 +45,32 @@ if [ $# -lt 1 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
errors=0
|
||||
|
||||
for _jail in ${JAILS}; do
|
||||
info "[${_jail}]:"
|
||||
bastille_jail_path=$(/usr/sbin/jls -j "${_jail}" path)
|
||||
if [ -f "/usr/sbin/mport" ]; then
|
||||
jexec -l -U root "${_jail}" /usr/sbin/mport "$@"
|
||||
if ! jexec -l -U root "${_jail}" /usr/sbin/mport "$@"; then
|
||||
errors=1
|
||||
fi
|
||||
elif [ -f "${bastille_jail_path}/usr/bin/apt" ]; then
|
||||
jexec -l "${_jail}" /usr/bin/apt "$@"
|
||||
if ! jexec -l "${_jail}" /usr/bin/apt "$@"; then
|
||||
errors=1
|
||||
fi
|
||||
elif [ "${USE_HOST_PKG}" = 1 ]; then
|
||||
/usr/sbin/pkg -j "${_jail}" "$@"
|
||||
if ! /usr/sbin/pkg -j "${_jail}" "$@"; then
|
||||
errors=1
|
||||
fi
|
||||
else
|
||||
jexec -l -U root "${_jail}" /usr/sbin/pkg "$@"
|
||||
if ! jexec -l -U root "${_jail}" /usr/sbin/pkg "$@"; then
|
||||
errors=1
|
||||
fi
|
||||
fi
|
||||
echo
|
||||
done
|
||||
|
||||
if [ $errors -ne 0 ]; then
|
||||
error_exit "Failed to apply on some jails, please check logs"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user