#!/bin/bash # # Bootstrap script to bring a fresh Ubuntu LTS install up to autoinstall parity # # Usage (short): # curl -fsSL aie.tal.one | sudo bash # curl -fsSL aie.tal.one | sudo bash -s -- # # Usage (full): # curl -fsSL https://talw.media/autoinstall/bootstrap.sh | sudo bash # curl -fsSL https://talw.media/autoinstall/bootstrap.sh | sudo bash -s -- # # AUTO-GENERATED - do not edit manually # set -euo pipefail # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color info() { echo -e "${GREEN}[INFO]${NC} $1"; } warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; } # Check if running as root or with sudo if [[ $EUID -ne 0 ]]; then error "This script must be run as root (use sudo)" fi REAL_USER="${SUDO_USER:-$USER}" REAL_HOME=$(getent passwd "$REAL_USER" | cut -d: -f6) NEW_HOSTNAME="${1:-}" info "Bootstrapping Ubuntu to autoinstall parity for user: $REAL_USER" # --- Set Hostname --- if [[ -n "$NEW_HOSTNAME" ]]; then info "Setting hostname to: $NEW_HOSTNAME" hostnamectl set-hostname "$NEW_HOSTNAME" sed -i "s/127\.0\.1\.1.*$/127.0.1.1\t$NEW_HOSTNAME/" /etc/hosts if ! grep -q "127.0.1.1" /etc/hosts; then echo -e "127.0.1.1\t$NEW_HOSTNAME" >> /etc/hosts fi else warn "No hostname provided, keeping current: $(hostname)" fi # --- Add External Repositories --- info "Adding GitHub CLI repository..." curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \ -o /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" \ > /etc/apt/sources.list.d/github-cli.list info "Adding Tailscale repository..." curl -fsSL "https://pkgs.tailscale.com/stable/ubuntu/$(lsb_release -cs).noarmor.gpg" \ -o /usr/share/keyrings/tailscale-archive-keyring.gpg curl -fsSL "https://pkgs.tailscale.com/stable/ubuntu/$(lsb_release -cs).tailscale-keyring.list" \ -o /etc/apt/sources.list.d/tailscale.list # --- Update and Install Packages --- info "Updating package lists..." apt-get update -qq info "Installing packages..." apt-get install -y \ openssh-server \ sshfs \ sshpass \ cifs-utils \ smbclient \ htop \ tree \ restic \ curl \ nodejs \ npm \ python3-dev \ python3-pip \ python3-venv \ pipx \ ffmpeg \ git \ git-lfs \ vlc \ gh \ tailscale # --- Configure Services --- info "Enabling SSH..." systemctl enable --now ssh # --- Set Timezone --- info "Setting timezone to America/Denver..." timedatectl set-timezone America/Denver # --- Download Dotfiles --- info "Downloading dotfiles to $REAL_HOME..." curl -fsSL https://talw.media/autoinstall/dotfiles/bashrc -o "$REAL_HOME/.bashrc" || true curl -fsSL https://talw.media/autoinstall/dotfiles/bash_aliases -o "$REAL_HOME/.bash_aliases" || true curl -fsSL https://talw.media/autoinstall/dotfiles/profile -o "$REAL_HOME/.profile" || true curl -fsSL https://talw.media/autoinstall/dotfiles/ps1 -o "$REAL_HOME/.ps1" || true chown "$REAL_USER:$REAL_USER" "$REAL_HOME/.bashrc" "$REAL_HOME/.bash_aliases" "$REAL_HOME/.profile" "$REAL_HOME/.ps1" 2>/dev/null || true # --- Summary --- echo "" info "Bootstrap complete!" echo "" echo "Hostname: $(hostname)" echo "" echo "Installed:" echo " - 16 packages from Ubuntu repos" echo " - git, git-lfs, vlc" echo " - gh (GitHub CLI)" echo " - tailscale" echo "" echo "Next steps:" echo " 1. Run 'tailscale up' to connect to your tailnet" echo " 2. Run 'gh auth login' to authenticate with GitHub" echo ""