Fedora Setup

This commit is contained in:
MangoPig
2026-05-29 15:57:17 +01:00
parent d5bcda270d
commit 3f753d0dd0
8 changed files with 338 additions and 98 deletions

View File

@@ -1,19 +1,37 @@
# Makefile
REBOOT_MARKER := .setup-reboot-required
# Default target
all: stow
# Full Setup
setup:
bash ./scripts/base.sh
bash ./scripts/node.sh
bash ./scripts/go.sh
bash ./scripts/rust.sh
bash ./scripts/python.sh
bash ./scripts/r.sh
make clean
make stow
@echo "Full setup completed."
@rm -f $(REBOOT_MARKER); \
bash ./scripts/base.sh; \
if [ -f $(REBOOT_MARKER) ]; then \
rm -f $(REBOOT_MARKER); \
echo "Package layering finished. Reboot, then rerun make setup."; \
exit 0; \
fi; \
bash ./scripts/node.sh; \
bash ./scripts/go.sh; \
bash ./scripts/rust.sh; \
bash ./scripts/python.sh; \
if [ -f $(REBOOT_MARKER) ]; then \
rm -f $(REBOOT_MARKER); \
echo "Package layering finished. Reboot, then rerun make setup."; \
exit 0; \
fi; \
bash ./scripts/r.sh; \
if [ -f $(REBOOT_MARKER) ]; then \
rm -f $(REBOOT_MARKER); \
echo "Package layering finished. Reboot, then rerun make setup."; \
exit 0; \
fi; \
$(MAKE) clean; \
$(MAKE) stow; \
echo "Full setup completed."
base:
bash ./scripts/base.sh
@@ -34,9 +52,6 @@ update:
git pull origin main
make setup
base:
bash ./scripts/base.sh
# Language Setups
node:
bash ./scripts/node.sh
@@ -73,3 +88,8 @@ test-arch:
@echo "Spawning Arch Container..."
docker run -it --rm -e TERM=xterm-256color -v $(PWD):/root/dotfiles archlinux:latest \
bash -c "pacman -Sy --noconfirm base-devel git make sudo && cd /root/dotfiles && make setup"
test-fedora:
@echo "Spawning Fedora Container..."
docker run -it --rm -e TERM=xterm-256color -v $(PWD):/root/dotfiles fedora:latest \
bash -c "dnf install -y git make sudo curl which passwd procps-ng && cd /root/dotfiles && make setup"

View File

