[bootstrap] Add more error checking

This commit is contained in:
Andrew Williams
2026-01-09 09:09:28 +00:00
parent ec46b79621
commit 2a9f962a85

View File

@@ -2,41 +2,56 @@
set -e set -e
# Check if git is installed # 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." echo "Git isn't installed."
exit 1 exit 1
fi 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' # Set environment, default to 'personal'
ENVIRONMENT="${1:-personal}" ENVIRONMENT="${1:-personal}"
echo "Bootstrapping dotfiles for environment: $ENVIRONMENT" echo "Bootstrapping dotfiles for environment: ${ENVIRONMENT}"
# Clone dotfiles # Clone dotfiles
echo "Cloning main dotfiles repository..." 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 # Clone private dotfiles based on environment
case "$ENVIRONMENT" in case "$ENVIRONMENT" in
personal) personal)
echo "Cloning personal dotfiles..." 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) work)
echo "Cloning work dotfiles..." 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" echo "Valid options are: personal, work"
exit 1 exit 1
;; ;;
esac esac
# Add the default packages # Add the default packages
for package in bin shell-common bash zsh ssh; do $STOWAGE --clobber install bin shell-common bash zsh ssh
echo "Stowing public package: $package"
"$HOME/.dotfiles/bin/.local/bin/stowage" --clobber install "$package" # If we're on macOS, add macos-specific packages
done if [[ "$(uname)" == "Darwin" ]]; then
$STOWAGE --clobber install macos
fi
echo "" echo ""
echo "Done! Please either source ~/.bash_profile / ~/.zshrc or restart your shell." echo "Done! Please either source ~/.bash_profile / ~/.zshrc or restart your shell."