116 lines
4.2 KiB
Bash
Executable File
116 lines
4.2 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
# Colors
|
|
BLUE='\033[1;34m'
|
|
YELLOW='\033[1;33m'
|
|
GREEN='\033[1;32m'
|
|
RED='\033[1;31m'
|
|
NC='\033[0m'
|
|
|
|
echo -e "${BLUE} LOG:${YELLOW} Initializing Base System Layer...${NC}"
|
|
|
|
# OS Detection
|
|
if [ -f /etc/os-release ]; then
|
|
. /etc/os-release
|
|
OS=$ID
|
|
fi
|
|
|
|
# Confirm Architecture
|
|
ARCH=$(uname -m)
|
|
if [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "aarch64" ]; then
|
|
echo -e "${RED} ERROR: Unsupported architecture: $ARCH${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
# 2. Package Installation (OS Dependencies)
|
|
# Note: Removed 'go', 'npm', 'cargo' - these are handled by specific scripts
|
|
PACKAGES=(
|
|
curl wget git sudo zsh tmux unzip tar gzip
|
|
build-essential openssl python bison mercurial
|
|
ripgrep fd bat fzf jq btop httpie gnupg zoxide stow
|
|
bind nmap socat tcpdump net-tools strace gdb hexyl
|
|
rclone
|
|
# 'eza' is REMOVED from here for Ubuntu logic below
|
|
)
|
|
|
|
if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then
|
|
# Arch has eza in the community repo
|
|
sudo pacman -Sy --noconfirm --needed "${PACKAGES[@]}" eza base-devel
|
|
elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get update
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "${PACKAGES[@]}" bsdmainutils pkg-config cmake
|
|
|
|
# -----------------------------------------------------------------
|
|
# EZA BINARY INSTALL (Ubuntu/Debian)
|
|
# -----------------------------------------------------------------
|
|
if ! command -v eza &> /dev/null; then
|
|
echo -e "${BLUE} LOG:${YELLOW} Fetching eza binary (skipping compilation)...${NC}"
|
|
|
|
# 1. Define Version (Check releases page for latest)
|
|
EZA_VER="v0.18.11"
|
|
EZA_URL="https://github.com/eza-community/eza/releases/download/${EZA_VER}/eza_x86_64-unknown-linux-gnu.tar.gz"
|
|
|
|
# 2. Download and Extract directly to a temp location
|
|
wget -qO- "$EZA_URL" | tar xz -C /tmp
|
|
|
|
# 3. Move to local bin (No sudo needed if ~/.local/bin is in PATH)
|
|
mkdir -p "$HOME/.local/bin"
|
|
mv /tmp/eza "$HOME/.local/bin/"
|
|
chmod +x "$HOME/.local/bin/eza"
|
|
|
|
echo -e "${GREEN} LOG: eza installed to ~/.local/bin${NC}"
|
|
fi
|
|
fi
|
|
# 3. Docker Installation
|
|
if command -v docker &> /dev/null; then
|
|
echo -e "${GREEN} LOG: Docker is already installed.${NC}"
|
|
else
|
|
if grep -qEi "(Microsoft|WSL)" /proc/version &> /dev/null; then
|
|
echo -e "${RED} LOG: WSL Detected! Skipping Native Docker.${NC}"
|
|
echo -e "${RED} >>> Please install Docker Desktop on Windows.${NC}"
|
|
else
|
|
echo -e "${BLUE} LOG:${YELLOW} Installing Native Docker...${NC}"
|
|
if [ "$OS" == "arch" ]; then
|
|
sudo pacman -S --noconfirm --needed docker docker-compose
|
|
sudo systemctl enable --now docker
|
|
elif [ "$OS" == "ubuntu" ]; then
|
|
# (Simplified for brevity - standard Docker install logic)
|
|
curl -fsSL https://get.docker.com | sh
|
|
fi
|
|
|
|
# Add user to group
|
|
sudo usermod -aG docker $(whoami)
|
|
fi
|
|
fi
|
|
|
|
# 4. Zsh & Configuration
|
|
if [ ! -d "$HOME/.oh-my-zsh" ]; then
|
|
echo -e "${BLUE} LOG:${YELLOW} Installing Oh My Zsh...${NC}"
|
|
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
|
|
fi
|
|
|
|
# Plugins
|
|
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
|
|
mkdir -p "$ZSH_CUSTOM/plugins"
|
|
[ ! -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ] && git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting"
|
|
[ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ] && git clone https://github.com/zsh-users/zsh-autosuggestions "$ZSH_CUSTOM/plugins/zsh-autosuggestions"
|
|
|
|
# 5. Git Credentials (WSL Bridge)
|
|
if grep -qEi "(Microsoft|WSL)" /proc/version &> /dev/null; then
|
|
GCM_WIN="/mnt/c/Program Files/Git/mingw64/bin/git-credential-manager.exe"
|
|
[ -f "$GCM_WIN" ] && git config --global credential.helper "! \"$GCM_WIN\""
|
|
else
|
|
git config --global credential.helper 'cache --timeout=43200'
|
|
fi
|
|
|
|
# 6. Cleanup & Secrets
|
|
rm -f "$HOME/.zshrc" "$HOME/.zsh_aliases"
|
|
touch "$HOME/.zsh_secrets"
|
|
|
|
# 7. Set Shell
|
|
if [ "$SHELL" != "$(which zsh)" ]; then
|
|
sudo chsh -s "$(which zsh)" $(whoami)
|
|
fi
|
|
|
|
echo -e "${GREEN} LOG: Base System Setup Complete.${NC}" |