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

40 lines
822 B
Text
Raw Normal View History

2021-08-14 18:01:30 +09:00
#!/bin/bash
set -euo pipefail
2022-04-22 19:47:02 +09:00
cd -- "$(dirname -- "$0")"
2021-08-14 18:01:30 +09:00
2022-04-25 20:36:15 +09:00
function install_dotfiles() {
2022-04-25 19:39:57 +09:00
local home
2022-04-25 19:28:26 +09:00
local dotfile
2022-06-11 02:06:00 +09:00
home=$(eval echo ~"${SUDO_USER:-}")
2022-04-25 19:28:26 +09:00
for dotfile in .*; do
[[ $dotfile =~ ^(\.\.?|\.git)$ ]] && continue
2021-08-14 18:01:30 +09:00
2022-04-25 19:28:26 +09:00
dotfile=$(realpath "$dotfile")
(
2022-04-25 19:39:57 +09:00
cd -- "$home"
2022-04-25 19:28:26 +09:00
ln -svf "$dotfile" .
)
done
}
2022-04-25 20:36:15 +09:00
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