#!/usr/bin/env bash # NAME: Enable and configure system services set -euo pipefail # Source common functions source "$(dirname "$0")/../common.sh" || { echo "[ERROR] Could not source common.sh" >&2 exit 1 } enable_networking_services() { log_info "Enabling networking services" sudo systemctl enable --now NetworkManager.service sudo systemctl enable --now bluetooth.service sudo systemctl enable --now sshd.service } enable_audio_services() { log_info "Enabling audio services" systemctl --user enable --now pipewire.service systemctl --user enable --now pipewire-pulse.service systemctl --user enable --now wireplumber.service } enable_printing_services() { log_info "Enabling printing services" sudo systemctl enable --now cups.service } configure_time_locale() { log_info "Configuring time and locale services" if ! grep -q "en_US.UTF-8 UTF-8" /etc/locale.gen; then echo "en_US.UTF-8 UTF-8" | sudo tee -a /etc/locale.gen sudo locale-gen fi echo "LANG=en_US.UTF-8" | sudo tee /etc/locale.conf log_info "System locale set to en_US.UTF-8" sudo timedatectl set-timezone America/Montevideo sudo timedatectl set-ntp true sudo systemctl enable --now systemd-timesyncd.service sudo systemctl enable --now cronie.service } enable_security_services() { log_info "Enabling security services" sudo systemctl enable --now ufw.service sudo ufw --force enable sudo ufw default deny incoming sudo ufw default allow outgoing } enable_backup_services() { log_info "Enabling backup services" if findmnt / -t btrfs &>/dev/null; then sudo systemctl enable --now snapper-timeline.timer sudo systemctl enable --now snapper-cleanup.timer log_info "Snapper enabled (BTRFS detected)" else log_info "Skipping Snapper (no BTRFS detected)" fi } enable_power_management() { log_info "Enabling power management" sudo systemctl enable --now power-profiles-daemon.service } enable_system_optimization() { log_info "Enabling system optimization" sudo systemctl enable --now haveged.service sudo systemctl enable --now plocate-updatedb.timer sudo systemctl enable --now syncthing@forbi.service } main() { init_script enable_networking_services enable_audio_services enable_printing_services configure_time_locale enable_security_services enable_backup_services enable_power_management enable_system_optimization finish_script 0 } main "$@"