first commit

This commit is contained in:
Dan Milne
2025-03-11 15:36:25 +11:00
commit eb9b51fe52
4 changed files with 135 additions and 0 deletions

83
install.sh Normal file
View File

@@ -0,0 +1,83 @@
#!/bin/bash
# 16.5mm
# Define paths
DOTFILES_DIR="$HOME/.config/dotfiles"
DOTFILES_REPO="https://git.tbdb.info/Booko/server-dotfiles.git" # Replace with your actual repo URL
BASHRC="$HOME/.bashrc"
BASH_PROFILE="$HOME/.bash_profile"
# Install Git if not present
if ! command -v git &> /dev/null; then
echo "Git not found. Installing Git..."
if command -v apt &> /dev/null; then
sudo apt update
sudo apt install -y git
elif command -v dnf &> /dev/null; then
sudo dnf install -y git
elif command -v yum &> /dev/null; then
sudo yum install -y git
elif command -v pacman &> /dev/null; then
sudo pacman -Sy git
else
echo "Error: Unsupported package manager. Please install Git manually."
exit 1
fi
elif command -v git &> /dev/null; then
echo "Git is already installed."
else
echo "Error: Cannot install Git on unknown operating system."
exit 1
fi
# Clone the repository if it doesn't exist
if [ ! -d "$DOTFILES_DIR" ]; then
echo "Cloning dotfiles repository to $DOTFILES_DIR..."
git clone "$DOTFILES_REPO" "$DOTFILES_DIR"
else
echo "Dotfiles directory already exists at $DOTFILES_DIR"
echo "Pulling latest changes..."
cd "$DOTFILES_DIR" && git pull
fi
# Add sourcing code to .bashrc if not already present
if ! grep -q "DOTFILES_DIR.*config/dotfiles" "$BASHRC"; then
cat << 'EOF' >> "$BASHRC"
# Load dotfiles configuration
DOTFILES_DIR="$HOME/.config/dotfiles"
# Load base configuration
if [ -f "$DOTFILES_DIR/bashrc" ]; then
source "$DOTFILES_DIR/bashrc"
fi
EOF
echo "Updated $BASHRC to load dotfiles configurations"
else
echo "$BASHRC already configured to load dotfiles"
fi
# Ensure .bash_profile sources .bashrc (for login shells)
if [ -f "$BASH_PROFILE" ]; then
if ! grep -q "source.*bashrc" "$BASH_PROFILE"; then
echo -e "\n# Source .bashrc for login shells\nif [ -f \"$BASHRC\" ]; then\n source \"$BASHRC\"\nfi" >> "$BASH_PROFILE"
echo "Updated $BASH_PROFILE to source $BASHRC"
else
echo "$BASH_PROFILE already sources $BASHRC"
fi
else
echo "# Source .bashrc for login shells" > "$BASH_PROFILE"
echo "if [ -f \"$BASHRC\" ]; then" >> "$BASH_PROFILE"
echo " source \"$BASHRC\"" >> "$BASH_PROFILE"
echo "fi" >> "$BASH_PROFILE"
echo "Created $BASH_PROFILE to source $BASHRC"
fi
# Install additional software
install_additional_software
echo "Dotfiles installation complete!"
echo "Your configurations will be loaded from:"
echo "- Base: $DOTFILES_DIR/base/bashrc"