Breaking it down

This commit is contained in:
MangoPig 2025-12-04 09:23:10 +00:00
parent 45cd93d43d
commit 10f55ec25c
10 changed files with 276 additions and 281 deletions

View File

@ -1,18 +1,23 @@
# Makefile for Dotfiles
# Tells Make that these targets are not actual files
.PHONY: all setup stow clean update docker-test
.PHONY: all setup stow clean update docker-test test-ubuntu test-arch storagebox
# Default target (runs when you just type 'make')
all: stow
# Full Setup
setup:
bash setup.sh
bash ./scripts/setup.sh
bash ./scripts/node.sh
bash ./scripts/go.sh
bash ./scripts/rust.sh
bash ./scripts/python.sh
@echo "Full setup completed."
# Just stow the dotfiles
stow:
stow . --target=$$HOME --ignore="setup.sh" --ignore=".git" --ignore=".gitignore" --ignore="README.md" --ignore=".zsh_secrets" --ignore=".zsh_secrets.example" --ignore="LICENSE" --ignore="Makefile" --ignore="provision.sh" --ignore="storagebox.sh"
stow . --target=$$HOME --ignore=".git" --ignore=".gitignore" --ignore="README.md" --ignore=".zsh_secrets" --ignore=".zsh_secrets.example" --ignore="LICENSE" --ignore="Makefile"
@echo "Dotfiles linked."
# Clean old files and links
@ -25,9 +30,22 @@ update:
git pull origin main
make setup
# Language Setups
node:
bash ./scripts/node.sh
go:
bash ./scripts/go.sh
rust:
bash ./scripts/rust.sh
python:
bash ./scripts/python.sh
# Setup StorageBox
storagebox:
bash storagebox.sh
bash ./scripts/storagebox.sh
# Docker Tests
test-ubuntu:

BIN
bin/eza Normal file

Binary file not shown.

46
scripts/go.sh Normal file
View File

