mirror of
https://github.com/kuhyx/scripts.git
synced 2026-07-04 11:43:03 +02:00
- Add common.sh library functions: require_imagemagick, install_missing_pacman_packages, handle_arg_help_or_unknown - Create android.sh shared library for Android utilities - Create hosts-guard-common.sh for pacman hooks shared functions - Update multiple scripts to source common.sh and use shared helpers - Add print_shutdown_schedule helper in setup_midnight_shutdown.sh - Remove duplicate log(), usage(), install_packages patterns across scripts - Format all shell scripts with shfmt (2-space indent)
30 lines
650 B
Bash
30 lines
650 B
Bash
#!/usr/bin/env bash
|
|
# Non-interactive pre-transaction hook to temporarily unlock /etc/hosts
|
|
|
|
set -euo pipefail
|
|
|
|
# Source shared functions
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
# shellcheck source=hosts-guard-common.sh
|
|
source "$SCRIPT_DIR/hosts-guard-common.sh"
|
|
|
|
# Remove protective attributes
|
|
remove_host_attrs
|
|
|
|
# Stop guard services
|
|
stop_units_if_present
|
|
|
|
log_hook "pre" "unlocking(start)"
|
|
|
|
# Collapse any existing mount layers
|
|
collapse_mounts
|
|
|
|
# Ensure writable by remounting if still read-only
|
|
if is_ro_mount; then
|
|
mount -o remount,rw "$TARGET" >/dev/null 2>&1 || collapse_mounts
|
|
fi
|
|
|
|
log_hook "pre" "unlocking(done)"
|
|
|
|
exit 0
|