Make server dotfiles generic: single servers/ folder instead of per-host

Consolidated server/<host>/ into one generic servers/ set applied to any
host. Baseline chosen as the superset of the per-host configs:
.zshrc (agnoster + kubectl), identical .vimrc, standard .bashrc, fuller
htoprc, and the shared neofetch config.

install.sh now deploys servers/ unconditionally (no hostname matching);
removed the --host flag. README updated accordingly.
This commit is contained in:
2026-07-20 09:19:40 -03:00
parent 1e98e55794
commit 7747781623
19 changed files with 45 additions and 1512 deletions

View File

@@ -3,19 +3,18 @@
#
# What it does:
# 1. Detects the OS and package manager (apt on Debian, apk on Alpine).
# 2. Installs base tooling (git, curl, zsh, vim) + extras (htop, neofetch, fzf).
# 2. Installs base tooling (git, curl, zsh, vim) + extras (htop, fzf).
# 3. Installs oh-my-zsh (unattended) and the zsh-autosuggestions plugin.
# 4. Deploys the server/<host> configs matching this machine's hostname.
# 5. Installs Vim plugins via Vundle (PluginInstall).
# 4. Deploys the generic server/ dotfiles.
# 5. Installs Vim plugins (clones each plugin declared in .vimrc).
#
# Usage:
# ./install.sh # auto-detect host, deploy matching configs
# ./install.sh --host vega # force a specific host config
# ./install.sh --no-zsh # skip oh-my-zsh / shell setup
# ./install.sh # full bootstrap
# ./install.sh --no-zsh # skip oh-my-zsh / shell setup
# ./install.sh --chsh # change the current user's login shell to zsh
# ./install.sh --dry-run # show what would happen, change nothing
#
# Run this from inside the cloned dotfiles repo (the dir that contains server/).
# Run this from inside the cloned dotfiles repo (the dir that contains servers/).
# Safe to re-run: every step is idempotent.
set -eu
@@ -26,7 +25,6 @@ set -eu
DRY_RUN=0
INSTALL_ZSH=1
CHSH=0
FORCE_HOST=""
info() { printf '\033[0;34m==>\033[0m %s\n' "$1"; }
ok() { printf '\033[0;32m✔\033[0m %s\n' "$1"; }
@@ -55,7 +53,6 @@ usage() {
# ----------------------------------------------------------------------------
while [ $# -gt 0 ]; do
case "$1" in
--host) FORCE_HOST="$2"; shift 2 ;;
--no-zsh) INSTALL_ZSH=0; shift ;;
--chsh) CHSH=1; shift ;;
--dry-run) DRY_RUN=1; shift ;;
@@ -65,11 +62,11 @@ while [ $# -gt 0 ]; do
done
# ----------------------------------------------------------------------------
# Locate the repo root (dir that holds this script and server/)
# Locate the repo root (dir that holds this script and servers/)
# ----------------------------------------------------------------------------
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
if [ ! -d "$SCRIPT_DIR/server" ]; then
die "server/ not found next to this script.
if [ ! -d "$SCRIPT_DIR/servers" ]; then
die "servers/ not found next to this script.
Clone the dotfiles repo first, then run install.sh from its root:
git clone git@git.ivanch.me:ivanch/dotfiles.git
cd dotfiles && ./install.sh"
@@ -167,23 +164,16 @@ install_oh_my_zsh() {
# Deploy the dotfiles for this host
# ----------------------------------------------------------------------------
deploy_dotfiles() {
HOST_NAME="${FORCE_HOST:-$(hostname 2>/dev/null || uname -n)}"
HOST_DIR="$SCRIPT_DIR/server/$HOST_NAME"
if [ ! -d "$HOST_DIR" ]; then
warn "No server/$HOST_NAME config found."
if [ -z "$FORCE_HOST" ]; then
avail=$(cd "$SCRIPT_DIR/server" && ls -1)
warn "Available hosts: $(echo "$avail" | tr '\n' ' ')"
warn "Skipping dotfile deploy. Re-run with --host <name> to force one."
fi
SRC_DIR="$SCRIPT_DIR/servers"
if [ ! -d "$SRC_DIR" ]; then
warn "servers/ not found next to this script; skipping dotfile deploy."
return 0
fi
info "Deploying dotfiles for host: $HOST_NAME"
# Copy every file/dir from server/<host>/ into $HOME, preserving structure.
# .zshrc/.vimrc/.bashrc land at $HOME; .config/* is nested.
for src in "$HOST_DIR"/* "$HOST_DIR"/.[!.]* "$HOST_DIR"/..?*; do
info "Deploying generic server dotfiles from servers/"
# Copy every file/dir from servers/ into $HOME, preserving structure.
# .zshrc/.vimrc/.bashrc land at $HOME; .config/* stays nested.
for src in "$SRC_DIR"/* "$SRC_DIR"/.[!.]* "$SRC_DIR"/..?*; do
[ -e "$src" ] || continue
run cp -Rf "$src" "$HOME/"
ok "$(basename "$src") -> $HOME/"