Add bootstrap.sh with zsh and git modules
Cross-distro (RHEL/Debian) VM setup: zsh + oh-my-zsh with a self-healing bash fallback for environments that reset the root filesystem or hardcode bash for new terminals (e.g. Kasm Workspaces), plus git identity and HTTPS credential-store configuration. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env sh
|
||||
# lib/os-detect.sh — shared OS/package-manager detection for module installers.
|
||||
# Source this, then call pkg_install <pkg> [pkg...].
|
||||
|
||||
detect_pkg_family() {
|
||||
if [ -f /etc/os-release ]; then
|
||||
# shellcheck disable=SC1091
|
||||
id_line="$(. /etc/os-release && printf '%s %s' "${ID:-}" "${ID_LIKE:-}")"
|
||||
case "$id_line" in
|
||||
*debian*|*ubuntu*) printf 'debian\n'; return 0 ;;
|
||||
*rhel*|*fedora*|*centos*) printf 'rhel\n'; return 0 ;;
|
||||
esac
|
||||
fi
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
printf 'debian\n'; return 0
|
||||
fi
|
||||
if command -v dnf >/dev/null 2>&1 || command -v yum >/dev/null 2>&1; then
|
||||
printf 'rhel\n'; return 0
|
||||
fi
|
||||
printf 'unknown\n'
|
||||
return 1
|
||||
}
|
||||
|
||||
pkg_install() {
|
||||
family="$(detect_pkg_family)"
|
||||
case "$family" in
|
||||
debian)
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y "$@"
|
||||
;;
|
||||
rhel)
|
||||
if command -v dnf >/dev/null 2>&1; then
|
||||
sudo dnf install -y "$@"
|
||||
else
|
||||
sudo yum install -y "$@"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
printf 'error: unsupported/undetected OS family; install manually: %s\n' "$*" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
Reference in New Issue
Block a user