@@ -12,15 +12,10 @@ NC='\033[0m'
DOTFILES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
REPO_ROOT="$(dirname "$DOTFILES_DIR")"
source "$DOTFILES_DIR/lib/distro.sh"
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
@@ -42,70 +37,118 @@ PACKAGES=(
bind nmap socat tcpdump net-tools
strace gdb hexyl
ninja-build libcurl4-openssl-dev
just
)
FINAL_LIST=""
FINAL_PACKAGES=()
for pkg in "${PACKAGES[@]}"; do
case "$pkg" in
"build-essential")
[ "$OS" == "arch" ] && pkg="base-devel"
[ "$OS" == "ubuntu" ] && pkg="build-essential"
if is_arch_family; then
FINAL_PACKAGES+=(base-devel)
elif is_debian_family; then
FINAL_PACKAGES+=(build-essential)
elif is_fedora_family; then
FINAL_PACKAGES+=(gcc gcc-c++ make patch)
fi
continue
;;
"python")
[ "$OS" == "arch" ] && pkg="python"
[ "$OS" == "ubuntu" ] && pkg="python3 python3-pip python3-venv"
if is_arch_family; then
FINAL_PACKAGES+=(python)
elif is_debian_family; then
FINAL_PACKAGES+=(python3 python3-pip python3-venv)
elif is_fedora_family; then
FINAL_PACKAGES+=(python3 python3-pip)
fi
continue
;;
"fd")
[ "$OS" == "arch" ] && pkg="fd"
[ "$OS" == "ubuntu" ] && pkg="fd-find"
if is_arch_family; then
FINAL_PACKAGES+=(fd)
elif is_debian_family || is_fedora_family; then
FINAL_PACKAGES+=(fd-find)
fi
continue
;;
"bat")
[ "$OS" == "arch" ] && pkg="bat"
[ "$OS" == "ubuntu" ] && pkg="bat"
FINAL_PACKAGES+=(bat)
continue
;;
"openssl")
[ "$OS" == "arch" ] && pkg="openssl"
[ "$OS" == "ubuntu" ] && pkg="libssl-dev"
if is_arch_family; then
FINAL_PACKAGES+=(openssl)
elif is_debian_family; then
FINAL_PACKAGES+=(libssl-dev)
elif is_fedora_family; then
FINAL_PACKAGES+=(openssl openssl-devel)
fi
continue
;;
"bind")
[ "$OS" == "arch" ] && pkg="bind"
[ "$OS" == "ubuntu" ] && pkg="dnsutils"
if is_arch_family; then
FINAL_PACKAGES+=(bind)
elif is_debian_family; then
FINAL_PACKAGES+=(dnsutils)
elif is_fedora_family; then
FINAL_PACKAGES+=(bind-utils)
fi
continue
;;
"ninja-build")
[ "$OS" == "arch" ] && pkg="ninja"
[ "$OS" == "ubuntu" ] && pkg="ninja-build"
if is_arch_family; then
FINAL_PACKAGES+=(ninja)
elif is_debian_family || is_fedora_family; then
FINAL_PACKAGES+=(ninja-build)
fi
continue
;;
"libcurl4-openssl-dev")
[ "$OS" == "arch" ] && pkg="curl"
[ "$OS" == "ubuntu" ] && pkg="libcurl4-openssl-dev"
if is_arch_family; then
FINAL_PACKAGES+=(curl)
elif is_debian_family; then
FINAL_PACKAGES+=(libcurl4-openssl-dev)
elif is_fedora_family; then
FINAL_PACKAGES+=(libcurl-devel)
fi
continue
;;
"gnupg")
if is_fedora_family; then
FINAL_PACKAGES+=(gnupg2)
else
FINAL_PACKAGES+=(gnupg)
fi
continue
;;
*)
esac
FINAL_LIST="$FINAL_LIST $pkg"
FINAL_PACKAGES+=("$pkg")
done
if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then
FINAL_LIST="$FINAL_LIST"
if is_debian_family; then
FINAL_PACKAGES+=(ca-certificates bsdmainutils pkg-config cmake)
fi
if [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
FINAL_LIST="$FINAL_LIST ca-certificates bsdmainutils pkg-config cmake"
if is_fedora_family; then
FINAL_PACKAGES+=(ca-certificates pkgconf-pkg-config cmake)
fi
echo -e "${BLUE} LOG:${YELLOW} Installing: ${NC}$FINAL_LIST"
echo -e "${BLUE} LOG:${YELLOW} Installing: ${NC}${FINAL_PACKAGES[*]}"
if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then
sudo pacman -S --noconfirm --needed $FINAL_LIST
install_status=0
install_packages "${FINAL_PACKAGES[@]}" || install_status=$?
elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y $FINAL_LIST
if [ "$install_status" -eq 42 ]; then
exit 0
elif [ "$install_status" -ne 0 ]; then
exit "$install_status"
fi
if [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
echo -e "${BLUE} LOG:${YELLOW} Fixing Ubuntu binary names...${NC}"
if is_debian_family || is_fedora_family; then
echo -e "${BLUE} LOG:${YELLOW} Fixing fd/bat binary names when needed...${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
@@ -120,6 +163,23 @@ if ! command -v rclone &> /dev/null; then
curl https://rclone.org/install.sh | sudo bash
fi
if ! command -v earthly &> /dev/null; then
echo -e "${BLUE} LOG:${YELLOW} Installing Earthly CLI...${NC}"
case "$ARCH" in
x86_64)
EARTHLY_ARCH="amd64"
;;
aarch64)
EARTHLY_ARCH="arm64"
;;
esac
curl -fLsS "https://github.com/earthly/earthly/releases/latest/download/earthly-linux-${EARTHLY_ARCH}" \
-o "$HOME/.local/bin/earthly"
chmod +x "$HOME/.local/bin/earthly"
fi
# Docker Installation
if command -v docker &> /dev/null; then
echo -e "${GREEN} LOG: Docker is already installed.${NC}"
@@ -129,16 +189,26 @@ else
echo -e "${RED} >>> Please install Docker Desktop on Windows.${NC}"
else
echo -e "${BLUE} LOG:${YELLOW} Installing Native Docker...${NC}"
if [ "$OS" == "arch" ]; then
if is_arch_family; then
sudo pacman -S --noconfirm --needed docker docker-compose
sudo systemctl enable --now docker
elif [ "$OS" == "ubuntu" ]; then
elif is_debian_family; then
curl -fsSL https://get.docker.com | sh
elif is_fedora_family; then
if is_atomic_fedora; then
echo -e "${YELLOW} NOTE:${NC} Skipping native Docker auto-install on rpm-ostree systems."
echo -e "${YELLOW} NOTE:${NC} After reboot, install your preferred container runtime separately if needed."
else
sudo dnf install -y moby-engine docker-compose
sudo systemctl enable --now docker
fi
fi
# Add user to group
if getent group docker >/dev/null 2>&1; then
sudo usermod -aG docker $(whoami)
fi
fi
fi
# 4. Zsh & Configuration

