- Timestamp:
- 07/31/2026 01:52:04 PM (6 weeks ago)
- Branches:
- main
- Children:
- f434294
- Parents:
- ccaa530
- Location:
- scripts
- Files:
-
- 1 added
- 2 edited
-
install.sh (modified) (1 diff)
-
klonkt-migrate-data.sh (modified) (1 diff)
-
klonkt-refresh-updater.sh (added)
Legend:
- Unmodified
- Added
- Removed
-
scripts/install.sh
rccaa530 r5462bab 305 305 306 306 log "Update command 'klonkt-update'…" 307 cat > /usr/local/bin/klonkt-update <<EOF 308 #!/usr/bin/env bash 309 set -euo pipefail 310 D="${KLONKT_DIR}" 311 B=\$(runuser -u ${KLONKT_USER} -- git -C "\$D" rev-parse HEAD 2>/dev/null || true) 312 runuser -u ${KLONKT_USER} -- git -C "\$D" fetch --depth 1 origin ${KLONKT_BRANCH} 313 runuser -u ${KLONKT_USER} -- git -C "\$D" checkout -qf -B ${KLONKT_BRANCH} FETCH_HEAD 314 A=\$(runuser -u ${KLONKT_USER} -- git -C "\$D" rev-parse HEAD) 315 if [ "\$B" = "\$A" ]; then 316 echo "Klonkt is already up to date (\$A) — nothing to do." 317 exit 0 318 fi 319 if ! runuser -u ${KLONKT_USER} -- git -C "\$D" diff --quiet "\$B" "\$A" -- package-lock.json 2>/dev/null; then 320 runuser -u ${KLONKT_USER} -- env HOME="\$D" bash -c "cd '\$D' && npm ci --omit=dev" 321 fi 322 # Restart every instance. Each directory under the data root with an .env is one 323 # instance sharing this checkout. An install that has not been split yet has no 324 # such directories and still runs the single klonkt.service. 325 N=0 326 for d in ${KLONKT_DATA_ROOT}/*/; do 327 [ -f "\$d/.env" ] || continue 328 s=\$(basename "\$d") 329 systemctl restart "klonkt@\$s" && N=\$((N+1)) 330 done 331 if [ "\$N" = 0 ]; then 332 systemctl restart klonkt 333 echo "Klonkt updated (\$A) + restarted." 334 else 335 echo "Klonkt updated (\$A) + restarted \$N instance(s)." 336 fi 337 EOF 338 chmod +x /usr/local/bin/klonkt-update 307 # Generated by the shared script so an install and a later layout migration 308 # can never drift apart on what the updater restarts. 309 KLONKT_DIR="$KLONKT_DIR" KLONKT_USER="$KLONKT_USER" \ 310 KLONKT_DATA_ROOT="$KLONKT_DATA_ROOT" KLONKT_BRANCH="$KLONKT_BRANCH" \ 311 bash "$KLONKT_DIR/scripts/klonkt-refresh-updater.sh" 339 312 ok "klonkt-update" 340 313 -
scripts/klonkt-migrate-data.sh
rccaa530 r5462bab 135 135 run "systemctl enable --now 'klonkt@$SLUG'" 136 136 137 step "Rewriting klonkt-update for the new layout" 138 # The installer generated an updater that restarts klonkt.service — which we 139 # just retired. Left alone it would keep updating the code while never 140 # restarting the real process: half old, half new, and a 500 with no obvious 141 # cause. Rewrite it so it restarts every klonkt@<slug> instead. 142 if [ -f "$KLONKT_DIR/scripts/klonkt-refresh-updater.sh" ]; then 143 run "KLONKT_DIR='$KLONKT_DIR' KLONKT_USER='$KLONKT_USER' KLONKT_DATA_ROOT='$DATA_ROOT' bash '$KLONKT_DIR/scripts/klonkt-refresh-updater.sh'" 144 else 145 say "WARNING: scripts/klonkt-refresh-updater.sh missing in this checkout." 146 say " Update the code and run it once by hand, or every klonkt-update" 147 say " from now on will update code WITHOUT restarting the process." 148 fi 149 137 150 step "Verifying" 138 151 if [ "$DRY" = 1 ]; then
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)