Fedora Setup

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

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,15 +189,25 @@ 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
sudo usermod -aG docker $(whoami)
if getent group docker >/dev/null 2>&1; then
sudo usermod -aG docker $(whoami)
fi
fi
fi
@@ -170,4 +240,4 @@ if [ "$SHELL" != "$(which zsh)" ]; then
sudo chsh -s "$(which zsh)" $(whoami)
fi
echo -e "${GREEN} LOG: Base System Setup Complete.${NC}"
echo -e "${GREEN} LOG: Base System Setup Complete.${NC}"