initial commit of setup script
This commit is contained in:
commit
927c39ce90
33
README_SETUP_DEBIAN.md
Normal file
33
README_SETUP_DEBIAN.md
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
Debian setup script
|
||||||
|
|
||||||
|
This repository contains a simple idempotent-ish script to provision a Debian-based machine after a rebuild.
|
||||||
|
|
||||||
|
Files
|
||||||
|
- setup-debian.sh: main script to run (creates/updates ~/.bashrc entries)
|
||||||
|
|
||||||
|
Usage
|
||||||
|
1. Make the script executable and run it as your user (it will use sudo when needed):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod +x ~/setup-debian.sh
|
||||||
|
~/setup-debian.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
or run with sudo:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo bash ~/setup-debian.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
What the script does
|
||||||
|
- Updates apt and installs requested packages (curl, net-tools, ncdu, tmux, htop, nala, neofetch, nfs-common, git, neovim, etc.)
|
||||||
|
- Installs `snapd` and installs Bitwarden via snap
|
||||||
|
- Attempts to detect a unix socket (ssh/bitwarden) and export `SSH_AUTH_SOCK` to `~/.bashrc`
|
||||||
|
- Installs VS Code via snap
|
||||||
|
- Installs latest `kubectl` binary and enables bash completion + aliases (`k`)
|
||||||
|
- Adds a `fgk` alias for `flux get kustomizations all`
|
||||||
|
- Adds arrow-key history search (type prefix then Up/Down)
|
||||||
|
|
||||||
|
Notes
|
||||||
|
- The script attempts to detect a Bitwarden SSH agent socket but may not find it automatically depending on how Bitwarden exposes it; if needed, manually set `SSH_AUTH_SOCK` in your shell to the socket path.
|
||||||
|
- `flux` must be installed separately if you need `fgk` to work.
|
||||||
98
setup-debian.sh
Executable file
98
setup-debian.sh
Executable file
|
|
@ -0,0 +1,98 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Debian setup script - idempotent-ish
|
||||||
|
# Run as your user; the script will use sudo where needed.
|
||||||
|
|
||||||
|
SUDO=''
|
||||||
|
if [ "$EUID" -ne 0 ]; then
|
||||||
|
SUDO='sudo'
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Starting Debian setup..."
|
||||||
|
|
||||||
|
${SUDO} apt update
|
||||||
|
${SUDO} apt upgrade -y
|
||||||
|
|
||||||
|
PKGS=(curl net-tools ncdu tmux htop nala neofetch nfs-common git neovim bash-completion ca-certificates gnupg lsb-release software-properties-common)
|
||||||
|
echo "Installing packages: ${PKGS[*]}"
|
||||||
|
${SUDO} apt install -y "${PKGS[@]}"
|
||||||
|
|
||||||
|
# snapd + Bitwarden
|
||||||
|
if ! command -v snap >/dev/null 2>&1; then
|
||||||
|
echo "Installing snapd..."
|
||||||
|
${SUDO} apt install -y snapd
|
||||||
|
${SUDO} systemctl enable --now snapd.socket || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Installing Bitwarden (snap)..."
|
||||||
|
${SUDO} snap install bitwarden || true
|
||||||
|
|
||||||
|
# Set SSH_AUTH_SOCK to Bitwarden snap socket path
|
||||||
|
# This uses the predictable snap path for the current user.
|
||||||
|
ssh_sock="/home/$(whoami)/snap/bitwarden/current/.bitwarden-ssh-agent.sock"
|
||||||
|
if ! grep -q "export SSH_AUTH_SOCK=${ssh_sock}" "$HOME/.bashrc" 2>/dev/null; then
|
||||||
|
echo "Adding Bitwarden SSH_AUTH_SOCK to ~/.bashrc"
|
||||||
|
printf "\n# Bitwarden SSH agent socket\nexport SSH_AUTH_SOCK=%s\n" "$ssh_sock" >> "$HOME/.bashrc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install VS Code via snap (classic)
|
||||||
|
if ! command -v code >/dev/null 2>&1; then
|
||||||
|
echo "Installing VS Code (snap)..."
|
||||||
|
${SUDO} snap install --classic code || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# kubectl installation (latest stable binary)
|
||||||
|
if ! command -v kubectl >/dev/null 2>&1; then
|
||||||
|
echo "Installing kubectl..."
|
||||||
|
curl -fsSLO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||||
|
${SUDO} install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
|
||||||
|
rm -f kubectl
|
||||||
|
fi
|
||||||
|
|
||||||
|
# flux CLI installation (latest release)
|
||||||
|
if ! command -v flux >/dev/null 2>&1; then
|
||||||
|
echo "Installing flux CLI..."
|
||||||
|
curl -s https://fluxcd.io/install.sh | ${SUDO} bash
|
||||||
|
fi
|
||||||
|
|
||||||
|
# velero CLI installation (latest release)
|
||||||
|
if ! command -v velero >/dev/null 2>&1; then
|
||||||
|
echo "Installing velero CLI..."
|
||||||
|
velero_version="$(curl -fsSL https://api.github.com/repos/vmware-tanzu/velero/releases/latest | grep -m1 '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')"
|
||||||
|
curl -fsSLO "https://github.com/vmware-tanzu/velero/releases/download/${velero_version}/velero-${velero_version}-linux-amd64.tar.gz"
|
||||||
|
tar -xzf "velero-${velero_version}-linux-amd64.tar.gz"
|
||||||
|
${SUDO} install -o root -g root -m 0755 "velero-${velero_version}-linux-amd64/velero" /usr/local/bin/velero
|
||||||
|
rm -rf "velero-${velero_version}-linux-amd64" "velero-${velero_version}-linux-amd64.tar.gz"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Enable kubectl bash completion and add aliases to ~/.bashrc if missing
|
||||||
|
ensure_bashrc_snippet() {
|
||||||
|
file="$HOME/.bashrc"
|
||||||
|
grep -q 'kubectl completion bash' "$file" || cat >> "$file" <<'BASH_SNIPPET'
|
||||||
|
|
||||||
|
# kubectl completion + aliases
|
||||||
|
if command -v kubectl >/dev/null 2>&1; then
|
||||||
|
source <(kubectl completion bash)
|
||||||
|
alias k=kubectl
|
||||||
|
complete -F __start_kubectl k
|
||||||
|
fi
|
||||||
|
|
||||||
|
# alias for flux get kustomizations
|
||||||
|
alias fgk='flux get kustomizations all'
|
||||||
|
BASH_SNIPPET
|
||||||
|
|
||||||
|
grep -q 'history-search-backward' "$file" || cat >> "$file" <<'HIST_SNIPPET'
|
||||||
|
|
||||||
|
# History search with arrow keys: type start then Up/Down to search
|
||||||
|
bind '"\e[A": history-search-backward'
|
||||||
|
bind '"\e[B": history-search-forward'
|
||||||
|
HIST_SNIPPET
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_bashrc_snippet
|
||||||
|
|
||||||
|
echo "Setup complete. Open a new shell or run 'source ~/.bashrc' to load changes."
|
||||||
|
echo "If Bitwarden provides an SSH agent, ensure SSH_AUTH_SOCK points to its socket."
|
||||||
|
|
||||||
|
exit 0
|
||||||
Loading…
Reference in a new issue