--- vzmigrate.orig 2008-09-10 13:39:06.000000000 +0200 +++ vzmigrate 2008-09-10 15:34:48.000000000 +0200 @@ -52,7 +52,7 @@ # entering a password. -ACT_SCRIPTS_SFX="start stop mount umount" +ACT_SCRIPTS_SFX="start stop mount umount migrate" SSH_OPTIONS="" SSH="ssh $SSH_OPTIONS" SCP_OPTIONS="" @@ -379,7 +379,7 @@ logexec 2 $SSH root@$host vzctl set $VEID --applyconfig_map name --save # vzctl return code 20 or 21 in case of unrecognized option -if [ $? != 20 && $? != 21 && $? != 0 ]; then +if [ $? != 20 ] && [ $? != 21 ] && [ $? != 0 ]; then log 0 "Failed to apply config on destination node" undo_conf exit $MIG_ERR_APPLY_CONFIG @@ -443,6 +443,15 @@ exit $MIG_ERR_COPY fi +if [[ -f "$confdir/$VEID.migrate" ]]; then + log 1 "Executing migrate script" + if ! $confdir/$VEID.migrate 1 "${host}"; then + log 0 "Failed to execute migrate script" + undo_sync + exit $MIG_ERR_COPY + fi +fi + if [ $online -eq 1 ]; then log 1 "Live migrating VE" @@ -495,6 +504,15 @@ undo_source_stage exit $MIG_ERR_COPY fi + + if [[ -f "$confdir/$VEID.migrate" ]]; then + log 2 "Running migrate script (2nd pass)" + if ! $confdir/$VEID.migrate 2 "${host}"; then + log 0 "Failed to run migrate script (2nd pass)" + undo_source_stage + exit $MIG_ERR_COPY + fi + fi fi if [ "${DISK_QUOTA}" != "no" ]; then @@ -590,7 +608,9 @@ if [ $remove_area -eq 1 ]; then log 2 "Destroying VE" logexec 2 vzctl destroy $VEID + [[ -f $confdir/$VEID.migrate ]] && mv -f $confdir/$VEID.migrate $confdir/$VEID.migrate.destroyed else # Move config as veid.migrated to allow backward migration mv -f $vpsconf $vpsconf.migrated + [[ -f $confdir/$VEID.migrate ]] && mv -f $confdir/$VEID.migrate $confdir/$VEID.migrate.migrated fi