View File

@@ -9,18 +9,27 @@ YELLOW='\033[1;33m'
GREEN='\033[1;32m'
NC='\033[0m'
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$ID
fi
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$SCRIPT_DIR/lib/distro.sh"
echo -e "${BLUE} LOG:${YELLOW} Setting up C++ Tooling (LLVM/Clang)...${NC}"
if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then
sudo pacman -S --noconfirm --needed clang cmake ninja lldb gdb
elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y clang cmake ninja-build lldb gdb
if is_arch_family; then
CPP_PACKAGES=(clang cmake ninja lldb gdb)
elif is_debian_family || is_fedora_family; then
CPP_PACKAGES=(clang cmake ninja-build lldb gdb)
else
echo -e "${RED} ERROR:${NC} Unsupported OS: $OS"
exit 1
fi
install_status=0
install_packages "${CPP_PACKAGES[@]}" || install_status=$?
if [ "$install_status" -eq 42 ]; then
exit 0
elif [ "$install_status" -ne 0 ]; then
exit "$install_status"
fi
echo -e "${GREEN} SUCCESS:${NC} C++ Environment Ready."

View File

@@ -13,6 +13,21 @@ NC='\033[0m'
export GVM_ROOT="$HOME/.programming/go"
BOOTSTRAP_GO="$GVM_ROOT/bootstrap"
ARCH="$(uname -m)"
case "$ARCH" in
x86_64)
GO_BOOTSTRAP_ARCH="amd64"
;;
aarch64)
GO_BOOTSTRAP_ARCH="arm64"
;;
*)
echo -e "${RED} ERROR:${NC} Unsupported architecture for Go bootstrap: $ARCH"
exit 1
;;
esac
echo -e "${BLUE} LOG:${YELLOW} Setting up Go and GVM in ${GVM_ROOT}...${NC}"
if [ ! -d "$GVM_ROOT/scripts" ]; then
@@ -32,7 +47,7 @@ if [ ! -d "$BOOTSTRAP_GO" ]; then
echo -e "${BLUE} LOG:${YELLOW} Downloading Bootstrap Go...${NC}"
mkdir -p "$BOOTSTRAP_GO"
wget -q https://go.dev/dl/go1.20.5.linux-amd64.tar.gz -O /tmp/go-bootstrap.tar.gz
wget -q "https://go.dev/dl/go1.20.5.linux-${GO_BOOTSTRAP_ARCH}.tar.gz" -O /tmp/go-bootstrap.tar.gz
tar -C "$BOOTSTRAP_GO" -xzf /tmp/go-bootstrap.tar.gz --strip-components=1
rm /tmp/go-bootstrap.tar.gz
@@ -63,4 +78,3 @@ fi
gvm use "$TARGET_VER" --default
echo -e "${GREEN} SUCCESS:${NC} Go setup completed."

