mirror of
https://github.com/hackacad/bastille.git
synced 2026-01-03 19:23:42 +01:00
upgrade: Make sure thin jails are stopped before upgrading
This commit is contained in:
@@ -47,6 +47,7 @@ EOF
|
||||
}
|
||||
|
||||
# Handle options.
|
||||
AUTO=0
|
||||
OPTION=""
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "${1}" in
|
||||
@@ -101,7 +102,7 @@ if freebsd-version | grep -qi HBSD; then
|
||||
error_exit "Not yet supported on HardenedBSD."
|
||||
fi
|
||||
|
||||
jail_check() {
|
||||
thick_jail_check() {
|
||||
# Check if the jail is thick and is running
|
||||
set_target_single "${TARGET}"
|
||||
check_target_is_running "${TARGET}" || if [ "${AUTO}" -eq 1 ]; then
|
||||
@@ -112,6 +113,17 @@ jail_check() {
|
||||
fi
|
||||
}
|
||||
|
||||
thin_jail_check() {
|
||||
# Check if the jail is thick and is running
|
||||
set_target_single "${TARGET}"
|
||||
check_target_is_stopped "${TARGET}" || if [ "${AUTO}" -eq 1 ]; then
|
||||
bastille stop "${TARGET}"
|
||||
else
|
||||
error_notify "Jail is running."
|
||||
error_continue "Use [-a|--auto] to auto-stop the jail."
|
||||
fi
|
||||
}
|
||||
|
||||
release_check() {
|
||||
# Validate the release
|
||||
if ! echo "${NEWRELEASE}" | grep -q "[0-9]\{2\}.[0-9]-[RELEASE,BETA,RC]"; then
|
||||
@@ -175,12 +187,26 @@ jail_updates_install() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if jail is thick or thin
|
||||
THIN_JAIL=0
|
||||
if grep -qw "${bastille_jailsdir}/${TARGET}/root/.bastille" "${bastille_jailsdir}/${TARGET}/fstab"; then
|
||||
THIN_JAIL=1
|
||||
fi
|
||||
|
||||
# Check what we should upgrade
|
||||
if [ "${NEWRELEASE}" = "install" ]; then
|
||||
jail_check
|
||||
if [ "${THIN_JAIL}" -eq 1 ]; then
|
||||
thin_jail_check
|
||||
else
|
||||
thick_jail_check
|
||||
fi
|
||||
jail_updates_install "${TARGET}"
|
||||
else
|
||||
jail_check
|
||||
if [ "${THIN_JAIL}" -eq 1 ]; then
|
||||
thin_jail_check
|
||||
else
|
||||
thick_jail_check
|
||||
fi
|
||||
release_check
|
||||
jail_upgrade "${TARGET}" "${NEWRELEASE}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user