mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 02:20:11 -08:00
- Improved OS detection in bootstrap.sh and setup.sh to handle unsupported OS cases. - Added a function to determine the package manager (nala, dnf, apt) based on the detected OS. - Updated package installation commands to use the appropriate package manager. - Enhanced user feedback with colored output for better visibility during setup and updates.
79 lines
1.8 KiB
Bash
Executable File
79 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
DOTFILES_REPO="acedanger/shell"
|
|
DOTFILES_BRANCH="main"
|
|
DOTFILES_DIR="$HOME/shell"
|
|
|
|
# Colors for output
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[0;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
echo -e "${GREEN}Setting up your system...${NC}"
|
|
|
|
# Detect OS
|
|
if [ -f /etc/os-release ]; then
|
|
. /etc/os-release
|
|
OS_NAME=$ID
|
|
OS_VERSION=$VERSION_ID
|
|
else
|
|
echo -e "${YELLOW}Unable to detect OS, assuming Debian/Ubuntu...${NC}"
|
|
OS_NAME="ubuntu"
|
|
OS_VERSION="22.04"
|
|
fi
|
|
|
|
echo -e "${GREEN}Detected OS: ${OS_NAME} ${OS_VERSION}${NC}"
|
|
|
|
# Function to determine the package manager to use
|
|
determine_pkg_manager() {
|
|
if command -v nala &> /dev/null; then
|
|
echo "nala"
|
|
elif [ "$OS_NAME" = "fedora" ]; then
|
|
echo "dnf"
|
|
else
|
|
echo "apt"
|
|
fi
|
|
}
|
|
|
|
# Determine which package manager to use
|
|
PKG_MANAGER=$(determine_pkg_manager)
|
|
echo -e "${GREEN}Using package manager: $PKG_MANAGER${NC}"
|
|
|
|
# Install git if not present
|
|
if ! command -v git &>/dev/null; then
|
|
echo -e "${YELLOW}Installing git...${NC}"
|
|
case $PKG_MANAGER in
|
|
nala)
|
|
sudo nala install -y git
|
|
;;
|
|
dnf)
|
|
sudo dnf install -y git
|
|
;;
|
|
apt)
|
|
sudo apt update && sudo apt install -y git
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
# Create shell directory if it doesn't exist
|
|
mkdir -p "$HOME/shell"
|
|
|
|
# Clone or update repository
|
|
if [ -d "$DOTFILES_DIR" ]; then
|
|
echo -e "${YELLOW}Updating existing shell repository...${NC}"
|
|
cd "$DOTFILES_DIR"
|
|
git pull origin $DOTFILES_BRANCH
|
|
else
|
|
echo -e "${YELLOW}Cloning shell repository...${NC}"
|
|
git clone "https://github.com/$DOTFILES_REPO.git" "$DOTFILES_DIR"
|
|
cd "$DOTFILES_DIR"
|
|
fi
|
|
|
|
# Make scripts executable
|
|
chmod +x "$DOTFILES_DIR/setup/setup.sh"
|
|
|
|
# Run setup script
|
|
"$DOTFILES_DIR/setup/setup.sh"
|
|
|
|
echo -e "${GREEN}Bootstrap completed! Please restart your terminal for changes to take effect.${NC}"
|