#!/bin/bash set -euo pipefail cd -- "$(dirname -- "$0")" function install_dotfiles() { local home local dotfile home=$(eval echo ~"${SUDO_USER:-}") for dotfile in .*; do [[ $dotfile =~ ^(\.\.?|\.git)$ ]] && continue dotfile=$(realpath "$dotfile") ( cd -- "$home" ln -svf "$dotfile" . ) done } function install_apt_packages() { local packages local package packages=() for package in etc/apt/sources.list.d/*.list; do package=${package##*/} package=${package%.list} packages+=("$package") done rsync -rv etc/apt/keyrings/ /usr/share/keyrings/ rsync -rv etc/apt/sources.list.d/ /etc/apt/sources.list.d/ apt update apt install -y "${packages[@]}" } install_dotfiles (($(id -u) == 0)) \ && [[ -d /etc/apt/sources.list.d ]] \ && install_apt_packages