[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
# 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."