From 2a9f962a85b01571407527d903668ebf3df3a710 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Fri, 9 Jan 2026 09:09:28 +0000 Subject: [PATCH] [bootstrap] Add more error checking --- bootstrap.sh | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index ff40feb..defa13b 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -2,41 +2,56 @@ set -e # Check if git is installed -if ! command -v git >/dev/null 2>&1; then +if ! [ -x $(command -v git) ]; then echo "Git isn't installed." exit 1 fi +# Check if we have a Python3 installation +if ! [ -x $(command -v python3) ]; then + echo "Python3 isn't installed." + exit 1 +fi + # Set environment, default to 'personal' ENVIRONMENT="${1:-personal}" -echo "Bootstrapping dotfiles for environment: $ENVIRONMENT" +echo "Bootstrapping dotfiles for environment: ${ENVIRONMENT}" # Clone dotfiles echo "Cloning main dotfiles repository..." -git clone git@github.com:nikdoof/dotfiles.git "$HOME/.dotfiles" >/dev/null +git clone git@github.com:nikdoof/dotfiles.git "${HOME}/.dotfiles" >/dev/null + +# Validate that the stowage command exists +STOWAGE="$HOME/.dotfiles/bin/.local/bin/stowage" +if ! [ -f "$STOWAGE" ]; then + echo "Stowage not found at in the expected location: ${STOWAGE}" + exit 1 +fi # Clone private dotfiles based on environment case "$ENVIRONMENT" in personal) echo "Cloning personal dotfiles..." - git clone git@github.com:nikdoof/dotfiles-private.git "$HOME/.dotfiles-private" >/dev/null + git clone git@github.com:nikdoof/dotfiles-private.git "${HOME}/.dotfiles-private" >/dev/null ;; work) echo "Cloning work dotfiles..." - git clone git@github.com:nikdoof/dotfiles-work.git "$HOME/.dotfiles-work" >/dev/null + git clone git@github.com:nikdoof/dotfiles-work.git "${HOME}/.dotfiles-work" >/dev/null ;; *) - echo "Unknown environment: $ENVIRONMENT" + echo "Unknown environment: ${ENVIRONMENT}" echo "Valid options are: personal, work" exit 1 ;; esac # Add the default packages -for package in bin shell-common bash zsh ssh; do - echo "Stowing public package: $package" - "$HOME/.dotfiles/bin/.local/bin/stowage" --clobber install "$package" -done +$STOWAGE --clobber install bin shell-common bash zsh ssh + +# If we're on macOS, add macos-specific packages +if [[ "$(uname)" == "Darwin" ]]; then + $STOWAGE --clobber install macos +fi echo "" echo "Done! Please either source ~/.bash_profile / ~/.zshrc or restart your shell."