mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-13 10:20:35 +01:00
Merge pull request #1209 from BastilleBSD/deprecate-parallel
This commit is contained in:
@@ -157,8 +157,6 @@ Available Commands:
|
|||||||
Use "bastille -v|--version" for version information.
|
Use "bastille -v|--version" for version information.
|
||||||
Use "bastille command -h|--help" for more information about a command.
|
Use "bastille command -h|--help" for more information about a command.
|
||||||
Use "bastille -c|--config config.conf command" to specify a non-default config file.
|
Use "bastille -c|--config config.conf command" to specify a non-default config file.
|
||||||
Use "bastille -p|--parallel VALUE command" to run bastille in parallel mode.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 1.0.x
|
## 1.0.x
|
||||||
|
|||||||
@@ -43,19 +43,6 @@ This value can be changed using ``bastille config TARGET set priority VALUE``.
|
|||||||
|
|
||||||
This value will be shown using ``bastille list all``.
|
This value will be shown using ``bastille list all``.
|
||||||
|
|
||||||
Parallel Mode
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Any command that supports multiple targets, also supports parallel mode. This
|
|
||||||
means that Bastille will run the command on multiple jails at a single time,
|
|
||||||
depending on the value given.
|
|
||||||
|
|
||||||
To use parallel mode, run ``bastille -p 4 pkg ALL update``, for example, to start
|
|
||||||
updating packages in all jails, 4 processes at a time.
|
|
||||||
|
|
||||||
Note that the ``-p`` option should follow the main ``bastille`` command, and not
|
|
||||||
the sub-command.
|
|
||||||
|
|
||||||
Examples: Containers
|
Examples: Containers
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
|||||||
@@ -52,5 +52,4 @@ Usage
|
|||||||
|
|
||||||
Use "bastille -v|--version" for version information.
|
Use "bastille -v|--version" for version information.
|
||||||
Use "bastille command -h|--help" for more information about a command.
|
Use "bastille command -h|--help" for more information about a command.
|
||||||
Use "bastille -c|--config config.conf command" to specify a non-default config file.
|
Use "bastille -c|--config config.conf command" to specify a non-default config file.
|
||||||
Use "bastille -p|--parallel VALUE command" to run bastille in parallel mode.
|
|
||||||
@@ -119,7 +119,6 @@ Available Commands:
|
|||||||
Use "bastille -v|--version" for version information.
|
Use "bastille -v|--version" for version information.
|
||||||
Use "bastille command -h|--help" for more information about a command.
|
Use "bastille command -h|--help" for more information about a command.
|
||||||
Use "bastille -c|--config FILE command" to specify a non-default config file.
|
Use "bastille -c|--config FILE command" to specify a non-default config file.
|
||||||
Use "bastille -p|--parallel VALUE command" to run bastille in parallel mode.
|
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
@@ -146,8 +145,6 @@ bastille_perms_check
|
|||||||
. /usr/local/share/bastille/common.sh
|
. /usr/local/share/bastille/common.sh
|
||||||
|
|
||||||
# Handle options
|
# Handle options
|
||||||
bastille_parallel_mode=0
|
|
||||||
bastille_process_limit="${bastille_process_limit:-1}"
|
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
-h|--help|help)
|
-h|--help|help)
|
||||||
@@ -170,15 +167,6 @@ while [ "$#" -gt 0 ]; do
|
|||||||
. /usr/local/share/bastille/common.sh
|
. /usr/local/share/bastille/common.sh
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
-p|--parallel)
|
|
||||||
bastille_parallel_mode=1
|
|
||||||
bastille_process_limit="${2}"
|
|
||||||
if ! echo "${bastille_process_limit}" | grep -Eq "^[0-9]+$"; then
|
|
||||||
error_exit "Not a valid process limit: ${bastille_process_limit}"
|
|
||||||
else
|
|
||||||
shift 2
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
-*)
|
-*)
|
||||||
error_exit "Unknown Option: \"${1}\""
|
error_exit "Unknown Option: \"${1}\""
|
||||||
;;
|
;;
|
||||||
@@ -188,9 +176,6 @@ while [ "$#" -gt 0 ]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Export parallel and limit
|
|
||||||
export bastille_process_limit
|
|
||||||
|
|
||||||
if [ "$#" -lt 1 ]; then
|
if [ "$#" -lt 1 ]; then
|
||||||
usage
|
usage
|
||||||
else
|
else
|
||||||
@@ -200,12 +185,14 @@ fi
|
|||||||
|
|
||||||
# Handle sub-commands.
|
# Handle sub-commands.
|
||||||
case "${CMD}" in
|
case "${CMD}" in
|
||||||
# Commands that don't allow parallel mode
|
# 38 total commands
|
||||||
bootstrap| \
|
bootstrap| \
|
||||||
clone| \
|
clone| \
|
||||||
cmd| \
|
cmd| \
|
||||||
|
config| \
|
||||||
console| \
|
console| \
|
||||||
convert| \
|
convert| \
|
||||||
|
cp| \
|
||||||
create| \
|
create| \
|
||||||
destroy| \
|
destroy| \
|
||||||
edit| \
|
edit| \
|
||||||
@@ -213,38 +200,30 @@ case "${CMD}" in
|
|||||||
export| \
|
export| \
|
||||||
htop| \
|
htop| \
|
||||||
import| \
|
import| \
|
||||||
|
jcp| \
|
||||||
limits| \
|
limits| \
|
||||||
list| \
|
list| \
|
||||||
migrate| \
|
migrate| \
|
||||||
|
mount| \
|
||||||
network| \
|
network| \
|
||||||
pkg| \
|
pkg| \
|
||||||
rcp| \
|
rcp| \
|
||||||
rdr| \
|
rdr| \
|
||||||
rename| \
|
rename| \
|
||||||
|
restart| \
|
||||||
service| \
|
service| \
|
||||||
setup| \
|
setup| \
|
||||||
top| \
|
|
||||||
update| \
|
|
||||||
upgrade| \
|
|
||||||
verify| \
|
|
||||||
zfs)
|
|
||||||
if [ "${bastille_parallel_mode}" -eq 1 ]; then
|
|
||||||
error_exit "Command does not support parallel mode: ${CMD}"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
# Commands that allow parallel mode
|
|
||||||
config| \
|
|
||||||
cp| \
|
|
||||||
jcp| \
|
|
||||||
limits| \
|
|
||||||
mount| \
|
|
||||||
restart| \
|
|
||||||
start| \
|
start| \
|
||||||
stop| \
|
stop| \
|
||||||
sysrc| \
|
sysrc| \
|
||||||
tags| \
|
tags| \
|
||||||
template| \
|
template| \
|
||||||
umount)
|
top| \
|
||||||
|
umount| \
|
||||||
|
update| \
|
||||||
|
upgrade| \
|
||||||
|
verify| \
|
||||||
|
zfs)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
usage
|
usage
|
||||||
|
|||||||
@@ -29,25 +29,46 @@ rcvar=${name}_enable
|
|||||||
: ${bastille_conf:="/usr/local/etc/bastille/bastille.conf"}
|
: ${bastille_conf:="/usr/local/etc/bastille/bastille.conf"}
|
||||||
: ${bastille_startup_delay:=0}
|
: ${bastille_startup_delay:=0}
|
||||||
: ${bastille_parallel_limit:=1}
|
: ${bastille_parallel_limit:=1}
|
||||||
|
: ${bastille_jail_list:=ALL}
|
||||||
|
|
||||||
command=/usr/local/bin/${name}
|
command=/usr/local/bin/${name}
|
||||||
start_cmd="bastille_start"
|
start_cmd="bastille_start"
|
||||||
stop_cmd="bastille_stop"
|
stop_cmd="bastille_stop"
|
||||||
restart_cmd="bastille_restart"
|
restart_cmd="bastille_restart"
|
||||||
|
|
||||||
bastille_start()
|
list_jails() {
|
||||||
{
|
local _jailsdir=$(. $bastille_conf; echo $bastille_jailsdir)
|
||||||
${command} -p ${bastille_parallel_limit} start --boot --delay ${bastille_startup_delay} ALL
|
local _jail_list=$(find ${_jailsdir}/* -mindepth 1 -maxdepth 1 -type f -name jail.conf | xargs -n1 dirname | xargs -n1 basename)
|
||||||
|
for _jail in ${_jail_list}; do
|
||||||
|
_priority="$(sysrc -f ${_jailsdir}/${_jail}/settings.conf -n priority)"
|
||||||
|
echo "${_jail} ${_priority}"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
bastille_stop()
|
sort_jails() {
|
||||||
{
|
local _order="${1}"
|
||||||
${command} -p ${bastille_parallel_limit} stop ALL
|
if [ "${_order}" = "forward" ]; then
|
||||||
|
bastille_jail_list="$(list_jails | sort -k2 -n | awk '{print $1}')"
|
||||||
|
elif [ "${_order}" = "reverse" ]; then
|
||||||
|
bastille_jail_list="$(list_jails | sort -k2 -nr | awk '{print $1}')"
|
||||||
|
else
|
||||||
|
echo "[ERROR]: Fatal error, could not get jail list."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
bastille_restart()
|
bastille_start() {
|
||||||
{
|
sort_jails "forward"
|
||||||
${command} -p ${bastille_parallel_limit} restart --boot --delay ${bastille_startup_delay} ALL
|
echo "${bastille_jail_list}" | xargs -P ${bastille_parallel_limit} -I JAIL ${command} start --boot --delay ${bastille_startup_delay} JAIL
|
||||||
|
}
|
||||||
|
|
||||||
|
bastille_stop() {
|
||||||
|
sort_jails "reverse"
|
||||||
|
echo "${bastille_jail_list}" | xargs -P ${bastille_parallel_limit} -I JAIL ${command} stop JAIL
|
||||||
|
}
|
||||||
|
|
||||||
|
bastille_restart() {
|
||||||
|
sort_jails "forward"
|
||||||
|
echo "${bastille_jail_list}" | xargs -P ${bastille_parallel_limit} -I JAIL ${command} restart --boot --delay ${bastille_startup_delay} JAIL
|
||||||
}
|
}
|
||||||
|
|
||||||
load_rc_config ${name}
|
load_rc_config ${name}
|
||||||
|
|||||||
@@ -84,10 +84,7 @@ bastille_root_check
|
|||||||
|
|
||||||
TARGET="${1}"
|
TARGET="${1}"
|
||||||
shift 1
|
shift 1
|
||||||
|
ERRORS=0
|
||||||
# Use mktemp to store exit codes
|
|
||||||
export TMP_BASTILLE_EXIT_CODE="$(mktemp)"
|
|
||||||
echo 0 > "${TMP_BASTILLE_EXIT_CODE}"
|
|
||||||
|
|
||||||
set_target "${TARGET}"
|
set_target "${TARGET}"
|
||||||
|
|
||||||
@@ -110,9 +107,15 @@ for _jail in ${JAILS}; do
|
|||||||
else
|
else
|
||||||
jexec -l -U root "${_jail}" "$@"
|
jexec -l -U root "${_jail}" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bastille_check_exit_code "${_jail}" "$?"
|
if [ "$?" -ne 0 ]; then
|
||||||
|
ERRORS=$((ERRORS + 1))
|
||||||
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
bastille_return_exit_code
|
if [ "${ERRORS}" -ne 0 ]; then
|
||||||
|
error_exit "[ERROR]: Command failed on ${ERRORS} jails."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
@@ -93,54 +93,6 @@ warn() {
|
|||||||
echo -e "${COLOR_YELLOW}$*${COLOR_RESET}"
|
echo -e "${COLOR_YELLOW}$*${COLOR_RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function checks and adds any error code
|
|
||||||
# that is not "0" to the tmp file
|
|
||||||
bastille_check_exit_code() {
|
|
||||||
|
|
||||||
local jail="${1}"
|
|
||||||
local exit_code="${2}"
|
|
||||||
|
|
||||||
# Set exit code variable
|
|
||||||
if [ -z "${TMP_BASTILLE_EXIT_CODE}" ]; then
|
|
||||||
error_exit "[ERROR]: Exit code status not set."
|
|
||||||
else
|
|
||||||
local old_exit_code="$(cat ${TMP_BASTILLE_EXIT_CODE})"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${exit_code}" -ne 0 ]; then
|
|
||||||
local new_exit_code="$(( ${old_exit_code} + ${exit_code} ))"
|
|
||||||
echo "${new_exit_code}" > "${TMP_BASTILLE_EXIT_CODE}"
|
|
||||||
error_notify "[ERROR CODE]: ${exit_code}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# This needs to be the last function called
|
|
||||||
# if used on any command
|
|
||||||
bastille_return_exit_code() {
|
|
||||||
|
|
||||||
local exit_code="$(cat ${TMP_BASTILLE_EXIT_CODE})"
|
|
||||||
|
|
||||||
rm -f ${TMP_BASTILLE_EXIT_CODE}
|
|
||||||
return "${exit_code}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Parallel mode, don't exceed process limit
|
|
||||||
bastille_running_jobs() {
|
|
||||||
|
|
||||||
_process_limit="${1}"
|
|
||||||
_running_jobs=$((_running_jobs + 1))
|
|
||||||
|
|
||||||
if [ "${_running_jobs}" -ge "${_process_limit}" ]; then
|
|
||||||
|
|
||||||
# Wait for at least one process to finish
|
|
||||||
wait 2>/dev/null || wait
|
|
||||||
|
|
||||||
_running_jobs=$((_running_jobs - 1))
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
check_target_exists() {
|
check_target_exists() {
|
||||||
local _TARGET="${1}"
|
local _TARGET="${1}"
|
||||||
local _jaillist="$(bastille list jails)"
|
local _jaillist="$(bastille list jails)"
|
||||||
|
|||||||
@@ -88,13 +88,12 @@ shift 2
|
|||||||
set_target "${TARGET}"
|
set_target "${TARGET}"
|
||||||
|
|
||||||
case "${ACTION}" in
|
case "${ACTION}" in
|
||||||
get)
|
get|remove)
|
||||||
if [ "$#" -ne 1 ]; then
|
if [ "$#" -ne 1 ]; then
|
||||||
error_notify 'Too many parameters for [get|remove] operation.'
|
error_exit "[ERROR]: Too many parameters for [get|remove] operation."
|
||||||
usage
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
add|set|remove)
|
add|set)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
error_exit "[ERROR]: Only (add|set), get and remove are supported."
|
error_exit "[ERROR]: Only (add|set), get and remove are supported."
|
||||||
@@ -125,8 +124,6 @@ print_jail_conf() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
|
|
||||||
(
|
|
||||||
|
|
||||||
# Backwards compatibility for specifying only an IP with ip[4|6].addr
|
# Backwards compatibility for specifying only an IP with ip[4|6].addr
|
||||||
if [ "${ACTION}" = "set" ] && [ "${PROPERTY}" = "ip4.addr" ]; then
|
if [ "${ACTION}" = "set" ] && [ "${PROPERTY}" = "ip4.addr" ]; then
|
||||||
@@ -310,13 +307,8 @@ for _jail in ${JAILS}; do
|
|||||||
rm "${_tmpfile}"
|
rm "${_tmpfile}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
) &
|
|
||||||
|
|
||||||
bastille_running_jobs "${bastille_process_limit}"
|
|
||||||
|
|
||||||
done
|
done
|
||||||
wait
|
|
||||||
|
|
||||||
# Only display this message once at the end (not for every jail). -- cwells
|
# Only display this message once at the end (not for every jail). -- cwells
|
||||||
if { [ "${ACTION}" = "set" ] || [ "${ACTION}" = "remove" ]; } && [ "${BASTILLE_PROPERTY}" -eq 0 ]; then
|
if { [ "${ACTION}" = "set" ] || [ "${ACTION}" = "remove" ]; } && [ "${BASTILLE_PROPERTY}" -eq 0 ]; then
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ for _jail in ${JAILS}; do
|
|||||||
else
|
else
|
||||||
check_fib "${_jail}"
|
check_fib "${_jail}"
|
||||||
LOGIN="$(jexec -l "${_jail}" which login)"
|
LOGIN="$(jexec -l "${_jail}" which login)"
|
||||||
${_setfib} jexec -l "${_jail}" $LOGIN -f root
|
${_setfib} jexec -l "${_jail}" ${LOGIN} -f root
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -83,26 +83,25 @@ fi
|
|||||||
TARGET="${1}"
|
TARGET="${1}"
|
||||||
HOST_PATH="${2}"
|
HOST_PATH="${2}"
|
||||||
JAIL_PATH="${3}"
|
JAIL_PATH="${3}"
|
||||||
|
ERRORS=0
|
||||||
|
|
||||||
bastille_root_check
|
bastille_root_check
|
||||||
set_target "${TARGET}"
|
set_target "${TARGET}"
|
||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
|
|
||||||
(
|
|
||||||
|
|
||||||
info "\n[${_jail}]:"
|
info "\n[${_jail}]:"
|
||||||
|
|
||||||
host_path="${HOST_PATH}"
|
host_path="${HOST_PATH}"
|
||||||
jail_path="$(echo ${bastille_jailsdir}/${_jail}/root/${JAIL_PATH} | sed 's#//#/#g')"
|
jail_path="$(echo ${bastille_jailsdir}/${_jail}/root/${JAIL_PATH} | sed 's#//#/#g')"
|
||||||
|
|
||||||
if ! cp "${OPTION}" "${host_path}" "${jail_path}"; then
|
if ! cp "${OPTION}" "${host_path}" "${jail_path}"; then
|
||||||
|
ERRORS=$((ERRORS + 1))
|
||||||
error_continue "[ERROR]: CP failed: ${host_path} -> ${jail_path}"
|
error_continue "[ERROR]: CP failed: ${host_path} -> ${jail_path}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
) &
|
|
||||||
|
|
||||||
bastille_running_jobs "${bastille_process_limit}"
|
|
||||||
|
|
||||||
done
|
done
|
||||||
wait
|
|
||||||
|
if [ "${ERRORS}" -ne 0 ]; then
|
||||||
|
error_exit "[ERROR]: Command failed on ${ERRORS} jails."
|
||||||
|
fi
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ SOURCE_TARGET="${1}"
|
|||||||
SOURCE_PATH="${2}"
|
SOURCE_PATH="${2}"
|
||||||
DEST_TARGET="${3}"
|
DEST_TARGET="${3}"
|
||||||
DEST_PATH="${4}"
|
DEST_PATH="${4}"
|
||||||
|
ERRORS=0
|
||||||
|
|
||||||
bastille_root_check
|
bastille_root_check
|
||||||
set_target_single "${SOURCE_TARGET}" && SOURCE_TARGET="${TARGET}"
|
set_target_single "${SOURCE_TARGET}" && SOURCE_TARGET="${TARGET}"
|
||||||
@@ -91,8 +92,6 @@ set_target "${DEST_TARGET}" && DEST_TARGET="${JAILS}"
|
|||||||
|
|
||||||
for _jail in ${DEST_TARGET}; do
|
for _jail in ${DEST_TARGET}; do
|
||||||
|
|
||||||
(
|
|
||||||
|
|
||||||
if [ "${_jail}" = "${SOURCE_TARGET}" ]; then
|
if [ "${_jail}" = "${SOURCE_TARGET}" ]; then
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
@@ -103,14 +102,14 @@ for _jail in ${DEST_TARGET}; do
|
|||||||
dest_path="$(echo ${bastille_jailsdir}/${_jail}/root/${DEST_PATH} | sed 's#//#/#g')"
|
dest_path="$(echo ${bastille_jailsdir}/${_jail}/root/${DEST_PATH} | sed 's#//#/#g')"
|
||||||
|
|
||||||
if ! cp "${OPTION}" "${source_path}" "${dest_path}"; then
|
if ! cp "${OPTION}" "${source_path}" "${dest_path}"; then
|
||||||
|
ERRORS=$((ERRORS + 1))
|
||||||
error_continue "[ERROR]: JCP failed: ${source_path} -> ${dest_path}"
|
error_continue "[ERROR]: JCP failed: ${source_path} -> ${dest_path}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
) &
|
|
||||||
|
|
||||||
bastille_running_jobs "${bastille_process_limit}"
|
|
||||||
|
|
||||||
done
|
done
|
||||||
wait
|
|
||||||
|
if [ "${ERRORS}" -ne 0 ]; then
|
||||||
|
error_exit "[ERROR]: Command failed on ${ERRORS} jails."
|
||||||
|
fi
|
||||||
@@ -139,8 +139,6 @@ add_cpuset() {
|
|||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
|
|
||||||
(
|
|
||||||
|
|
||||||
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
||||||
bastille start "${_jail}"
|
bastille start "${_jail}"
|
||||||
else
|
else
|
||||||
@@ -301,10 +299,5 @@ for _jail in ${JAILS}; do
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
) &
|
|
||||||
|
|
||||||
bastille_running_jobs "${bastille_process_limit}"
|
done
|
||||||
|
|
||||||
done
|
|
||||||
wait
|
|
||||||
@@ -144,8 +144,6 @@ fi
|
|||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
|
|
||||||
(
|
|
||||||
|
|
||||||
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
||||||
bastille start "${_jail}"
|
bastille start "${_jail}"
|
||||||
else
|
else
|
||||||
@@ -202,10 +200,5 @@ for _jail in ${JAILS}; do
|
|||||||
echo "${_fstab_entry}" >> "${bastille_jailsdir}/${_jail}/fstab" || error_continue "Failed to create fstab entry: ${_fstab_entry}"
|
echo "${_fstab_entry}" >> "${bastille_jailsdir}/${_jail}/fstab" || error_continue "Failed to create fstab entry: ${_fstab_entry}"
|
||||||
mount -F "${bastille_jailsdir}/${_jail}/fstab" -a || error_continue "Failed to mount volume: ${_fullpath}"
|
mount -F "${bastille_jailsdir}/${_jail}/fstab" -a || error_continue "Failed to mount volume: ${_fullpath}"
|
||||||
echo "Added: ${_fstab_entry}"
|
echo "Added: ${_fstab_entry}"
|
||||||
|
|
||||||
) &
|
|
||||||
|
|
||||||
bastille_running_jobs "${bastille_process_limit}"
|
|
||||||
|
|
||||||
done
|
done
|
||||||
wait
|
|
||||||
|
|||||||
@@ -96,14 +96,12 @@ fi
|
|||||||
|
|
||||||
TARGET="${1}"
|
TARGET="${1}"
|
||||||
shift
|
shift
|
||||||
# Use mktemp to store exit codes
|
ERRORS=0
|
||||||
export TMP_BASTILLE_EXIT_CODE="$(mktemp)"
|
|
||||||
echo 0 > "${TMP_BASTILLE_EXIT_CODE}"
|
|
||||||
|
|
||||||
bastille_root_check
|
bastille_root_check
|
||||||
set_target "${TARGET}"
|
set_target "${TARGET}"
|
||||||
|
|
||||||
pkg_run_command() {
|
for _jail in ${JAILS}; do
|
||||||
|
|
||||||
# Validate jail state
|
# Validate jail state
|
||||||
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
||||||
@@ -136,12 +134,14 @@ pkg_run_command() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bastille_check_exit_code "${_jail}" "$?"
|
if [ "$?" -ne 0 ]; then
|
||||||
}
|
ERRORS=$((ERRORS + 1))
|
||||||
|
fi
|
||||||
for _jail in ${JAILS}; do
|
|
||||||
pkg_run_command "$@"
|
|
||||||
done
|
done
|
||||||
echo
|
|
||||||
|
|
||||||
bastille_return_exit_code
|
if [ "${ERRORS}" -ne 0 ]; then
|
||||||
|
error_exit "[ERROR]: Command failed on ${ERRORS} jails."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
@@ -112,17 +112,12 @@ set_target "${TARGET}"
|
|||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
|
|
||||||
(
|
|
||||||
|
|
||||||
# Only restart running jails
|
# Only restart running jails
|
||||||
if check_target_is_running "${_jail}"; then
|
if check_target_is_running "${_jail}"; then
|
||||||
bastille stop ${_stop_options} ${_jail}
|
bastille stop ${_stop_options} ${_jail}
|
||||||
bastille start ${_start_options} ${_jail}
|
bastille start ${_start_options} ${_jail}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
) &
|
|
||||||
|
|
||||||
bastille_running_jobs "${bastille_process_limit}"
|
|
||||||
|
|
||||||
done
|
done
|
||||||
wait
|
|
||||||
|
echo
|
||||||
@@ -82,9 +82,7 @@ fi
|
|||||||
|
|
||||||
TARGET="${1}"
|
TARGET="${1}"
|
||||||
shift
|
shift
|
||||||
# Use mktemp to store exit codes
|
ERRORS=0
|
||||||
export TMP_BASTILLE_EXIT_CODE="$(mktemp)"
|
|
||||||
echo 0 > "${TMP_BASTILLE_EXIT_CODE}"
|
|
||||||
|
|
||||||
bastille_root_check
|
bastille_root_check
|
||||||
set_target "${TARGET}"
|
set_target "${TARGET}"
|
||||||
@@ -104,9 +102,14 @@ for _jail in ${JAILS}; do
|
|||||||
|
|
||||||
jexec -l "${_jail}" /usr/sbin/service "$@"
|
jexec -l "${_jail}" /usr/sbin/service "$@"
|
||||||
|
|
||||||
bastille_check_exit_code "${_jail}" "$?"
|
if [ "$?" -ne 0 ]; then
|
||||||
|
ERRORS=$((ERRORS + 1))
|
||||||
done
|
fi
|
||||||
echo
|
|
||||||
|
|
||||||
bastille_return_exit_code
|
done
|
||||||
|
|
||||||
|
if [ "${ERRORS}" -ne 0 ]; then
|
||||||
|
error_exit "[ERROR]: Command failed on ${ERRORS} jails."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
@@ -104,8 +104,6 @@ set_target "${TARGET}"
|
|||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
|
|
||||||
(
|
|
||||||
|
|
||||||
# Continue if '-b|--boot' is set and 'boot=off'
|
# Continue if '-b|--boot' is set and 'boot=off'
|
||||||
if [ "${BOOT}" -eq 1 ]; then
|
if [ "${BOOT}" -eq 1 ]; then
|
||||||
BOOT_ENABLED="$(sysrc -f ${bastille_jailsdir}/${_jail}/settings.conf -n boot)"
|
BOOT_ENABLED="$(sysrc -f ${bastille_jailsdir}/${_jail}/settings.conf -n boot)"
|
||||||
@@ -219,10 +217,5 @@ for _jail in ${JAILS}; do
|
|||||||
|
|
||||||
# Delay between jail action
|
# Delay between jail action
|
||||||
sleep "${DELAY_TIME}"
|
sleep "${DELAY_TIME}"
|
||||||
|
|
||||||
) &
|
|
||||||
|
|
||||||
bastille_running_jobs "${bastille_process_limit}"
|
done
|
||||||
|
|
||||||
done
|
|
||||||
wait
|
|
||||||
@@ -87,8 +87,6 @@ set_target "${TARGET}" "reverse"
|
|||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
|
|
||||||
(
|
|
||||||
|
|
||||||
# Validate that all jails that 'depend' on this one are stopped
|
# Validate that all jails that 'depend' on this one are stopped
|
||||||
for _depend_jail in $(ls --color=never ${bastille_jailsdir} | sed -e 's/\n//g'); do
|
for _depend_jail in $(ls --color=never ${bastille_jailsdir} | sed -e 's/\n//g'); do
|
||||||
if ! grep -hoqsw "depend=" ${bastille_jailsdir}/${_depend_jail}/settings.conf; then
|
if ! grep -hoqsw "depend=" ${bastille_jailsdir}/${_depend_jail}/settings.conf; then
|
||||||
@@ -161,9 +159,4 @@ for _jail in ${JAILS}; do
|
|||||||
|
|
||||||
update_jail_syntax_v1 "${_jail}"
|
update_jail_syntax_v1 "${_jail}"
|
||||||
|
|
||||||
) &
|
|
||||||
|
|
||||||
bastille_running_jobs "${bastille_process_limit}"
|
|
||||||
|
|
||||||
done
|
done
|
||||||
wait
|
|
||||||
|
|||||||
@@ -82,17 +82,13 @@ fi
|
|||||||
|
|
||||||
TARGET="${1}"
|
TARGET="${1}"
|
||||||
shift
|
shift
|
||||||
# Use mktemp to store exit codes
|
ERRORS=0
|
||||||
export TMP_BASTILLE_EXIT_CODE="$(mktemp)"
|
|
||||||
echo 0 > "${TMP_BASTILLE_EXIT_CODE}"
|
|
||||||
|
|
||||||
bastille_root_check
|
bastille_root_check
|
||||||
set_target "${TARGET}"
|
set_target "${TARGET}"
|
||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
|
|
||||||
(
|
|
||||||
|
|
||||||
# Validate jail state
|
# Validate jail state
|
||||||
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
||||||
bastille start "${_jail}"
|
bastille start "${_jail}"
|
||||||
@@ -106,14 +102,14 @@ for _jail in ${JAILS}; do
|
|||||||
|
|
||||||
jexec -l "${_jail}" /usr/sbin/sysrc "$@"
|
jexec -l "${_jail}" /usr/sbin/sysrc "$@"
|
||||||
|
|
||||||
bastille_check_exit_code "${_jail}" "$?"
|
if [ "$?" -ne 0 ]; then
|
||||||
|
ERRORS=$((ERRORS + 1))
|
||||||
) &
|
fi
|
||||||
|
|
||||||
bastille_running_jobs "${bastille_process_limit}"
|
|
||||||
|
|
||||||
done
|
done
|
||||||
wait
|
|
||||||
echo
|
|
||||||
|
|
||||||
bastille_return_exit_code
|
if [ "${ERRORS}" -ne 0 ]; then
|
||||||
|
error_exit "[ERROR]: Command failed on ${ERRORS} jails."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
@@ -77,8 +77,6 @@ set_target "${TARGET}"
|
|||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
|
|
||||||
(
|
|
||||||
|
|
||||||
bastille_jail_tags="${bastille_jailsdir}/${_jail}/tags"
|
bastille_jail_tags="${bastille_jailsdir}/${_jail}/tags"
|
||||||
case ${ACTION} in
|
case ${ACTION} in
|
||||||
add)
|
add)
|
||||||
@@ -120,9 +118,4 @@ for _jail in ${JAILS}; do
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
) &
|
|
||||||
|
|
||||||
bastille_running_jobs "${bastille_process_limit}"
|
|
||||||
|
|
||||||
done
|
done
|
||||||
wait
|
|
||||||
|
|||||||
@@ -272,8 +272,6 @@ fi
|
|||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
|
|
||||||
(
|
|
||||||
|
|
||||||
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
||||||
bastille start "${_jail}"
|
bastille start "${_jail}"
|
||||||
else
|
else
|
||||||
@@ -475,10 +473,5 @@ for _jail in ${JAILS}; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
info "\nTemplate applied: ${TEMPLATE}"
|
info "\nTemplate applied: ${TEMPLATE}"
|
||||||
|
|
||||||
) &
|
|
||||||
|
|
||||||
bastille_running_jobs "${bastille_process_limit}"
|
|
||||||
|
|
||||||
done
|
done
|
||||||
wait
|
|
||||||
|
|||||||
@@ -88,8 +88,6 @@ set_target "${TARGET}"
|
|||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
|
|
||||||
(
|
|
||||||
|
|
||||||
# Validate jail state
|
# Validate jail state
|
||||||
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
check_target_is_running "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
||||||
bastille start "${_jail}"
|
bastille start "${_jail}"
|
||||||
@@ -130,9 +128,6 @@ for _jail in ${JAILS}; do
|
|||||||
|
|
||||||
echo "Unmounted: ${_jailpath}"
|
echo "Unmounted: ${_jailpath}"
|
||||||
|
|
||||||
) &
|
|
||||||
|
|
||||||
bastille_running_jobs "${bastille_process_limit}"
|
|
||||||
|
|
||||||
done
|
done
|
||||||
wait
|
|
||||||
|
echo
|
||||||
Reference in New Issue
Block a user