diff --git a/bin/omarchy-cn-update b/bin/omarchy-cn-update index 4889a2b1..a5bff24b 100755 --- a/bin/omarchy-cn-update +++ b/bin/omarchy-cn-update @@ -5,7 +5,7 @@ set -euo pipefail MANIFEST="$HOME/.local/state/omarchycn/overlay-manifest" -MIGRATION_STATE="$HOME/.local/state/omarchycn/last-migration" +MIGRATION_DONE_DIR="$HOME/.local/state/omarchycn/migrations-done" if [[ ! -f $MANIFEST ]]; then echo "Not an overlay install (no $MANIFEST)." >&2 @@ -26,20 +26,16 @@ echo "Source: $old -> $new" "$src/bin/omarchy-cn-install-overlay" -# Run migrations newer than the last recorded one, in filename order -last="" -if [[ -f $MIGRATION_STATE ]]; then - last=$(<"$MIGRATION_STATE") -fi - +# Run each not-yet-completed migration in filename order, one marker per file if [[ -d $src/cn/migrations ]]; then + mkdir -p "$MIGRATION_DONE_DIR" for m in "$src"/cn/migrations/*.sh; do [[ -f $m ]] || continue name="${m##*/}" - if [[ $name > $last ]]; then + if [[ ! -f $MIGRATION_DONE_DIR/$name ]]; then echo "Migration: $name" - bash "$m" - echo "$name" > "$MIGRATION_STATE" + bash -euo pipefail "$m" + touch "$MIGRATION_DONE_DIR/$name" fi done fi