Skip to content

Commit 1bca794

Browse files
rcourtmanclaude
andcommitted
enhance: improve migration from /opt/pulse-proxmox to /opt/pulse
- Add comprehensive user notification with migration details - Implement pre-migration validation (disk space, permissions, valid installation) - Add migration status tracking to prevent duplicate attempts - Enhance error messages with detailed troubleshooting steps - Provide interactive confirmation before proceeding 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4b8fdf2 commit 1bca794

File tree

1 file changed

+71
-3
lines changed

1 file changed

+71
-3
lines changed

scripts/install-pulse.sh

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -691,21 +691,80 @@ migrate_from_old_path() {
691691
return 1
692692
fi
693693

694+
echo ""
695+
echo "=================================================================="
696+
echo " PULSE MIGRATION NOTICE"
697+
echo "=================================================================="
698+
echo ""
694699
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 ""
696713

714+
# Pre-migration validation checks
715+
print_info "Running pre-migration validation..."
716+
717+
# Check if it's a valid Pulse installation
697718
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"
699720
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."
701722
print_error "Migration aborted for safety."
702723
return 1
703724
fi
704725

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+
705763
local backup_path="/tmp/pulse-migration-backup-$(date +%s)"
706764
print_info "Creating backup at $backup_path before migration..."
707765
if ! cp -r "$OLD_PULSE_DIR" "$backup_path"; then
708766
print_error "Failed to create backup. Migration aborted."
767+
rm -f "$migration_marker"
709768
return 1
710769
fi
711770
print_success "Backup created successfully."
@@ -752,6 +811,8 @@ migrate_from_old_path() {
752811
print_success "Old service cleaned up."
753812
fi
754813

814+
# Remove migration marker on success
815+
rm -f "$migration_marker"
755816
return 0
756817
else
757818
print_error "Failed to move directory. Restoring from backup..."
@@ -760,7 +821,14 @@ migrate_from_old_path() {
760821
else
761822
print_error "Failed to restore backup! Original installation may be lost."
762823
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"
763830
fi
831+
rm -f "$migration_marker"
764832
return 1
765833
fi
766834
}

0 commit comments

Comments
 (0)