Skip to content

Instantly share code, notes, and snippets.

@lbr88
Last active December 20, 2025 15:50
Show Gist options
  • Select an option

  • Save lbr88/39882ea9cf5951d2fd1847e8221e936d to your computer and use it in GitHub Desktop.

Select an option

Save lbr88/39882ea9cf5951d2fd1847e8221e936d to your computer and use it in GitHub Desktop.
Bootstrap script for dotfiles setup
#!/bin/bash
# Bootstrap script for fresh Ubuntu install
# Run with: bash -c "$(curl -fsSL https://xxz.dk/l/u24b)"
set -e
echo "=== Dotfiles Bootstrap ==="
# Install minimal dependencies
echo "[1/6] Installing dependencies..."
sudo apt update
DEBIAN_FRONTEND=noninteractive sudo apt install -y curl git snapd
# Install GitHub CLI
echo "[2/6] Installing GitHub CLI..."
if ! command -v gh &>/dev/null; then
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg 2>/dev/null
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
DEBIAN_FRONTEND=noninteractive sudo apt install -y gh
fi
# Install Bitwarden (desktop and CLI)
echo "[3/6] Setting up Bitwarden..."
if ! command -v bitwarden &>/dev/null; then
echo "Installing Bitwarden desktop app..."
sudo snap install bitwarden
fi
if ! command -v bw &>/dev/null; then
echo "Installing Bitwarden CLI..."
sudo snap install bw
fi
# Configure Bitwarden CLI server (only if not already configured)
CURRENT_SERVER=$(bw config server 2>/dev/null | grep -oP 'https://[^ ]+' || echo "")
DESIRED_SERVER="https://vw.nyvej.it"
if [ "$CURRENT_SERVER" != "$DESIRED_SERVER" ]; then
echo "Configuring Bitwarden CLI server..."
# Logout first if needed to allow server change
bw logout 2>/dev/null || true
bw config server "$DESIRED_SERVER"
fi
echo ""
echo "✓ Bitwarden desktop app is installed"
echo " Please open Bitwarden and login to access your passwords"
echo ""
# Authenticate with GitHub (opens browser)
echo "[4/6] Authenticating with GitHub..."
if ! gh auth status &>/dev/null; then
echo "Please log in to GitHub in your browser..."
gh auth login -h github.com -p https -w
fi
# Clone and run setup
echo "[5/5] Cloning dotfiles and running setup..."
DOTFILES_DIR="$HOME/git/private/dotfiles"
mkdir -p "$(dirname "$DOTFILES_DIR")"
if [ -d "$DOTFILES_DIR" ]; then
echo "Dotfiles already exists, updating..."
cd "$DOTFILES_DIR"
# Reset any local changes (they get re-generated by setup anyway)
git reset --hard HEAD 2>/dev/null || true
# Sync using gh CLI
gh repo sync 2>/dev/null || echo "⚠ Could not sync repo"
cd - > /dev/null
else
gh repo clone lbr88/dotfiles "$DOTFILES_DIR"
fi
chmod +x "$DOTFILES_DIR/setup_user.sh"
exec "$DOTFILES_DIR/setup_user.sh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment