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>
28 lines
1.2 KiB
Bash
28 lines
1.2 KiB
Bash
UPDATEDB_CONF_PATH="${OMARCHY_UPDATEDB_CONF_PATH:-/etc/updatedb.conf}"
|
|
|
|
echo "Configuring locate to skip Btrfs snapshots and index Btrfs subvolumes"
|
|
|
|
[[ -f $UPDATEDB_CONF_PATH ]] || exit 0
|
|
|
|
# Btrfs subvolume mounts (like /home) look like bind mounts, so pruning
|
|
# bind mounts leaves them out of the index entirely.
|
|
if grep -qE '^PRUNE_BIND_MOUNTS[[:space:]]*=' "$UPDATEDB_CONF_PATH"; then
|
|
sed -i -E 's|^PRUNE_BIND_MOUNTS[[:space:]]*=.*|PRUNE_BIND_MOUNTS = "no"|' "$UPDATEDB_CONF_PATH"
|
|
else
|
|
printf '%s\n' 'PRUNE_BIND_MOUNTS = "no"' >>"$UPDATEDB_CONF_PATH"
|
|
fi
|
|
|
|
# Snapper snapshots are nested subvolumes reached by plain directory
|
|
# traversal, so without this updatedb indexes the system once per snapshot.
|
|
# The quotes are optional in updatedb.conf, so read the paths back out of
|
|
# whatever quoting the file uses and write the setting in one canonical form.
|
|
pruned=$(sed -nE 's|^PRUNEPATHS[[:space:]]*=[[:space:]]*"?([^"]*)"?[[:space:]]*$|\1|p' "$UPDATEDB_CONF_PATH" | tail -n 1)
|
|
|
|
if [[ " $pruned " != *" /.snapshots "* ]]; then
|
|
if [[ -n $pruned ]]; then
|
|
sed -i -E "s|^PRUNEPATHS[[:space:]]*=.*|PRUNEPATHS = \"/.snapshots $pruned\"|" "$UPDATEDB_CONF_PATH"
|
|
else
|
|
printf '%s\n' 'PRUNEPATHS = "/.snapshots"' >>"$UPDATEDB_CONF_PATH"
|
|
fi
|
|
fi
|