corrections

This commit is contained in:
2026-10-27 10:13:22 +01:00
parent 4f59afbac1
commit b9c86feba5
+57 -63
View File
@@ -1,6 +1,30 @@
#!/bin/bash
set -uo pipefail
#------------------------------------------
# Argument parsing (must come before anything reads DEBUG_MODE)
#------------------------------------------
DEBUG_MODE=false
for arg in "$@"; do
case "$arg" in
-d|--debug) DEBUG_MODE=true ;;
-h|--help)
cat <<'EOF'
Usage: ./setup.sh [-d|--debug]
-d, --debug Pause after each section instead of aborting on error
-h, --help Show this help
EOF
exit 0
;;
*) echo "Unknown argument: $arg (try --help)" >&2; exit 2 ;;
esac
done
export DEBUG_MODE
# Abort on error unless we are walking through it step by step
if [[ "$DEBUG_MODE" == "true" ]]; then
set +e
else
set -e
fi
#------------------------------------------
# Color helpers (printf-safe, no tput)
#------------------------------------------
@@ -13,21 +37,19 @@ BLUE='\033[0;34m'
GRAY='\033[0;37m'
BOLD='\033[1m'
RESET='\033[0m'
# Disable colors if output is not a terminal
if [ ! -t 1 ]; then
RED='' GREEN='' YELLOW='' CYAN='' PURPLE='' BLUE='' GRAY='' BOLD='' RESET=''
fi
color_yellow() { printf "%b%s%b\n" "$YELLOW" "$*" "$RESET"; }
color_cyan() { printf "%b%s%b\n" "$CYAN" "$*" "$RESET"; }
color_red() { printf "%b%s%b\n" "$RED" "$*" "$RESET"; }
color_green() { printf "%b%s%b\n" "$GREEN" "$*" "$RESET"; }
color_gray() { printf "%b%s%b\n" "$GRAY" "$*" "$RESET"; }
#------------------------------------------
# Helper functions
#------------------------------------------
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
pause_if_debug() {
if [[ "${DEBUG_MODE:-false}" == "true" ]]; then
echo
@@ -41,10 +63,8 @@ pause_if_debug() {
echo
fi
}
install_packages() { sudo dnf install -y "$@"; }
is_package_installed() { rpm -q "$@" &>/dev/null; }
remove_packages() {
local packages_to_remove=()
for pkg in "$@"; do
@@ -52,35 +72,30 @@ remove_packages() {
packages_to_remove+=("$pkg")
fi
done
if [ ${#packages_to_remove[@]} -gt 0 ]; then
color_cyan "Removing packages: ${packages_to_remove[*]}"
sudo dnf remove -y "${packages_to_remove[@]}"
fi
}
#------------------------------------------
# 0 STARTING the script
#------------------------------------------
#------------------------------------------
# Script Version 1.0
# Script Version 1.1
#------------------------------------------
clear # Wipe the terminal history view cleanly for the main menu execution
# Wipe the terminal history view cleanly. Guarded: without TERM (cron, piped
# installs, ssh without a tty) `clear` fails and would abort the whole run.
clear 2>/dev/null || true
if [[ "$DEBUG_MODE" == "true" ]]; then
color_red "!!! DEBUG MODE ENABLED !!!"
color_red "The script will pause after each major section."
echo
fi
echo
color_yellow "----------------------------------------------------------------"
color_yellow "Script version 1.0"
color_yellow "Script version 1.1"
color_yellow "----------------------------------------------------------------"
echo
#------------------------------------------
# OS Detection
#------------------------------------------
@@ -89,17 +104,12 @@ color_yellow "----------------------------------------------------------------"
color_yellow "Start OS Detection"
color_yellow "----------------------------------------------------------------"
echo
source /etc/os-release
OS_ID="${ID,,}"
OS_LIKE="${ID_LIKE:-}"
OS_LIKE="${OS_LIKE,,}"
OS_ID="${ID:-unknown}"; OS_ID="${OS_ID,,}"
OS_LIKE="${ID_LIKE:-}"; OS_LIKE="${OS_LIKE,,}"
OS_VERSION="${VERSION_ID:-unknown}"
OS_PRETTY="$PRETTY_NAME"
OS_PRETTY="${PRETTY_NAME:-unknown}"
OS=""
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
case "$OS_ID" in
fedora) OS="fedora" ;;
*)
@@ -108,7 +118,6 @@ case "$OS_ID" in
fi
;;
esac
if [[ -n "$OS" ]]; then
color_cyan "----------------------------------------------------------------"
color_cyan "Detected OS: $OS_PRETTY"
@@ -121,9 +130,14 @@ else
color_red "----------------------------------------------------------------"
exit 1
fi
# Minimum supported release: this repo targets Fedora 44 and newer.
FEDORA_REL=$(rpm -E %fedora)
if [[ "$FEDORA_REL" =~ ^[0-9]+$ ]] && (( FEDORA_REL < 44 )); then
color_red "$OS_PRETTY reports release $FEDORA_REL, but this setup targets Fedora 44+."
color_red "Refusing to continue. Re-run on F44 or newer."
exit 1
fi
pause_if_debug
#------------------------------------------
# 1 Basic Settings
#------------------------------------------
@@ -132,7 +146,6 @@ color_yellow "----------------------------------------------------------------"
color_yellow "1 Basic Settings"
color_yellow "----------------------------------------------------------------"
echo
#------------------------------------------
# 1.1 Ensure base is ready for installation
#------------------------------------------
@@ -140,63 +153,49 @@ if ! command -v curl >/dev/null 2>&1; then
color_yellow "curl is not installed. Installing..."
install_packages curl
fi
# config-manager lives in dnf5-plugins; make sure it is present before using it
if ! dnf config-manager --help >/dev/null 2>&1; then
color_yellow "dnf config-manager missing. Installing dnf5-plugins..."
install_packages dnf5-plugins
fi
pause_if_debug
#------------------------------------------
# 1.2 Update and Enable Repos + Flatpak
#------------------------------------------
color_cyan "Optimizing DNF for speed..."
# 1. Increase parallel downloads (allows downloading multiple packages at once)
# 2. Set dnf to set YES as default instead of NO
sudo dnf config-manager setopt max_parallel_downloads=20
sudo dnf config-manager setopt defaultyes=True
color_green "DNF optimized. Refreshing metadata..."
sudo dnf makecache --refresh
color_cyan "Enabling RPM Fusion repositories for Fedora $(rpm -E %fedora)..."
# Define the version variable for readability
FEDORA_VER=$(rpm -E %fedora)
color_yellow "Checking for updates and sources..."
sudo dnf check-update || true
color_cyan "Enabling RPM Fusion repositories for Fedora ${FEDORA_VER}..."
# Check if flatpak is installed, if not, install it
if ! command -v flatpak &> /dev/null; then
color_yellow "Flatpak not found. Installing..."
sudo dnf install -y flatpak
fi
color_cyan "Enabling Flathub..."
# Using --if-not-exists is good practice to prevent errors on re-runs
sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
sudo dnf install -y \
"https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-${FEDORA_VER}.noarch.rpm" \
"https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-${FEDORA_VER}.noarch.rpm"
color_cyan "Enabling full Flathub support..."
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
color_cyan "Enabling Flathub (system-wide)..."
# --if-not-exists keeps this idempotent on re-runs
sudo flatpak remote-add --if-not-exists --system flathub https://dl.flathub.org/repo/flathub.flatpakrepo
# Update the system
color_gray "Updating the system"
echohttps://git.ku-it.org/terrabeam/starburst.git
echo
sudo dnf update -y
pause_if_debug
#------------------------------------------
# Tiling Window Manager Selection
# 2 Tiling Window Manager Selection
#------------------------------------------
echo
color_yellow "----------------------------------------------------------------"
color_yellow "Tiling WM Selection"
color_yellow "2 Tiling WM Selection"
color_yellow "----------------------------------------------------------------"
echo
while true; do
echo
color_gray "Select a tiling window manager:"
@@ -209,7 +208,6 @@ while true; do
if ! read -t 15 -rp "Enter choice [1/2/3/4/x] (default: x): " choice; then
choice="x"
fi
case "${choice,,}" in
1) TWM="chadwm"; break ;;
2) TWM="hyprland"; break ;;
@@ -219,16 +217,14 @@ while true; do
*) echo "Invalid option. Please enter 1, 2, 3, 4 or x." ;;
esac
done
echo
color_cyan "----------------------------------------------------------------"
color_cyan "Selected Tiling WM: $TWM"
color_cyan "----------------------------------------------------------------"
export TWM
pause_if_debug
#------------------------------------------
# 5. Tiling Window Manager installation
# 3 Tiling Window Manager installation
#------------------------------------------
case "$TWM" in
chadwm|hyprland|mango|niri)
@@ -236,7 +232,8 @@ case "$TWM" in
SCRIPT_NAME="$SCRIPT_DIR/${TWM}.sh"
if [[ -f "$SCRIPT_NAME" ]]; then
color_cyan "Running $SCRIPT_NAME"
source "$SCRIPT_NAME"
# Run in a subshell: a module's set -e / exit cannot leak into this script
( source "$SCRIPT_NAME" )
else
color_red "Error: $SCRIPT_NAME not found!"
exit 1
@@ -246,14 +243,11 @@ case "$TWM" in
color_gray "No tiling window manager selected, skipping TWM installation."
;;
esac
pause_if_debug
echo
color_yellow "----------------------------------------------------------------"
color_yellow "End Detection"
color_yellow "----------------------------------------------------------------"
color_green "Fedora setup complete."
color_red "The installation has finished. A reboot is recommended."
# Reboots are dangerous to automate; we use a shorter timeout and default to No