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:
1 parent
f1d73a0c02
commit
37e607c055
1 file changed
+19
-4
@@ -45,17 +45,32 @@ if [ $# -lt 1 ]; then
|
|||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
errors=0
|
||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
info "[${_jail}]:"
|
info "[${_jail}]:"
|
||||||
bastille_jail_path=$(/usr/sbin/jls -j "${_jail}" path)
|
bastille_jail_path=$(/usr/sbin/jls -j "${_jail}" path)
|
||||||
if [ -f "/usr/sbin/mport" ]; then
|
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
|
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
|
elif [ "${USE_HOST_PKG}" = 1 ]; then
|
||||||
/usr/sbin/pkg -j "${_jail}" "$@"
|
if ! /usr/sbin/pkg -j "${_jail}" "$@"; then
|
||||||
|
errors=1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
jexec -l -U root "${_jail}" /usr/sbin/pkg "$@"
|
if ! jexec -l -U root "${_jail}" /usr/sbin/pkg "$@"; then
|
||||||
|
errors=1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
done
|
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