mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-22 18:21:53 +01:00
Update migrate.sh
This commit is contained in:
@@ -159,14 +159,14 @@ migrate_jail() {
|
|||||||
|
|
||||||
# Verify jail does not exist remotely
|
# Verify jail does not exist remotely
|
||||||
if echo ${_remote_jail_list} | grep -Eoq "^${TARGET}$"; then
|
if echo ${_remote_jail_list} | grep -Eoq "^${TARGET}$"; then
|
||||||
migrate_cleanup "${_jail}"
|
migrate_cleanup "${_jail}" "${_user}" "${_host}"
|
||||||
error_exit "[ERROR]: Jail already exists on remote system: ${TARGET}"
|
error_exit "[ERROR]: Jail already exists on remote system: ${TARGET}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify ZFS on both systems
|
# Verify ZFS on both systems
|
||||||
if checkyesno bastille_zfs_enable; then
|
if checkyesno bastille_zfs_enable; then
|
||||||
if ! checkyesno _remote_bastille_zfs_enable; then
|
if ! checkyesno _remote_bastille_zfs_enable; then
|
||||||
migrate_cleanup "${_jail}"
|
migrate_cleanup "${_jail}" "${_user}" "${_host}"
|
||||||
error_notify "[ERROR]: ZFS is enabled locally, but not remotely."
|
error_notify "[ERROR]: ZFS is enabled locally, but not remotely."
|
||||||
error_exit "Enable ZFS remotely to continue."
|
error_exit "Enable ZFS remotely to continue."
|
||||||
else
|
else
|
||||||
@@ -178,19 +178,19 @@ migrate_jail() {
|
|||||||
|
|
||||||
# Send sha256
|
# Send sha256
|
||||||
if ! scp ${bastille_migratedir}/${_file_sha256} ${_user}@${_host}:${_remote_bastille_migratedir}; then
|
if ! scp ${bastille_migratedir}/${_file_sha256} ${_user}@${_host}:${_remote_bastille_migratedir}; then
|
||||||
migrate_cleanup "${_jail}"
|
migrate_cleanup "${_jail}" "${_user}" "${_host}"
|
||||||
error_exit "[ERROR]: Failed to send jail to remote system."
|
error_exit "[ERROR]: Failed to send jail to remote system."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Send jail export
|
# Send jail export
|
||||||
if ! scp ${bastille_migratedir}/${_file} ${_user}@${_host}:${_remote_bastille_migratedir}; then
|
if ! scp ${bastille_migratedir}/${_file} ${_user}@${_host}:${_remote_bastille_migratedir}; then
|
||||||
migrate_cleanup "${_jail}"
|
migrate_cleanup "${_jail}" "${_user}" "${_host}"
|
||||||
error_exit "[ERROR]: Failed to send jail to remote system."
|
error_exit "[ERROR]: Failed to send jail to remote system."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if checkyesno _remote_bastille_zfs_enable; then
|
if checkyesno _remote_bastille_zfs_enable; then
|
||||||
migrate_cleanup "${_jail}"
|
migrate_cleanup "${_jail}" "${_user}" "${_host}"
|
||||||
error_notify "[ERROR]: ZFS is enabled remotely, but not locally."
|
error_notify "[ERROR]: ZFS is enabled remotely, but not locally."
|
||||||
error_exit "Enable ZFS locally to continue."
|
error_exit "Enable ZFS locally to continue."
|
||||||
else
|
else
|
||||||
@@ -202,13 +202,13 @@ migrate_jail() {
|
|||||||
|
|
||||||
# Send sha256
|
# Send sha256
|
||||||
if ! scp ${bastille_migratedir}/${_file_sha256} ${_user}@${_host}:${_remote_bastille_migratedir}; then
|
if ! scp ${bastille_migratedir}/${_file_sha256} ${_user}@${_host}:${_remote_bastille_migratedir}; then
|
||||||
migrate_cleanup "${_jail}"
|
migrate_cleanup "${_jail}" "${_user}" "${_host}"
|
||||||
error_exit "[ERROR]: Failed to migrate jail to remote system."
|
error_exit "[ERROR]: Failed to migrate jail to remote system."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Send jail export
|
# Send jail export
|
||||||
if ! scp ${bastille_migratedir}/${_file} ${_user}@${_host}:${_remote_bastille_migratedir}; then
|
if ! scp ${bastille_migratedir}/${_file} ${_user}@${_host}:${_remote_bastille_migratedir}; then
|
||||||
migrate_cleanup "${_jail}"
|
migrate_cleanup "${_jail}" "${_user}" "${_host}"
|
||||||
error_exit "[ERROR]: Failed to migrate jail to remote system."
|
error_exit "[ERROR]: Failed to migrate jail to remote system."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -216,7 +216,7 @@ migrate_jail() {
|
|||||||
|
|
||||||
# Import the jail remotely
|
# Import the jail remotely
|
||||||
if ! ssh ${_user}@${_host} sudo bastille import ${_remote_bastille_migratedir}/${_file}; then
|
if ! ssh ${_user}@${_host} sudo bastille import ${_remote_bastille_migratedir}/${_file}; then
|
||||||
migrate_cleanup "${_jail}"
|
migrate_cleanup "${_jail}" "${_user}" "${_host}"
|
||||||
error_exit "[ERROR]: Failed to import jail on remote system."
|
error_exit "[ERROR]: Failed to import jail on remote system."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ migrate_jail() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove archives
|
# Remove archives
|
||||||
migrate_cleanup "${_jail}"
|
migrate_cleanup "${_jail}" "${_user}" "${_host}"
|
||||||
|
|
||||||
# Start new jail if AUTO=1
|
# Start new jail if AUTO=1
|
||||||
if [ "${AUTO}" -eq 1 ]; then
|
if [ "${AUTO}" -eq 1 ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user