mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 18:07:06 +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
109 lines
3.8 KiB
Bash
Executable File
109 lines
3.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Firefox enterprise-policy installation for install_leechblock.sh.
|
|
# Sourced by the installer; inherits its strict mode and info/warn helpers.
|
|
# Reads AUTO_FIREFOX; writes policies.json under system paths.
|
|
#
|
|
# Whether a Firefox-family browser was detected arrives as $1 rather than as
|
|
# the ff_found global the pre-split code used: that global is written in
|
|
# leechblock_browsers.sh, and reading it here would be a cross-file global the
|
|
# linter genuinely cannot resolve (it runs without -x), i.e. a real SC2154
|
|
# rather than noise. Suppressions are forbidden, so the value is passed
|
|
# explicitly instead.
|
|
install_firefox_policy() {
|
|
local ff_found="${1:-0}"
|
|
|
|
# If requested, attempt automatic install on Firefox via enterprise policies
|
|
if [[ $AUTO_FIREFOX -eq 1 && $ff_found -eq 1 ]]; then
|
|
echo
|
|
info "Attempting Firefox auto-install via Enterprise Policies (requires sudo)."
|
|
# AMO info
|
|
ADDON_ID="leechblockng@proginosko.com"
|
|
ADDON_AMO_URL="https://addons.mozilla.org/firefox/downloads/latest/leechblock-ng/latest.xpi"
|
|
|
|
# Determine policy directories for detected Firefox-like browsers
|
|
declare -a POLICY_DIRS
|
|
POLICY_DIRS=()
|
|
if command -v firefox >/dev/null 2>&1; then
|
|
POLICY_DIRS+=("/etc/firefox/policies" "/usr/lib/firefox/distribution")
|
|
fi
|
|
if command -v firefox-developer-edition >/dev/null 2>&1; then
|
|
POLICY_DIRS+=("/etc/firefox-developer-edition/policies" "/usr/lib/firefox-developer-edition/distribution")
|
|
fi
|
|
if command -v librewolf >/dev/null 2>&1; then
|
|
POLICY_DIRS+=("/etc/librewolf/policies" "/usr/lib/librewolf/distribution")
|
|
fi
|
|
# Generic mozilla path as fallback
|
|
POLICY_DIRS+=("/usr/lib/mozilla/distribution")
|
|
|
|
updated_any=0
|
|
for pol_target in "${POLICY_DIRS[@]}"; do
|
|
tmp_pol=$(mktemp)
|
|
existing="${pol_target}/policies.json"
|
|
if sudo test -f "$existing"; then
|
|
info "Merging into existing policies.json at $existing"
|
|
sudo cp "$existing" "$tmp_pol"
|
|
if command -v jq >/dev/null 2>&1; then
|
|
merged=$(jq --arg id "$ADDON_ID" --arg url "$ADDON_AMO_URL" '
|
|
.policies |= (. // {}) |
|
|
.policies.ExtensionSettings |= (. // {}) |
|
|
.policies.ExtensionSettings."*" |= (. // {"installation_mode":"allowed"}) |
|
|
.policies.ExtensionSettings[$id] |= (. // {}) |
|
|
.policies.ExtensionSettings[$id].installation_mode = "force_installed" |
|
|
.policies.ExtensionSettings[$id].install_url = $url
|
|
' "$tmp_pol") || merged=""
|
|
if [[ -n $merged ]]; then
|
|
printf '%s\n' "$merged" >"$tmp_pol"
|
|
else
|
|
warn "jq merge failed; skipping $pol_target"
|
|
rm -f "$tmp_pol"
|
|
continue
|
|
fi
|
|
else
|
|
warn "jq not available; creating minimal policies.json (existing file will be backed up)."
|
|
sudo cp "$existing" "${existing}.bak.$(date +%s)"
|
|
cat >"$tmp_pol" <<JSON
|
|
{
|
|
"policies": {
|
|
"ExtensionSettings": {
|
|
"*": { "installation_mode": "allowed" },
|
|
"$ADDON_ID": {
|
|
"installation_mode": "force_installed",
|
|
"install_url": "$ADDON_AMO_URL"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
JSON
|
|
fi
|
|
else
|
|
info "Creating new policies.json at $pol_target"
|
|
cat >"$tmp_pol" <<JSON
|
|
{
|
|
"policies": {
|
|
"ExtensionSettings": {
|
|
"*": { "installation_mode": "allowed" },
|
|
"$ADDON_ID": {
|
|
"installation_mode": "force_installed",
|
|
"install_url": "$ADDON_AMO_URL"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
JSON
|
|
fi
|
|
|
|
sudo mkdir -p "$pol_target"
|
|
sudo cp "$tmp_pol" "$pol_target/policies.json"
|
|
rm -f "$tmp_pol"
|
|
updated_any=1
|
|
done
|
|
|
|
if [[ $updated_any -eq 1 ]]; then
|
|
info "Firefox policies updated. Restart Firefox/LibreWolf to complete installation of LeechBlock NG."
|
|
else
|
|
warn "No Firefox policy locations updated. You may not have a supported Firefox installed."
|
|
fi
|
|
info "Firefox policy updated. Restart Firefox to complete installation of LeechBlock NG."
|
|
fi
|
|
}
|