mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-21 17:52:01 +01:00
Merge pull request #1042 from BastilleBSD/tschettervictor-patch-1
migrate: Allow live migration
This commit is contained in:
@@ -25,5 +25,6 @@ port by supplying it as in ``user@host:port``.
|
|||||||
-d | --destroy Destroy local jail after migration.
|
-d | --destroy Destroy local jail after migration.
|
||||||
-b | --backup Retain archives on remote system.
|
-b | --backup Retain archives on remote system.
|
||||||
| --doas Use 'doas' instead of 'sudo'.
|
| --doas Use 'doas' instead of 'sudo'.
|
||||||
|
-l | --live Migrate a running jail (ZFS only).
|
||||||
-p | --password Use password based authentication.
|
-p | --password Use password based authentication.
|
||||||
-x | --debug Enable debug mode.
|
-x | --debug Enable debug mode.
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ usage() {
|
|||||||
-b | --backup Retain archives on remote system.
|
-b | --backup Retain archives on remote system.
|
||||||
-d | --destroy Destroy local jail after migration.
|
-d | --destroy Destroy local jail after migration.
|
||||||
| --doas Use 'doas' instead of 'sudo'.
|
| --doas Use 'doas' instead of 'sudo'.
|
||||||
|
-l | --live Migrate a running jail (ZFS only).
|
||||||
-p | --password Use password based authentication.
|
-p | --password Use password based authentication.
|
||||||
-x | --debug Enable debug mode.
|
-x | --debug Enable debug mode.
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ EOF
|
|||||||
|
|
||||||
# Handle options.
|
# Handle options.
|
||||||
AUTO=0
|
AUTO=0
|
||||||
|
LIVE=0
|
||||||
OPT_BACKUP=0
|
OPT_BACKUP=0
|
||||||
OPT_DESTROY=0
|
OPT_DESTROY=0
|
||||||
OPT_PASSWORD=0
|
OPT_PASSWORD=0
|
||||||
@@ -81,6 +83,10 @@ while [ "$#" -gt 0 ]; do
|
|||||||
OPT_SU="doas"
|
OPT_SU="doas"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-l|--live)
|
||||||
|
LIVE=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-p|--password)
|
-p|--password)
|
||||||
OPT_PASSWORD=1
|
OPT_PASSWORD=1
|
||||||
shift
|
shift
|
||||||
@@ -95,6 +101,7 @@ while [ "$#" -gt 0 ]; do
|
|||||||
a) AUTO=1 ;;
|
a) AUTO=1 ;;
|
||||||
b) OPT_BACKUP=1 ;;
|
b) OPT_BACKUP=1 ;;
|
||||||
d) OPT_DESTROY=1 ;;
|
d) OPT_DESTROY=1 ;;
|
||||||
|
l) LIVE=1 ;;
|
||||||
p) OPT_PASSWORD=1 ;;
|
p) OPT_PASSWORD=1 ;;
|
||||||
x) enable_debug ;;
|
x) enable_debug ;;
|
||||||
*) error_exit "[ERROR]: Unknown Option: \"${1}\"" ;;
|
*) error_exit "[ERROR]: Unknown Option: \"${1}\"" ;;
|
||||||
@@ -108,6 +115,13 @@ while [ "$#" -gt 0 ]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Validate options
|
||||||
|
if [ "${LIVE}" -eq 1 ]; then
|
||||||
|
if ! checkyesno bastille_zfs_enable; then
|
||||||
|
error_exit "[ERROR]: [-l|--live] can only be used with ZFS systems."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$#" -ne 2 ]; then
|
if [ "$#" -ne 2 ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
@@ -334,12 +348,18 @@ for _jail in ${JAILS}; do
|
|||||||
(
|
(
|
||||||
|
|
||||||
# Validate jail state
|
# Validate jail state
|
||||||
check_target_is_stopped "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
if [ "${LIVE}" -eq 1 ]; then
|
||||||
bastille stop "${_jail}"
|
if ! check_target_is_running "${_jail}"; then
|
||||||
else
|
error_exit "[ERROR]: [-l|--live] can only be used with a running jail."
|
||||||
info "\n[${_jail}]:"
|
fi
|
||||||
error_notify "Jail is running."
|
elif ! check_target_is_stopped "${_jail}"; then
|
||||||
error_continue "Use [-a|--auto] to auto-stop the jail."
|
if [ "${AUTO}" -eq 1 ]; then
|
||||||
|
bastille stop "${_jail}"
|
||||||
|
else
|
||||||
|
info "\n[${_jail}]:"
|
||||||
|
error_notify "[ERROR]: Jail is running."
|
||||||
|
error_exit "Use [-a|--auto] to auto-stop the jail, or [-l|--live] (ZFS only) to migrate a running jail."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info "\nAttempting to migrate '${_jail}' to '${HOST}'..."
|
info "\nAttempting to migrate '${_jail}' to '${HOST}'..."
|
||||||
|
|||||||
Reference in New Issue
Block a user