Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • scripts/klonkt-migrate-data.sh

    rf434294 r12bed59  
    128128run "systemctl daemon-reload"
    129129
     130step "Retiring $OLD_UNIT"
     131# Stopping and disabling is NOT enough: `systemctl restart klonkt` starts a
     132# disabled unit anyway, and that is exactly what an updater generated before
     133# the split does. A resurrected klonkt.service no longer finds its .env (that
     134# moved with the data), falls back to the built-in defaults, and writes a
     135# FRESH EMPTY database into the checkout.
     136#
     137# Masking does not help either: the unit file lives in /etc/systemd/system,
     138# the highest-priority directory, and `systemctl mask` refuses when a real
     139# file is already there ("File ... already exists"). Verified, not assumed.
     140#
     141# So the file is moved aside. systemd then no longer knows the unit at all and
     142# any restart fails loudly with "Unit klonkt.service not found". The file is
     143# kept next to its old place, timestamped, so a rollback is a move back.
     144if [ -f "/etc/systemd/system/$OLD_UNIT" ]; then
     145  run "systemctl stop $OLD_UNIT 2>/dev/null || true"
     146  run "systemctl disable $OLD_UNIT 2>/dev/null || true"
     147  RETIRED="/etc/systemd/system/${OLD_UNIT}.retired-$(date +%Y%m%d%H%M%S)"
     148  run "mv '/etc/systemd/system/$OLD_UNIT' '$RETIRED'"
     149  run "systemctl daemon-reload"
     150  say "stopped, disabled and moved aside → $RETIRED"
     151  say "roll back by moving that file back and running: systemctl daemon-reload"
     152else
     153  say "no $OLD_UNIT unit file to retire"
     154fi
     155
    130156step "Switching to klonkt@$SLUG"
    131 if systemctl list-unit-files "$OLD_UNIT" >/dev/null 2>&1; then
    132   run "systemctl disable --now $OLD_UNIT"
    133   # Disable only removes the autostart link: `systemctl restart klonkt` would
    134   # still START it. That is not theoretical — an updater generated before the
    135   # split does exactly that, and the resurrected unit finds no .env (it moved
    136   # with the data), falls back to the built-in defaults and creates a FRESH
    137   # EMPTY database in the checkout. Masking makes any such call fail loudly.
    138   # Reversible: systemctl unmask klonkt.
    139   run "systemctl mask $OLD_UNIT"
    140   say "disabled and masked $OLD_UNIT (unmask to roll back)"
    141 fi
    142157run "systemctl enable --now 'klonkt@$SLUG'"
    143158
Note: See TracChangeset for help on using the changeset viewer.