mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 21:54:00 +01:00
Two levels of pure taxonomy carrying no information, and a 2-directory
cap leaves no room for them. Categories now sit directly under
linux_configuration/: features, fixes, utils, misc, fresh-install,
installers, diagnostics, gaming, boot_recovery, periodic_background, lib,
meta, tests. A script's own lib/ and tests/ are exempt from the cap, so
those stay put.
Depth violations 248 -> 139; roughly 40 of the remainder are inside
digital_wellbeing and hosts, deferred until the guard-lib repoint.
The moves are the easy half. What breaks is every path that counted
levels, and three classes of it had to be found by resolving paths rather
than reading diffs:
- 52 relative `source` lines for lib/common.sh and lib/android.sh. The
correct prefix differs per file: 40 were ../../ and 12 were ../../../,
so a blanket replace would have fixed one set and broken the other.
- REPO_ROOT in 7 fixes/lib/tests harnesses and setup_syncyomi_guard.sh,
each walking up four levels from a directory now two levels shallower.
This caused a real regression -- the fixes suite went red with
"log_warn: command not found" -- caught by running it and comparing
against the pre-move baseline worktree.
- conftest.py's sys.path entries, which took the pytest gate down with
14 collection errors, and the `# shellcheck source=` directives, which
took shellcheck down with SC1091.
16 symlinks in $HOME broke, including the entire i3blocks bar. All
repointed, and cpu_monitor/memory/disk/time/volume were run to confirm
they emit real output rather than merely resolving.
Verified: 1798 tests pass at 100% coverage, 8 of 9 lib/tests suites pass
(the ninth needs the coverage jail, identically at baseline), pre-commit
is clean, and the two untracked secret configs are still ignored after
their gitignore paths changed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
83 lines
2.8 KiB
Bash
Executable File
83 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Journal, sssd and snap-startup performance fixes.
|
|
#
|
|
# Sourced by fix_ubuntu_performance.sh; split out to keep ubuntu_perf_fixes.sh
|
|
# under the 250-line cap. Sourced rather than run, so it inherits the
|
|
# caller's strict mode and the variables above the source line.
|
|
|
|
# ===================================================================
|
|
# Fix 6: Journal vacuum + permanent size cap
|
|
# ===================================================================
|
|
fix_journal() {
|
|
# Create permanent size cap via drop-in. JOURNALD_CONF_DIR defaults to the
|
|
# real path and is only overridden by the test suite, which must not write
|
|
# to /etc: lib/tests/run_all.sh runs un-jailed in ci_mirror.sh and in CI.
|
|
local dropin_dir="${JOURNALD_CONF_DIR:-/etc/systemd/journald.conf.d}"
|
|
local dropin_file="$dropin_dir/size-limit.conf"
|
|
|
|
if [[ -f $dropin_file ]] && grep -q 'SystemMaxUse=300M' "$dropin_file"; then
|
|
log_ok "Journal size cap already configured — skipping."
|
|
return 0
|
|
fi
|
|
|
|
mkdir -p "$dropin_dir"
|
|
cat >"$dropin_file" <<'JOURNALEOF'
|
|
[Journal]
|
|
SystemMaxUse=300M
|
|
JOURNALEOF
|
|
|
|
# Vacuum existing logs
|
|
journalctl --vacuum-size=300M 2>/dev/null || true
|
|
|
|
systemctl restart systemd-journald
|
|
|
|
add_undo "# Undo: Remove journal size cap"
|
|
add_undo "rm -f /etc/systemd/journald.conf.d/size-limit.conf"
|
|
add_undo "systemctl restart systemd-journald"
|
|
add_undo ""
|
|
return 0
|
|
}
|
|
|
|
# ===================================================================
|
|
# Fix 7: Disable snap-related boot slowness (optional but impactful)
|
|
# ===================================================================
|
|
fix_snap_startup() {
|
|
# Disable snapd.snap-repair.timer - not critical, runs periodically
|
|
if systemctl is-enabled snapd.snap-repair.timer >/dev/null 2>&1; then
|
|
systemctl disable snapd.snap-repair.timer
|
|
systemctl stop snapd.snap-repair.timer 2>/dev/null || true
|
|
|
|
add_undo "# Undo: Re-enable snap repair timer"
|
|
add_undo "systemctl enable snapd.snap-repair.timer"
|
|
add_undo ""
|
|
else
|
|
log_ok "snapd.snap-repair.timer already disabled — skipping."
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
# ===================================================================
|
|
# Undo mode: run the most recent undo script
|
|
# ===================================================================
|
|
run_undo() {
|
|
local latest_undo
|
|
# shellcheck disable=SC2012
|
|
latest_undo=$(ls -1t "${UNDO_DIR:-/root}"/undo_ubuntu_performance_*.sh 2>/dev/null | head -1)
|
|
|
|
if [[ -z ${latest_undo:-} ]]; then
|
|
log_error "No undo script found in ${UNDO_DIR:-/root}/"
|
|
exit 1
|
|
fi
|
|
|
|
log_info "Running undo script: $latest_undo"
|
|
bash "$latest_undo"
|
|
log_ok "All changes reversed."
|
|
log_info "Reboot recommended to ensure all changes take effect."
|
|
exit 0
|
|
}
|
|
|
|
# ===================================================================
|
|
# Apply all fixes
|
|
# ===================================================================
|