@ -0,0 +1,46 @@
#!/bin/bash
set -e
BLUE='\033[1;34m'
YELLOW='\033[1;33m'
GREEN='\033[1;32m'
RED='\033[1;31m'
NC='\033[0m'
echo -e "${BLUE} LOG:${YELLOW} Setting up Go (GVM)...${NC}"
# 1. Install GVM dependencies
unalias cd 2>/dev/null || true
# 2. Install GVM if missing
if [ ! -d "$HOME/.gvm" ]; then
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
fi
# 3. Load GVM
[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"
# 4. Install Go
# Use a known stable version that exists. 1.24.11 is speculative. 1.24.0 is real.
TARGET_GO="go1.24.0"
if command -v gvm &> /dev/null; then
if [[ $(gvm list) != *"$TARGET_GO"* ]]; then
echo -e "${BLUE} LOG:${YELLOW} Installing $TARGET_GO...${NC}"
# Try Binary install first (Fastest/Safest)
gvm install "$TARGET_GO" -B || {
echo -e "${RED} LOG: Binary failed. Bootstrapping via go1.22.9...${NC}"
gvm install go1.22.9 -B
gvm use go1.22.9
gvm install "$TARGET_GO"
}
gvm use "$TARGET_GO" --default
echo -e "${GREEN} LOG: Go setup complete.$(go version)${NC}"
else
echo -e "${GREEN} LOG: $TARGET_GO already installed.${NC}"
fi
else
echo -e "${RED} ERROR: GVM failed to load.${NC}"
exit 1
fi

33
scripts/node.sh Normal file
View File

@ -0,0 +1,33 @@
#!/bin/bash
set -e # Exit on error
BLUE='\033[1;34m'
YELLOW='\033[1;33m'
GREEN='\033[1;32m'
NC='\033[0m'
echo -e "${BLUE} LOG:${YELLOW} Setting up Node.js (NVM)...${NC}"
export NVM_DIR="$HOME/.nvm"
# 1. Install NVM
if [ ! -d "$NVM_DIR" ]; then
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
fi
# 2. Load NVM
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# 3. Install Node
if command -v nvm &> /dev/null; then
echo -e "${BLUE} LOG:${YELLOW} Installing LTS...${NC}"
nvm install --lts
nvm use --lts
echo -e "${BLUE} LOG:${YELLOW} Installing Global Tools...${NC}"
# set +e is safer for npm global installs which can be noisy
set +e
npm install -g pnpm yarn
set -e
echo -e "${GREEN} LOG: Node setup complete.$(node -v)${NC}"
fi

View File

@ -7,6 +7,10 @@ YELLOW='\033[1;33m'
RED='\033[1;31m'
NC='\033[0m'
DEFAULT_USER="mangopig"
DEFAULT_UID="1000"
DEFAULT_GID="1000"
# Root Check
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}Please run this script as root.${NC}"
@ -48,18 +52,26 @@ else
fi
# Interactive Prompts
if [ -t 0 ]; then
echo -e "${GREEN}---------------------------------------${NC}"
echo -e "${GREEN} USER PROVISIONING WIZARD ${NC}"
echo -e "${GREEN}---------------------------------------${NC}"
read -p "Enter Username (default: mangopig): " USERNAME
USERNAME=${USERNAME:-mangopig}
read -p "Enter Username (default: $DEFAULT_USER): " INPUT_USER
USERNAME=${INPUT_USER:-$DEFAULT_USER}
read -p "Enter UID (default: 1000): " USER_UID
USER_UID=${USER_UID:-1000}
read -p "Enter UID (default: $DEFAULT_UID): " INPUT_UID
USER_UID=${INPUT_UID:-$DEFAULT_UID}
read -p "Enter GID (default: 1000): " USER_GID
USER_GID=${USER_GID:-1000}
read -p "Enter GID (default: $DEFAULT_GID): " INPUT_GID
USER_GID=${INPUT_GID:-$DEFAULT_GID}
else
echo -e "${YELLOW}LOG: Non-interactive session detected. Using defaults.${NC}"
# Allow Environment Variables to override defaults in Docker/Headless
USERNAME=${USERNAME:-$DEFAULT_USER}
USER_UID=${USER_UID:-$DEFAULT_UID}
USER_GID=${USER_GID:-$DEFAULT_GID}
fi
# Group Creation
if getent group "$USER_GID" >/dev/null; then

15
scripts/python.sh Normal file
View File

@ -0,0 +1,15 @@
#!/bin/bash
set -e
# Bold Colors
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
RED='\033[1;31m'
GREEN='\033[1;32m'
NC='\033[0m'
# Python Setup
echo -e "${BLUE} LOG:${YELLOW} Setting up Python environment...${NC}"
# MiniConda Installation

23
scripts/rust.sh Normal file
View File

