feat(setup): install system files from etc/
This commit is contained in:
@@ -21,14 +21,11 @@ ERROR=false
|
||||
typeset -a PKGS
|
||||
PKGS=(
|
||||
"alacritty"
|
||||
"dunst"
|
||||
"fish"
|
||||
"i3"
|
||||
"i3lock"
|
||||
"i3status"
|
||||
"jq"
|
||||
"lf"
|
||||
"picom"
|
||||
"rofi"
|
||||
"startx"
|
||||
"tmux"
|
||||
@@ -85,6 +82,15 @@ COPIES=(
|
||||
".gtkrc-2.0"
|
||||
)
|
||||
|
||||
typeset -a SYSTEM_INSTALLS
|
||||
SYSTEM_INSTALLS=(
|
||||
"sysctl.d/99-gaming-perf.conf"
|
||||
"sysctl.d/99-network.conf"
|
||||
"tmpfiles.d/99-gaming-perf.conf"
|
||||
"udev/rules.d/99-perf.rules"
|
||||
"ssh/sshd_config.d/sshd_harden.conf"
|
||||
)
|
||||
|
||||
typeset -A SYMLINK_MAP
|
||||
SYMLINK_MAP[zsh/rc]=".zshrc"
|
||||
|
||||
@@ -258,6 +264,58 @@ copy_all_items() {
|
||||
done
|
||||
}
|
||||
|
||||
install_system_file() {
|
||||
local rel src dst dst_parent
|
||||
|
||||
rel="$1"
|
||||
|
||||
if test -z "$rel"; then
|
||||
error "missing path argument:"
|
||||
error "$0 $@"
|
||||
return 1
|
||||
fi
|
||||
|
||||
src="${SCRIPT_DIR}/etc/$rel"
|
||||
dst="/etc/$rel"
|
||||
dst_parent="$(dirname -- "$dst")"
|
||||
|
||||
if ! test -e "$src"; then
|
||||
error "the following source path does not exist:"
|
||||
error "$src"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! sudo test -d "$dst_parent"; then
|
||||
echo "Creating parent: $dst_parent"
|
||||
sudo mkdir -p "$dst_parent"
|
||||
fi
|
||||
|
||||
if sudo test -e "$dst"; then
|
||||
if sudo cmp -s "$src" "$dst"; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if $FORCE; then
|
||||
echo "Overwriting: $dst"
|
||||
elif $IGNORE_EXISTING; then
|
||||
return 0
|
||||
else
|
||||
error "system file already exists and differs (use --force to overwrite):"
|
||||
error "$dst"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Installing: etc/$rel -> $dst"
|
||||
sudo install -m 644 "$src" "$dst"
|
||||
}
|
||||
|
||||
install_all_system_files() {
|
||||
for rel in "${SYSTEM_INSTALLS[@]}"; do
|
||||
install_system_file "$rel"
|
||||
done
|
||||
}
|
||||
|
||||
check_terminfo() {
|
||||
if ! infocmp tmux-256color > /dev/null; then
|
||||
error "Missing terminfo for tmux-256color. Try installing ncurses-term."
|
||||
@@ -311,6 +369,7 @@ else
|
||||
check_packages_installed
|
||||
create_all_symlinks
|
||||
copy_all_items
|
||||
install_all_system_files
|
||||
fi
|
||||
|
||||
if $ERROR; then
|
||||
|
||||
Reference in New Issue
Block a user