mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-19 16:51:00 +01:00
Merge pull request #813 from tschettervictor/patch-4
pkg: auto-mode/debug-mode
This commit is contained in:
@@ -165,11 +165,10 @@ version|-v|--version)
|
||||
help|-h|--help)
|
||||
usage
|
||||
;;
|
||||
|
||||
bootstrap|clone|console|create|cp|destroy|etcupdate|export|htop|import|jcp|list|mount|rcp|rdr|rename|restart|setup|start|top|umount|update|upgrade|verify)
|
||||
bootstrap|clone|console|create|cp|destroy|etcupdate|export|htop|import|jcp|list|mount|pkg|rcp|rdr|rename|restart|setup|start|top|umount|update|upgrade|verify)
|
||||
# Nothing "extra" to do for these commands. -- cwells
|
||||
;;
|
||||
config|cmd|convert|edit|limits|pkg|service|stop|sysrc|tags|template|zfs)
|
||||
config|cmd|convert|edit|limits|service|stop|sysrc|tags|template|zfs)
|
||||
# Parse the target and ensure it exists. -- cwells
|
||||
if [ $# -eq 0 ]; then # No target was given, so show the command's help. -- cwells
|
||||
PARAMS='help'
|
||||
|
||||
@@ -31,29 +31,82 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
. /usr/local/share/bastille/common.sh
|
||||
. /usr/local/etc/bastille/bastille.conf
|
||||
|
||||
usage() {
|
||||
error_exit "Usage: bastille pkg [-H|--host] TARGET command [args]"
|
||||
error_notify "Usage: bastille pkg [option(s)] TARGET COMMAND args"
|
||||
cat << EOF
|
||||
Options:
|
||||
|
||||
-a | --auto Auto mode. Start/stop jail(s) if required.
|
||||
-H | --host Use host 'pkg'.
|
||||
-x | --debug Enable debug mode.
|
||||
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Handle special-case commands first.
|
||||
case "$1" in
|
||||
help|-h|--help)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
# Handle options.
|
||||
AUTO=0
|
||||
USE_HOST_PKG=0
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "${1}" in
|
||||
-h|--help|help)
|
||||
usage
|
||||
;;
|
||||
-a|--auto)
|
||||
AUTO=1
|
||||
shift
|
||||
;;
|
||||
-H|--host)
|
||||
USE_HOST_PKG=1
|
||||
shift
|
||||
;;
|
||||
-x|--debug)
|
||||
enable_debug
|
||||
shift
|
||||
;;
|
||||
-*)
|
||||
for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do
|
||||
case ${_opt} in
|
||||
a) AUTO=1 ;;
|
||||
H) USE_HOST_PKG=1 ;;
|
||||
x) enable_debug ;;
|
||||
*) error_exit "Unknown Option: \"${1}\"" ;;
|
||||
esac
|
||||
done
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
if [ $# -lt 2 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
TARGET="${1}"
|
||||
shift
|
||||
|
||||
bastille_root_check
|
||||
set_target "${TARGET}"
|
||||
|
||||
errors=0
|
||||
|
||||
for _jail in ${JAILS}; do
|
||||
|
||||
info "[${_jail}]:"
|
||||
bastille_jail_path=$(/usr/sbin/jls -j "${_jail}" path)
|
||||
|
||||
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
||||
bastille start "${_jail}"
|
||||
else
|
||||
error_notify "Jail is not running."
|
||||
error_continue "Use [-a|--auto] to auto-start the jail."
|
||||
fi
|
||||
|
||||
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
|
||||
@@ -71,10 +124,8 @@ for _jail in ${JAILS}; do
|
||||
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