@ -0,0 +1,23 @@
#!/bin/bash
set -e
BLUE='\033[1;34m'
YELLOW='\033[1;33m'
GREEN='\033[1;32m'
NC='\033[0m'
echo -e "${BLUE} LOG:${YELLOW} Setting up Rust (Rustup)...${NC}"
# 1. Install Rustup
if ! command -v rustup &> /dev/null; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
fi
# 2. Source Environment
[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env"
# 3. Update to Stable
if command -v cargo &> /dev/null; then
rustup default stable
rustup update
echo -e "${GREEN} LOG: Rust setup complete.$(cargo --version)${NC}"
fi

116
scripts/setup.sh Executable file
View File

@ -0,0 +1,116 @@
#!/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}"

268
setup.sh
View File

@ -1,268 +0,0 @@
#!/bin/bash
set -e
# Variables
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
DOTFILES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Bold Colors
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
RED='\033[1;31m'
GREEN='\033[1;32m'
NC='\033[0m'
# OS Detection
echo -e "${BLUE} LOG:${YELLOW} Checking System...${NC}"
OS="unknown"
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$ID
fi
if [ "$OS" = "unknown" ] || [ -z "$OS" ]; then
echo -e "${RED} ERROR:${NC} Could not detect operating system. /etc/os-release not found or ID not set."
exit 1
fi
# Package Installation
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
)
FINAL_LIST=""
for pkg in "${PACKAGES[@]}"; do
case "$pkg" in
"build-essential")
[ "$OS" == "arch" ] && pkg="base-devel"
[ "$OS" == "ubuntu" ] && pkg="build-essential"
;;
"python")
[ "$OS" == "arch" ] && pkg="python"
[ "$OS" == "ubuntu" ] && pkg="python3 python3-pip python3-venv"
;;
"fd")
[ "$OS" == "arch" ] && pkg="fd"
[ "$OS" == "ubuntu" ] && pkg="fd-find"
;;
"bat")
[ "$OS" == "arch" ] && pkg="bat"
[ "$OS" == "ubuntu" ] && pkg="bat"
;;
"openssl")
[ "$OS" == "arch" ] && pkg="openssl"
[ "$OS" == "ubuntu" ] && pkg="libssl-dev"
;;
"bind")
[ "$OS" == "arch" ] && pkg="bind"
[ "$OS" == "ubuntu" ] && pkg="dnsutils"
;;
*)
esac
FINAL_LIST="$FINAL_LIST $pkg"
done
# Extra packages for specific distros
if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then
FINAL_LIST="$FINAL_LIST eza"
fi
if [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
FINAL_LIST="$FINAL_LIST ca-certificates bsdmainutils pkg-config cmake"
fi
echo -e "${BLUE} LOG:${YELLOW} Installing: ${NC}$FINAL_LIST"
if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then
sudo pacman -S --noconfirm --needed $FINAL_LIST
elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y $FINAL_LIST
fi
if [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
echo -e "${BLUE} LOG:${YELLOW} Fixing Ubuntu binary names...${NC}"
[ -f /usr/bin/fdfind ] && sudo ln -sf /usr/bin/fdfind /usr/local/bin/fd
[ -f /usr/bin/batcat ] && sudo ln -sf /usr/bin/batcat /usr/local/bin/bat
fi
# Docker Installation
if command -v docker &> /dev/null; then
echo -e "${GREEN} LOG: Docker is already installed. Skipping...${NC}"
else
# Check if we are running in WSL
if grep -qEi "(Microsoft|WSL)" /proc/version &> /dev/null; then
echo -e "${RED} LOG: WSL Detected! Skipping Native Docker installation.${NC}"
echo -e "${RED} >>> ACTION REQUIRED: Please install Docker Desktop for Windows.${NC}"
echo -e "${RED} >>> Ensure 'Use WSL 2 based engine' is enabled in Docker settings.${NC}"
else
echo -e "${BLUE} LOG:${YELLOW} Docker not found. Installing Native Docker Engine...${NC}"
# ARCH LINUX
if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then
sudo pacman -S --noconfirm --needed docker docker-compose
sudo systemctl enable --now docker
fi
# UBUNTU / DEBIAN
if [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
echo -e "${BLUE} LOG:${YELLOW} Setting up Official Docker Repository...${NC}"
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
fi
fi
fi
# Install NVM, GVM, Rustup
echo -e "${BLUE} LOG:${YELLOW} Installing NVM, GVM and Rustup...${NC}"
# NVM
if [ ! -d "$HOME/.nvm" ]; then
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
fi
# Go and GVM
wget https://go.dev/dl/go1.25.4.linux-amd64.tar.gz -O /tmp/go1.25.4.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf /tmp/go1.25.4.linux-amd64.tar.gz
rm -f /tmp/go1.25.4.linux-amd64.tar.gz
if [ ! -d "$HOME/.gvm" ]; then
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
fi
# Rustup
if ! command -v rustup &> /dev/null; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
fi
# Install Eza with Cargo
echo -e "${BLUE} LOG:${YELLOW} Installing Eza via Cargo...${NC}"
if ! command -v eza &> /dev/null; then
source "$HOME/.cargo/env"
cargo install eza
fi
# ---------------------------------------------------------------------
# GIT CREDENTIAL CONFIGURATION
# ---------------------------------------------------------------------
echo -e "${BLUE} LOG:${YELLOW} Configuring Git Credentials...${NC}"
if grep -qEi "(Microsoft|WSL)" /proc/version &> /dev/null; then
# Linux Server: Cache credentials for 12 hours
if [ -f "$GCM_WIN" ]; then
git config --global credential.helper "! \"$GCM_WIN\""
fi
else
# Linux Server: Cache credentials for 12 hour
git config --global credential.helper 'cache --timeout=43200' --replace-all
fi
# Docker Group
echo -e "${BLUE} LOG:${YELLOW} Setting up Docker group...${NC}"
if ! getent group docker > /dev/null 2>&1; then
sudo groupadd docker
fi
sudo usermod -aG docker $(whoami)
# Zsh and Oh My Zsh Setup
echo -e "${BLUE} LOG:${YELLOW} Setting up Oh My Zsh...${NC}"
if [ ! -d "$HOME/.oh-my-zsh" ]; then
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
fi
echo -e "${BLUE} LOG:${YELLOW} Installing Zsh plugins...${NC}"
if [ ! -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ]; then
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting"
fi
if [ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ]; then
git clone https://github.com/zsh-users/zsh-autosuggestions "$ZSH_CUSTOM/plugins/zsh-autosuggestions"
fi
# Making Zsh the default shell
echo -e "${BLUE} LOG:${YELLOW} Setting Zsh as the default shell...${NC}"
if [ "$SHELL" != "$(which zsh)" ]; then
sudo chsh -s "$(which zsh)" $(whoami)
fi
# File Cleanup
echo -e "${BLUE} LOG:${YELLOW} Cleaning up old configs...${NC}"
rm -f "$HOME/.zshrc" "$HOME/.zsh_aliases"
# Ensure secrets file exists
echo -e "${BLUE} LOG:${YELLOW} Ensuring secrets file exists...${NC}"
touch "$HOME/.zsh_secrets"
# Stow Dotfiles
echo -e "${BLUE} LOG:${YELLOW} Stowing dotfiles...${NC}"
cd "$DOTFILES_DIR"
stow . --target="$HOME" --ignore="setup.sh" --ignore=".git" --ignore=".gitignore" --ignore="README.md" --ignore=".zsh_secrets" --ignore=".zsh_secrets.example" --ignore="LICENSE" --ignore="Makefile" --ignore="provision.sh" --ignore="storagebox.sh"
# Language Setup
echo -e "${BLUE} LOG:${YELLOW} Finalizing Language Setup...${NC}"
set +e
# 1. Setup Node (NVM)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
if command -v nvm &> /dev/null; then
echo -e "${BLUE} LOG:${YELLOW} Installing Node LTS...${NC}"
nvm install --lts
nvm use --lts
echo -e "${BLUE} LOG:${YELLOW} Installing Global Tools (pnpm, yarn)...${NC}"
npm install -g pnpm yarn || true
fi
# 2. Setup Go (GVM)
unalias cd 2>/dev/null || true
[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"
if command -v gvm &> /dev/null; then
echo -e "${BLUE} LOG:${YELLOW} Installing Go 1.24.11...${NC}"
gvm install go1.24.11 -B
gvm use go1.24.11 --default
if [ $? -eq 0 ]; then
echo -e "${BLUE} LOG:${YELLOW} Go version: $(go version)${NC}"
else
echo -e "${RED} ERROR:${NC} GVM failed to install Go 1.24.11"
fi
fi
# 3. Setup Rust
[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env"
if command -v rustup &> /dev/null; then
echo -e "${BLUE} LOG:${YELLOW} Updating Rust to stable...${NC}"
rustup default stable
rustup update
fi
set -e
# Finish
echo -e "${GREEN} LOG: Setup Complete! Please restart your terminal to apply all changes. ${NC} "