mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 00:27:01 +01:00
github.com/kuhyx/android-guardian, cloned to ~/android-guardian
periodic_background/utils/ held two unrelated things: the Magisk module
and heavy_job_lock.sh. Only the module was a unit, so the directory is
split rather than moved.
heavy_job_lock.sh goes to digital_wellbeing/, NOT to ~/utils. Measured
rather than assumed: of its consumers only install_pacman_wrapper.sh
reads the repo copy, while pacman_wrapper.sh, makepkg_capped.sh and
meta/scripts/run_with_heavy_lock.sh all read the installed
/usr/local/bin copy. A library belongs with whoever installs it, and
exporting it would have added a cross-repo edge for one caller.
Fixed a bug that predates the extraction: update_android_hosts.sh set
GUARDIAN_MODULE_DIR to "$SCRIPT_DIR/android_guardian", a sibling that
never existed at that path -- packaging could not have worked from this
checkout at all. It now reads ${ANDROID_GUARDIAN_DIR:-~/android-guardian}
and require_guardian_module() gates build_module(), the single funnel
every packaging path goes through, so a missing checkout names the clone
command instead of failing inside a cp four helpers deep.
Verified both directions: with no checkout the guard fires with
instructions; with one, the module builds -- 182331 blocked domains, a
1.1 MB zip. The subsequent adb push failed on device-side storage, which
this commit does not touch.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
52 lines
1.5 KiB
Bash
Executable File
52 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Building the Magisk hosts module.
|
|
#
|
|
# Sourced by update_android_hosts.sh; split out to keep it under the 250-line cap.
|
|
# Sourced rather than run, so it inherits the caller's strict mode.
|
|
|
|
# Build the module zip
|
|
build_module() {
|
|
local tmp_dir="$WORK_DIR/guardian_module"
|
|
local module_zip="$WORK_DIR/android_guardian.zip"
|
|
|
|
require_guardian_module
|
|
|
|
echo "[BUILD] Building Android Guardian module..." >&2
|
|
|
|
rm -rf "$tmp_dir"
|
|
mkdir -p "$tmp_dir/system/etc"
|
|
|
|
# Copy module files
|
|
cp "$GUARDIAN_MODULE_DIR/module.prop" "$tmp_dir/"
|
|
cp "$GUARDIAN_MODULE_DIR/service.sh" "$tmp_dir/"
|
|
cp "$GUARDIAN_MODULE_DIR/post-fs-data.sh" "$tmp_dir/"
|
|
cp "$GUARDIAN_MODULE_DIR/uninstall.sh" "$tmp_dir/"
|
|
|
|
# Build hosts file
|
|
local hosts_file="$tmp_dir/system/etc/hosts"
|
|
if [[ -f /etc/hosts.stevenblack ]]; then
|
|
echo "[BUILD] Using StevenBlack hosts cache..." >&2
|
|
cp /etc/hosts.stevenblack "$hosts_file"
|
|
elif [[ -f /etc/hosts ]]; then
|
|
echo "[BUILD] Using /etc/hosts..." >&2
|
|
cp /etc/hosts "$hosts_file"
|
|
else
|
|
die "No hosts file found"
|
|
fi
|
|
|
|
# Append custom blocking entries
|
|
# The blocklist is a data file, not a heredoc: 248 lines of hosts
|
|
# entries that belong under data/ where they can be diffed and edited
|
|
# without touching shell.
|
|
cat "$SCRIPT_DIR/data/android_guardian_blocklist.hosts" >>"$hosts_file"
|
|
|
|
local total_entries
|
|
total_entries=$(grep -c "^0\.0\.0\.0 " "$hosts_file" || echo 0)
|
|
echo "[BUILD] Hosts file contains $total_entries blocked domains" >&2
|
|
|
|
# Create zip
|
|
(cd "$tmp_dir" && zip -r "$module_zip" . -x "*.DS_Store") >/dev/null
|
|
|
|
echo "$module_zip"
|
|
}
|