@@ -691,21 +691,80 @@ migrate_from_old_path() {
691
691
return 1
692
692
fi
693
693
694
+ echo " "
695
+ echo " =================================================================="
696
+ echo " PULSE MIGRATION NOTICE"
697
+ echo " =================================================================="
698
+ echo " "
694
699
print_info " Found existing Pulse installation at old path: $OLD_PULSE_DIR "
695
- print_info " Migrating to new path: $PULSE_DIR "
700
+ print_info " This will be automatically migrated to new path: $PULSE_DIR "
701
+ echo " "
702
+ print_info " What will be migrated:"
703
+ print_info " • Application files and data"
704
+ print_info " • Configuration and metrics history"
705
+ print_info " • Systemd service files"
706
+ print_info " • User settings and preferences"
707
+ echo " "
708
+ print_info " A backup will be created at /tmp/pulse-migration-backup-* before migration"
709
+ print_info " Your Pulse service will be briefly stopped during this process"
710
+ echo " "
711
+ read -p " Press Enter to continue with migration, or Ctrl+C to abort..."
712
+ echo " "
696
713
714
+ # Pre-migration validation checks
715
+ print_info " Running pre-migration validation..."
716
+
717
+ # Check if it's a valid Pulse installation
697
718
if [ -f " $OLD_PULSE_DIR /package.json" ] && grep -q ' "name".*"pulse"' " $OLD_PULSE_DIR /package.json" 2> /dev/null; then
698
- print_info " Verified this is a valid Pulse installation. "
719
+ print_info " ✓ Verified this is a valid Pulse installation"
699
720
else
700
- print_error " Directory $OLD_PULSE_DIR exists but does not appear to be a valid Pulse installation."
721
+ print_error " ✗ Directory $OLD_PULSE_DIR exists but does not appear to be a valid Pulse installation."
701
722
print_error " Migration aborted for safety."
702
723
return 1
703
724
fi
704
725
726
+ # Check available disk space (need at least 2x the installation size)
727
+ local old_size=$( du -sm " $OLD_PULSE_DIR " 2> /dev/null | cut -f1)
728
+ local available_space=$( df -m /opt 2> /dev/null | awk ' NR==2 {print $4}' )
729
+ if [ -n " $old_size " ] && [ -n " $available_space " ]; then
730
+ local required_space=$(( old_size * 2 ))
731
+ if [ " $available_space " -lt " $required_space " ]; then
732
+ print_error " ✗ Insufficient disk space for migration"
733
+ print_error " Required: ${required_space} MB, Available: ${available_space} MB"
734
+ return 1
735
+ else
736
+ print_info " ✓ Sufficient disk space available (${available_space} MB)"
737
+ fi
738
+ fi
739
+
740
+ # Check if Pulse service is running and can be stopped
741
+ if systemctl is-active --quiet pulse-monitor.service 2> /dev/null || systemctl is-active --quiet pulse-proxmox.service 2> /dev/null; then
742
+ print_info " ✓ Pulse service is running and will be temporarily stopped during migration"
743
+ fi
744
+
745
+ # Check write permissions to /opt
746
+ if [ ! -w " /opt" ]; then
747
+ print_error " ✗ No write permission to /opt directory"
748
+ return 1
749
+ else
750
+ print_info " ✓ Write permissions confirmed for /opt directory"
751
+ fi
752
+
753
+ # Check if migration was already attempted
754
+ local migration_marker=" /tmp/.pulse-migration-attempted"
755
+ if [ -f " $migration_marker " ]; then
756
+ print_warning " Previous migration attempt detected. Cleaning up and retrying..."
757
+ rm -f " $migration_marker "
758
+ fi
759
+
760
+ # Create migration marker
761
+ touch " $migration_marker "
762
+
705
763
local backup_path=" /tmp/pulse-migration-backup-$( date +%s) "
706
764
print_info " Creating backup at $backup_path before migration..."
707
765
if ! cp -r " $OLD_PULSE_DIR " " $backup_path " ; then
708
766
print_error " Failed to create backup. Migration aborted."
767
+ rm -f " $migration_marker "
709
768
return 1
710
769
fi
711
770
print_success " Backup created successfully."
@@ -752,6 +811,8 @@ migrate_from_old_path() {
752
811
print_success " Old service cleaned up."
753
812
fi
754
813
814
+ # Remove migration marker on success
815
+ rm -f " $migration_marker "
755
816
return 0
756
817
else
757
818
print_error " Failed to move directory. Restoring from backup..."
@@ -760,7 +821,14 @@ migrate_from_old_path() {
760
821
else
761
822
print_error " Failed to restore backup! Original installation may be lost."
762
823
print_error " Backup location: $backup_path "
824
+ print_error " "
825
+ print_error " TROUBLESHOOTING STEPS:"
826
+ print_error " 1. Check disk space: df -h"
827
+ print_error " 2. Check permissions: ls -la /opt/"
828
+ print_error " 3. Manually restore: sudo mv $backup_path $OLD_PULSE_DIR "
829
+ print_error " 4. Check systemctl status pulse-monitor for service issues"
763
830
fi
831
+ rm -f " $migration_marker "
764
832
return 1
765
833
fi
766
834
}
0 commit comments