@@ -90,6 +90,8 @@ function validate_after_copy_defaults() {
9090function start() {
9191 echo " Starting Stellar Quickstart"
9292
93+ validate_persistent_volume_version
94+
9395 echo " versions:"
9496 echo " quickstart: $REVISION "
9597 echo " xdr:"
@@ -327,6 +329,55 @@ function set_pg_password() {
327329
328330}
329331
332+ function validate_persistent_volume_version() {
333+ local version_file=" $STELLAR_HOME /.quickstart-version.json"
334+ if [ -f " $version_file " ]; then
335+ local init_revision=$( < " $version_file " jq -r ' .revision' )
336+ local init_image=$( < " $version_file " jq -r ' .image' )
337+
338+ # Check for mismatch: compare revisions, and images if both are set
339+ local mismatch=false
340+ if [ " $init_revision " != " $REVISION " ]; then
341+ mismatch=true
342+ elif [ -n " $init_image " ] && [ -n " $IMAGE_NAME " ] && [ " $init_image " != " $IMAGE_NAME " ]; then
343+ mismatch=true
344+ fi
345+
346+ if [ " $mismatch " = " true" ]; then
347+ local yellow=$( echo -e " \e[33m" )
348+ local red=$( echo -e " \e[31m" )
349+ local bold=$( echo -e " \e[1m" )
350+ echo " "
351+ echo " ${red}${bold} ╔══════════════════════════════════════════════════════════════════╗${clear} "
352+ echo " ${red}${bold} ║ ⚠️ VERSION MISMATCH WARNING ║${clear} "
353+ echo " ${red}${bold} ╚══════════════════════════════════════════════════════════════════╝${clear} "
354+ echo " "
355+ echo " ${yellow} The persistent volume was initialized with a different version.${clear} "
356+ echo " "
357+ if [ -n " $init_image " ]; then
358+ echo " Initialized with: ${bold} $init_revision ($init_image )${clear} "
359+ else
360+ echo " Initialized with: ${bold} $init_revision ${clear} "
361+ fi
362+ if [ -n " $IMAGE_NAME " ]; then
363+ echo " Running with: ${bold} $REVISION ($IMAGE_NAME )${clear} "
364+ else
365+ echo " Running with: ${bold} $REVISION ${clear} "
366+ fi
367+ echo " "
368+ echo " ${yellow} Persistent volumes may contain incompatible data across versions.${clear} "
369+ echo " "
370+ if [ -n " $init_image " ]; then
371+ echo " To run with the original version:"
372+ echo " ${cyan} docker run ... $init_image ${clear} "
373+ echo " "
374+ fi
375+ echo " To use the new version, remove the persistent volume and start fresh."
376+ echo " "
377+ fi
378+ fi
379+ }
380+
330381function copy_defaults() {
331382 local CP=" rsync -a"
332383
@@ -421,6 +472,18 @@ function copy_defaults() {
421472 $CP /opt/stellar-default/$NETWORK /galexie/ $GALEXIEHOME
422473 fi
423474 fi
475+
476+ # Save version info on first initialization
477+ local version_file=" $STELLAR_HOME /.quickstart-version.json"
478+ if [ ! -f " $version_file " ]; then
479+ jq -n --arg revision " $REVISION " --arg image " $IMAGE_NAME " \
480+ ' {revision: $revision, image: $image}' > " $version_file "
481+ if [ -n " $IMAGE_NAME " ]; then
482+ echo " version: saved $REVISION ($IMAGE_NAME )"
483+ else
484+ echo " version: saved $REVISION "
485+ fi
486+ fi
424487}
425488
426489function copy_pgpass() {
@@ -959,5 +1022,4 @@ function horizon_status() {
9591022 done
9601023 echo " horizon: ingestion caught up"
9611024}
962-
9631025main $@
0 commit comments