testsAndMisc/linux_configuration/scripts/periodic_background/system-maintenance/bin/periodic-system-maintenance.sh
Krzysztof kuhy Rudnicki 42a66a1419 refactor(linux_configuration/scripts): split all scripts into single_use/ and periodic_background/
- Move all linux_configuration scripts into two semantic categories:
  - single_use/: scripts run once manually (fresh install, fixes, setup)
  - periodic_background/: scripts run by systemd timers or daemons
- Preserve existing subdirectory structure within each category
- Fix lib/common.sh source paths for new directory depths
- Fix CONFIG_DIR depth in setup_periodic_system.sh and check_and_enable_services.sh
- Update all references in tests, fresh-install/main.sh, nix modules, and docs
- Fix check_polling_antipatterns.sh false positives (||, regex |, case patterns, jq strings)
- Fix pre-existing mypy exclusion path and type annotations for moved tools/ directory
- Rewrite check_polling_antipatterns.sh using awk (no bash regex loops); add require_serial: true
2026-05-15 00:32:35 +02:00

53 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# Periodic system maintenance script
# Installs pacman wrapper and updates hosts file
# This file is installed by setup_periodic_system.sh
set -e
LOG_FILE="/var/log/periodic-system-maintenance.log"
# Path placeholders replaced at install time
PACMAN_WRAPPER_INSTALL="__PACMAN_WRAPPER_INSTALL__"
HOSTS_INSTALL_SCRIPT="__HOSTS_INSTALL_SCRIPT__"
# Function to log with timestamp
log_message() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$LOG_FILE"
}
# Function to execute with logging
execute_with_log() {
local script_path="$1"
local script_name="$2"
log_message "Starting $script_name"
echo "Executing $script_name..." >&2
if [[ -f $script_path ]]; then
if bash "$script_path" >> "$LOG_FILE" 2>&1; then
log_message "$script_name completed successfully"
echo "$script_name completed successfully" >&2
else
local ec=$?
log_message "$script_name failed with exit code $ec"
echo "$script_name failed (exit $ec)" >&2
fi
else
log_message "$script_name not found at $script_path"
echo "$script_name not found at $script_path" >&2
fi
}
# Start maintenance
log_message "=== Periodic System Maintenance Started ==="
# Install pacman wrapper
execute_with_log "$PACMAN_WRAPPER_INSTALL" "Pacman Wrapper Installation"
# Update hosts file
execute_with_log "$HOSTS_INSTALL_SCRIPT" "Hosts File Update"
log_message "=== Periodic System Maintenance Completed ==="
echo "Periodic system maintenance completed. Check $LOG_FILE for details." >&2