Skip to content

Commit 0db0063

Browse files
JohnMcLearclaude
andcommitted
fix(snap): default seeded settings to sqlite, not dirty
settings.json.template's own comment says dirty is for testing only. A Snap install is the "not testing" case — shipping it by default means every `sudo snap install etherpad-lite` starts on a DB the project explicitly recommends against. Rewrite the postinstall sed to switch dbType: "dirty" → "sqlite" and point filename at $SNAP_COMMON/var/etherpad.db. sqlite is already shipped in-tree via ueberdb2 → rusty-store-kv (prebuilt napi-rs binary, no build deps), so this works under strict confinement with zero snap.yaml changes. Only affects first-run seeding; existing $SNAP_COMMON/etc/settings.json is never touched on refresh. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent bacf79f commit 0db0063

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

snap/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ A few values are exposed as snap config for convenience:
3939
| `snap set etherpad-lite port=9001` | `9001` | Listen port |
4040
| `snap set etherpad-lite ip=0.0.0.0` | `0.0.0.0` | Bind address |
4141

42-
Pad data (dirty DB, logs) lives in `/var/snap/etherpad-lite/common/` and
43-
survives `snap refresh`.
42+
Pad data (sqlite DB at `var/etherpad.db`, logs) lives in
43+
`/var/snap/etherpad-lite/common/` and survives `snap refresh`. The
44+
shipped `settings.json.template` defaults to `dbType: "dirty"`, which
45+
the template itself warns is dev-only; the launch wrapper rewrites the
46+
seeded copy to `sqlite` on first run so users get an ACID-safe DB out
47+
of the box.
4448

4549
## Publish to the Snap Store
4650

snap/local/bin/etherpad-service

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#
44
# 1. On first run, copy settings.json.template -> $SNAP_COMMON/etc/settings.json
55
# so the admin can edit it outside the read-only squashfs. Patch the
6-
# seeded file so dirty-DB / ip / port point at writable paths and pick
7-
# up env-var overrides.
6+
# seeded file so the DB (switched from dev-only dirty to sqlite) / ip /
7+
# port point at writable paths and pick up env-var overrides.
88
# 2. Create writable data dirs under $SNAP_COMMON.
99
# 3. Apply `snap set` overrides (port, ip) via env vars — Etherpad's
1010
# settings.json supports ${PORT:9001}-style substitution natively.
@@ -27,9 +27,13 @@ SETTINGS="${ETC_DIR}/settings.json"
2727
if [ ! -f "${SETTINGS}" ]; then
2828
echo "[etherpad-snap] bootstrapping ${SETTINGS} from template"
2929
cp "${APP_DIR}/settings.json.template" "${SETTINGS}"
30-
# Point the default dirty-DB at $SNAP_COMMON (absolute path, writable).
30+
# Switch the template's dev-only dirty default to sqlite and point it
31+
# at $SNAP_COMMON (absolute path, writable under strict confinement).
32+
# sqlite is shipped by ueberdb2 via the prebuilt rusty-store-kv native
33+
# module — no additional build deps required.
3134
sed -i \
32-
-e 's|"filename": "var/dirty.db"|"filename": "'"${VAR_DIR}"'/dirty.db"|' \
35+
-e 's|"dbType": "dirty"|"dbType": "sqlite"|' \
36+
-e 's|"filename": "var/dirty.db"|"filename": "'"${VAR_DIR}"'/etherpad.db"|' \
3337
"${SETTINGS}"
3438
# Rewrite ip/port literals to Etherpad's env-substitution syntax so
3539
# `snap set etherpad-lite port=<n>` / `ip=<addr>` actually take effect.

0 commit comments

Comments
 (0)