84
scripts/lib/distro.sh Normal file
View File

@@ -0,0 +1,84 @@
#!/bin/bash
# Shared distro helpers for install scripts.
SCRIPT_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="${REPO_ROOT:-$(dirname "$(dirname "$SCRIPT_LIB_DIR")")}"
REBOOT_MARKER="${REBOOT_MARKER:-$REPO_ROOT/.setup-reboot-required}"
if [ -f /etc/os-release ]; then
. /etc/os-release
OS="${ID}"
OS_LIKE="${ID_LIKE:-}"
else
echo "Unable to detect operating system: /etc/os-release not found."
return 1 2>/dev/null || exit 1
fi
is_arch_family() {
[[ "$OS" == "arch" || "$OS" == "manjaro" || " $OS_LIKE " == *" arch "* ]]
}
is_debian_family() {
[[ "$OS" == "ubuntu" || "$OS" == "debian" || " $OS_LIKE " == *" debian "* ]]
}
is_fedora_family() {
[[ "$OS" == "fedora" || "$OS" == "bazzite" || " $OS_LIKE " == *" fedora "* || " $OS_LIKE " == *" rhel "* ]]
}
is_atomic_fedora() {
is_fedora_family && command -v rpm-ostree >/dev/null 2>&1 && [ -f /run/ostree-booted ]
}
mark_reboot_required() {
touch "$REBOOT_MARKER"
echo ""
echo " REBOOT REQUIRED: Fedora atomic package layering finished."
echo " Please reboot, then rerun the same make target."
echo ""
}
install_packages() {
local packages=("$@")
if [ ${#packages[@]} -eq 0 ]; then
return 0
fi
if is_arch_family; then
sudo pacman -S --noconfirm --needed "${packages[@]}"
return 0
fi
if is_debian_family; then
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "${packages[@]}"
return 0
fi
if is_fedora_family; then
if is_atomic_fedora; then
local missing_packages=()
local pkg
for pkg in "${packages[@]}"; do
rpm -q "$pkg" >/dev/null 2>&1 || missing_packages+=("$pkg")
done
if [ ${#missing_packages[@]} -eq 0 ]; then
return 0
fi
sudo rpm-ostree install "${missing_packages[@]}"
mark_reboot_required
return 42
fi
sudo dnf install -y "${packages[@]}"
return 0
fi
echo "Unsupported OS: $OS"
return 1
}

View File

@@ -12,6 +12,8 @@ NC='\033[0m'
DEFAULT_USER="mangopig"
DEFAULT_UID="1000"
DEFAULT_GID="1000"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$SCRIPT_DIR/lib/distro.sh"
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}Please run this script as root.${NC}"
@@ -19,10 +21,6 @@ if [ "$EUID" -ne 0 ]; then
fi
echo -e "${YELLOW}LOG: Detecting OS...${NC}"
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$ID
fi
echo -e "${YELLOW}LOG: Determining primary IPv4 address...${NC}"
if command -v hostname >/dev/null 2>&1 && hostname -I >/dev/null 2>&1; then
@@ -37,18 +35,29 @@ fi
echo -e "${YELLOW}LOG: Updating system and installing base tools...${NC}"
if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then
if is_arch_family; then
pacman -Sy --noconfirm git make curl zsh sudo
SUDO_GROUP="wheel"
elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
elif is_debian_family; then
apt-get update
apt-get install -y git make curl sudo zsh
SUDO_GROUP="sudo"
elif is_fedora_family; then
if is_atomic_fedora; then
echo -e "${RED}Provisioning on Fedora atomic systems is not supported by this root script.${NC}"
echo -e "${RED}Use the normal user workflow and run make setup after login instead.${NC}"
exit 1
fi
dnf install -y git make curl sudo zsh
SUDO_GROUP="wheel"
else
echo -e "${RED}Unsupported OS: $OS${NC}"
exit 1
fi
ZSH_PATH="$(command -v zsh)"
if [ -t 0 ]; then
echo -e "${GREEN}---------------------------------------${NC}"
echo -e "${GREEN} USER PROVISIONING WIZARD ${NC}"
@@ -96,7 +105,7 @@ echo -e "${YELLOW}LOG: Configuring passwordless sudo...${NC}"
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > "/etc/sudoers.d/90-$USERNAME"
chmod 0440 "/etc/sudoers.d/90-$USERNAME"
if [ "$OS" == "arch" ]; then
if is_arch_family || is_fedora_family; then
sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
fi

View File

@@ -9,22 +9,31 @@ GREEN='\033[1;32m'
RED='\033[1;31m'
NC='\033[0m'
# OS Detection
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$ID
fi
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$SCRIPT_DIR/lib/distro.sh"
# Install Build Dependencies
if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then
if is_arch_family; then
echo -e "${BLUE} LOG:${YELLOW} Installing Arch build dependencies...${NC}"
sudo pacman -S --noconfirm --needed base-devel openssl zlib xz tk libffi bzip2 git
elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
PYTHON_BUILD_DEPS=(base-devel openssl zlib xz tk libffi bzip2 git)
elif is_debian_family; then
echo -e "${BLUE} LOG:${YELLOW} Installing Debian build dependencies...${NC}"
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev git
PYTHON_BUILD_DEPS=(make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev git)
elif is_fedora_family; then
echo -e "${BLUE} LOG:${YELLOW} Installing Fedora build dependencies...${NC}"
PYTHON_BUILD_DEPS=(make gcc gcc-c++ patch zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz xz-devel ncurses-devel findutils git)
else
echo -e "${RED} ERROR:${NC} Unsupported OS: $OS"
exit 1
fi
install_status=0
install_packages "${PYTHON_BUILD_DEPS[@]}" || install_status=$?
if [ "$install_status" -eq 42 ]; then
exit 0
elif [ "$install_status" -ne 0 ]; then
exit "$install_status"
fi
# Define the Black Box Location

View File

@@ -9,30 +9,38 @@ GREEN='\033[1;32m'
RED='\033[1;31m'
NC='\033[0m'
# OS Detection
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$ID
fi
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$SCRIPT_DIR/lib/distro.sh"
echo -e "${BLUE} LOG:${YELLOW} Detecting R installation strategy for $OS...${NC}"
if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then
if is_arch_family; then
echo -e "${BLUE} LOG:${YELLOW} Arch Linux detected. Using system R (Pacman)...${NC}"
# Install R + Build Tools
sudo pacman -S --noconfirm --needed r gcc-fortran curl tar
install_status=0
install_packages r gcc-fortran curl tar || install_status=$?
if [ "$install_status" -eq 42 ]; then
exit 0
elif [ "$install_status" -ne 0 ]; then
exit "$install_status"
fi
echo -e "${GREEN} SUCCESS:${NC} R installed via Pacman."
R_BIN="R"
elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
elif is_debian_family; then
echo -e "${BLUE} LOG:${YELLOW} Installing Debian build dependencies...${NC}"
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y gfortran curl tar ca-certificates
install_status=0
install_packages gfortran curl tar ca-certificates || install_status=$?
if [ "$install_status" -eq 42 ]; then
exit 0
elif [ "$install_status" -ne 0 ]; then
exit "$install_status"
fi
if ! command -v rig >/dev/null 2>&1; then
echo -e "${BLUE} LOG:${YELLOW} Installing Rig for Debian/Ubuntu...${NC}"
@@ -69,6 +77,23 @@ elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
fi
R_BIN="rig run"
elif is_fedora_family; then
echo -e "${BLUE} LOG:${YELLOW} Fedora detected. Using system R...${NC}"
install_status=0
install_packages R gcc-gfortran curl tar || install_status=$?
if [ "$install_status" -eq 42 ]; then
exit 0
elif [ "$install_status" -ne 0 ]; then
exit "$install_status"
fi
R_BIN="R"
else
echo -e "${RED} ERROR:${NC} Unsupported OS: $OS"
exit 1
fi
echo -e "${BLUE} LOG:${YELLOW} Installing 'renv' package globally...${NC}"