1
0
Fork 0
mirror of https://github.com/kou029w/dotfiles.git synced 2025-01-18 16:07:59 +00:00
dotfiles/install

39 lines
822 B
Bash
Executable file

#!/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