- Timestamp:
- 08/07/2026 04:14:49 PM (5 weeks ago)
- Branches:
- main
- Children:
- f85b2c3
- Parents:
- fa33214
- git-author:
- Robin <roboburr@…> (07/31/2026 02:52:19 PM)
- git-committer:
- Robin <roboburr@…> (08/07/2026 04:14:49 PM)
- Location:
- scripts
- Files:
-
- 2 edited
-
klonkt-migrate-data.sh (modified) (1 diff)
-
klonkt-refresh-updater.sh (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
scripts/klonkt-migrate-data.sh
rfa33214 r12bed59 128 128 run "systemctl daemon-reload" 129 129 130 step "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. 144 if [ -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" 152 else 153 say "no $OLD_UNIT unit file to retire" 154 fi 155 130 156 step "Switching to klonkt@$SLUG" 131 if systemctl list-unit-files "$OLD_UNIT" >/dev/null 2>&1; then132 run "systemctl disable --now $OLD_UNIT"133 # Disable only removes the autostart link: `systemctl restart klonkt` would134 # still START it. That is not theoretical — an updater generated before the135 # split does exactly that, and the resurrected unit finds no .env (it moved136 # with the data), falls back to the built-in defaults and creates a FRESH137 # 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 fi142 157 run "systemctl enable --now 'klonkt@$SLUG'" 143 158 -
scripts/klonkt-refresh-updater.sh
rfa33214 r12bed59 59 59 echo "klonkt-update rewritten: branch ${BRANCH}, code ${KLONKT_DIR}, instances under ${DATA_ROOT}" 60 60 61 # On a split install the old single unit must not be startable. `disable` alone 62 # does not stop `systemctl restart klonkt` from starting it, and a resurrected 63 # klonkt.service has no .env (it moved with the data): it falls back to the 64 # defaults and writes a fresh empty database into the checkout. 61 # On a split install the old single unit must not be startable at all. 62 # `disable` is not enough (restart starts a disabled unit anyway) and `mask` 63 # refuses while the real file sits in /etc/systemd/system, the highest-priority 64 # directory. Moving the file aside is what actually works: systemd stops 65 # knowing the unit, so any restart fails loudly instead of quietly starting a 66 # second process that writes an empty database into the checkout. 65 67 SPLIT=0 66 68 for d in "${DATA_ROOT}"/*/; do [ -f "$d/.env" ] && SPLIT=1 && break; done 67 if [ "$SPLIT" = 1 ] && systemctl list-unit-files klonkt.service >/dev/null 2>&1; then 68 if ! systemctl is-enabled klonkt.service 2>/dev/null | grep -q masked; then 69 systemctl stop klonkt.service 2>/dev/null || true 70 systemctl disable klonkt.service 2>/dev/null || true 71 systemctl mask klonkt.service 72 echo "retired klonkt.service: stopped, disabled and masked (unmask to roll back)" 69 if [ "$SPLIT" = 1 ] && [ -f /etc/systemd/system/klonkt.service ]; then 70 systemctl stop klonkt.service 2>/dev/null || true 71 systemctl disable klonkt.service 2>/dev/null || true 72 RETIRED="/etc/systemd/system/klonkt.service.retired-$(date +%Y%m%d%H%M%S)" 73 if mv /etc/systemd/system/klonkt.service "$RETIRED"; then 74 systemctl daemon-reload 75 echo "retired klonkt.service → $RETIRED (move it back + daemon-reload to roll back)" 76 else 77 echo "WARNING: could not move /etc/systemd/system/klonkt.service aside." 78 echo " Until you do, any 'systemctl restart klonkt' starts a second" 79 echo " process that writes an empty database into ${KLONKT_DIR}." 73 80 fi 74 81 fi
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)