Replace the in-flight updatedb and read PRUNEPATHS out of any quoting

The machines this targets are the ones with an updatedb already grinding
through every snapshot, and `systemctl start` on an active unit is a
no-op. updatedb reads /etc/updatedb.conf once at startup, so a run that
began before the rewrite keeps burning CPU on the old config until it
finishes. Restart the service instead: it's Type=oneshot and plocate
builds into a temp db, so nothing is lost by replacing the run.

Quotes are optional in updatedb.conf, so parse the existing paths out of
whatever quoting the file uses and write the setting back in one
canonical form. `PRUNEPATHS=/tmp` previously fell through to the append
branch and got a second PRUNEPATHS line, which drops /tmp from the
pruned set. Comparing whole paths rather than substrings also keeps a
config that already prunes something like /var/lib/machines/.snapshots
from being mistaken for one that prunes /.snapshots.

Prefer $OMARCHY_PATH over the packaged copy when locating the config
script, per docs/migrations.md, so the migration test exercises the
checked-out script rather than whatever release is installed. Skip when
neither exists: omarchy-migrate runs under set -e, so a missing script
would take down every migration queued behind it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
David Heinemeier Hansson
2026-07-26 19:00:02 -07:00
co-authored by Claude Opus 5
parent d548c064ee
commit a6a13cf3e6
4 changed files with 54 additions and 15 deletions
+8 -8
View File
@@ -1,11 +1,7 @@
echo "Configure locate to skip Btrfs snapshots and index Btrfs subvolumes"
OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}"
locate_config_script=/usr/share/omarchy/install/config/locate.sh
if [[ ! -f $locate_config_script ]]; then
locate_config_script="$OMARCHY_PATH/install/config/locate.sh"
fi
locate_config_script="$OMARCHY_PATH/install/config/locate.sh"
UPDATEDB_CONF_PATH="${OMARCHY_UPDATEDB_CONF_PATH:-/etc/updatedb.conf}"
as_root() {
@@ -17,14 +13,18 @@ as_root() {
}
[[ -f $UPDATEDB_CONF_PATH ]] || exit 0
[[ -f $locate_config_script ]] || exit 0
if grep -q '^PRUNE_BIND_MOUNTS = "no"' "$UPDATEDB_CONF_PATH" &&
grep -E '^PRUNEPATHS' "$UPDATEDB_CONF_PATH" | grep -qF '/.snapshots'; then
grep -E '^PRUNEPATHS' "$UPDATEDB_CONF_PATH" | grep -qE '(^|[[:space:]"])/\.snapshots([[:space:]"]|$)'; then
exit 0
fi
as_root env OMARCHY_UPDATEDB_CONF_PATH="$UPDATEDB_CONF_PATH" bash -euo pipefail "$locate_config_script"
# Rebuild the index with the new exclusions; pruning /.snapshots turns
# multi-hour runs on snapshot-heavy systems back into one-minute runs.
as_root systemctl start --no-block plocate-updatedb.service >/dev/null 2>&1 || true
# multi-hour runs on snapshot-heavy systems back into one-minute runs. Restart
# rather than start: the machines this targets are the ones with an updatedb
# already grinding through every snapshot, and a run that started before the
# rewrite keeps using the config it read at startup.
as_root systemctl restart --no-block plocate-updatedb.service >/dev/null 2>&1 || true