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 #!/bin/bash
set -uo pipefail 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) # Color helpers (printf-safe, no tput)
#------------------------------------------ #------------------------------------------
@@ -13,21 +37,19 @@ BLUE='\033[0;34m'
GRAY='\033[0;37m' GRAY='\033[0;37m'
BOLD='\033[1m' BOLD='\033[1m'
RESET='\033[0m' RESET='\033[0m'
# Disable colors if output is not a terminal # Disable colors if output is not a terminal
if [ ! -t 1 ]; then if [ ! -t 1 ]; then
RED='' GREEN='' YELLOW='' CYAN='' PURPLE='' BLUE='' GRAY='' BOLD='' RESET='' RED='' GREEN='' YELLOW='' CYAN='' PURPLE='' BLUE='' GRAY='' BOLD='' RESET=''
fi fi
color_yellow() { printf "%b%s%b\n" "$YELLOW" "$*" "$RESET"; } color_yellow() { printf "%b%s%b\n" "$YELLOW" "$*" "$RESET"; }
color_cyan() { printf "%b%s%b\n" "$CYAN" "$*" "$RESET"; } color_cyan() { printf "%b%s%b\n" "$CYAN" "$*" "$RESET"; }
color_red() { printf "%b%s%b\n" "$RED" "$*" "$RESET"; } color_red() { printf "%b%s%b\n" "$RED" "$*" "$RESET"; }
color_green() { printf "%b%s%b\n" "$GREEN" "$*" "$RESET"; } color_green() { printf "%b%s%b\n" "$GREEN" "$*" "$RESET"; }
color_gray() { printf "%b%s%b\n" "$GRAY" "$*" "$RESET"; } color_gray() { printf "%b%s%b\n" "$GRAY" "$*" "$RESET"; }
#------------------------------------------ #------------------------------------------
# Helper functions # Helper functions
#------------------------------------------ #------------------------------------------
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
pause_if_debug() { pause_if_debug() {
if [[ "${DEBUG_MODE:-false}" == "true" ]]; then if [[ "${DEBUG_MODE:-false}" == "true" ]]; then
echo echo
@@ -41,10 +63,8 @@ pause_if_debug() {
echo echo
fi fi
} }
install_packages() { sudo dnf install -y "$@"; } install_packages() { sudo dnf install -y "$@"; }
is_package_installed() { rpm -q "$@" &>/dev/null; } is_package_installed() { rpm -q "$@" &>/dev/null; }
remove_packages() { remove_packages() {
local packages_to_remove=() local packages_to_remove=()
for pkg in "$@"; do for pkg in "$@"; do
@@ -52,35 +72,30 @@ remove_packages() {
packages_to_remove+=("$pkg") packages_to_remove+=("$pkg")
fi fi
done done
if [ ${#packages_to_remove[@]} -gt 0 ]; then if [ ${#packages_to_remove[@]} -gt 0 ]; then
color_cyan "Removing packages: ${packages_to_remove[*]}" color_cyan "Removing packages: ${packages_to_remove[*]}"
sudo dnf remove -y "${packages_to_remove[@]}" sudo dnf remove -y "${packages_to_remove[@]}"
fi fi
} }
#------------------------------------------ #------------------------------------------
# 0 STARTING the script # 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 if [[ "$DEBUG_MODE" == "true" ]]; then
color_red "!!! DEBUG MODE ENABLED !!!" color_red "!!! DEBUG MODE ENABLED !!!"
color_red "The script will pause after each major section." color_red "The script will pause after each major section."
echo echo
fi fi
echo echo
color_yellow "----------------------------------------------------------------" color_yellow "----------------------------------------------------------------"
color_yellow "Script version 1.0" color_yellow "Script version 1.1"
color_yellow "----------------------------------------------------------------" color_yellow "----------------------------------------------------------------"
echo echo
#------------------------------------------ #------------------------------------------
# OS Detection # OS Detection
#------------------------------------------ #------------------------------------------
@@ -89,17 +104,12 @@ color_yellow "----------------------------------------------------------------"
color_yellow "Start OS Detection" color_yellow "Start OS Detection"
color_yellow "----------------------------------------------------------------" color_yellow "----------------------------------------------------------------"
echo echo
source /etc/os-release source /etc/os-release
OS_ID="${ID:-unknown}"; OS_ID="${OS_ID,,}"
OS_ID="${ID,,}" OS_LIKE="${ID_LIKE:-}"; OS_LIKE="${OS_LIKE,,}"
OS_LIKE="${ID_LIKE:-}"
OS_LIKE="${OS_LIKE,,}"
OS_VERSION="${VERSION_ID:-unknown}" OS_VERSION="${VERSION_ID:-unknown}"
OS_PRETTY="$PRETTY_NAME" OS_PRETTY="${PRETTY_NAME:-unknown}"
OS="" OS=""
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
case "$OS_ID" in case "$OS_ID" in
fedora) OS="fedora" ;; fedora) OS="fedora" ;;
*) *)
@@ -108,7 +118,6 @@ case "$OS_ID" in
fi fi
;; ;;
esac esac
if [[ -n "$OS" ]]; then if [[ -n "$OS" ]]; then
color_cyan "----------------------------------------------------------------" color_cyan "----------------------------------------------------------------"
color_cyan "Detected OS: $OS_PRETTY" color_cyan "Detected OS: $OS_PRETTY"
@@ -121,9 +130,14 @@ else
color_red "----------------------------------------------------------------" color_red "----------------------------------------------------------------"
exit 1 exit 1
fi 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 pause_if_debug
#------------------------------------------ #------------------------------------------
# 1 Basic Settings # 1 Basic Settings
#------------------------------------------ #------------------------------------------
@@ -132,7 +146,6 @@ color_yellow "----------------------------------------------------------------"
color_yellow "1 Basic Settings" color_yellow "1 Basic Settings"
color_yellow "----------------------------------------------------------------" color_yellow "----------------------------------------------------------------"
echo echo
#------------------------------------------ #------------------------------------------
# 1.1 Ensure base is ready for installation # 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..." color_yellow "curl is not installed. Installing..."
install_packages curl install_packages curl
fi 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 pause_if_debug
#------------------------------------------ #------------------------------------------
# 1.2 Update and Enable Repos + Flatpak # 1.2 Update and Enable Repos + Flatpak
#------------------------------------------ #------------------------------------------
color_cyan "Optimizing DNF for speed..." color_cyan "Optimizing DNF for speed..."
# 1. Increase parallel downloads (allows downloading multiple packages at once) # 1. Increase parallel downloads (allows downloading multiple packages at once)
# 2. Set dnf to set YES as default instead of NO # 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 max_parallel_downloads=20
sudo dnf config-manager setopt defaultyes=True sudo dnf config-manager setopt defaultyes=True
color_green "DNF optimized. Refreshing metadata..." color_green "DNF optimized. Refreshing metadata..."
sudo dnf makecache --refresh sudo dnf makecache --refresh
color_cyan "Enabling RPM Fusion repositories for Fedora $(rpm -E %fedora)..."
# Define the version variable for readability # Define the version variable for readability
FEDORA_VER=$(rpm -E %fedora) FEDORA_VER=$(rpm -E %fedora)
color_cyan "Enabling RPM Fusion repositories for Fedora ${FEDORA_VER}..."
color_yellow "Checking for updates and sources..."
sudo dnf check-update || true
# Check if flatpak is installed, if not, install it # Check if flatpak is installed, if not, install it
if ! command -v flatpak &> /dev/null; then if ! command -v flatpak &> /dev/null; then
color_yellow "Flatpak not found. Installing..." color_yellow "Flatpak not found. Installing..."
sudo dnf install -y flatpak sudo dnf install -y flatpak
fi 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 \ sudo dnf install -y \
"https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-${FEDORA_VER}.noarch.rpm" \ "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" "https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-${FEDORA_VER}.noarch.rpm"
color_cyan "Enabling Flathub (system-wide)..."
color_cyan "Enabling full Flathub support..." # --if-not-exists keeps this idempotent on re-runs
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo sudo flatpak remote-add --if-not-exists --system flathub https://dl.flathub.org/repo/flathub.flatpakrepo
# Update the system # Update the system
color_gray "Updating the system" color_gray "Updating the system"
echohttps://git.ku-it.org/terrabeam/starburst.git echo
sudo dnf update -y sudo dnf update -y
pause_if_debug pause_if_debug
#------------------------------------------ #------------------------------------------
# Tiling Window Manager Selection # 2 Tiling Window Manager Selection
#------------------------------------------ #------------------------------------------
echo echo
color_yellow "----------------------------------------------------------------" color_yellow "----------------------------------------------------------------"
color_yellow "Tiling WM Selection" color_yellow "2 Tiling WM Selection"
color_yellow "----------------------------------------------------------------" color_yellow "----------------------------------------------------------------"
echo echo
while true; do while true; do
echo echo
color_gray "Select a tiling window manager:" 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 if ! read -t 15 -rp "Enter choice [1/2/3/4/x] (default: x): " choice; then
choice="x" choice="x"
fi fi
case "${choice,,}" in case "${choice,,}" in
1) TWM="chadwm"; break ;; 1) TWM="chadwm"; break ;;
2) TWM="hyprland"; break ;; 2) TWM="hyprland"; break ;;
@@ -219,16 +217,14 @@ while true; do
*) echo "Invalid option. Please enter 1, 2, 3, 4 or x." ;; *) echo "Invalid option. Please enter 1, 2, 3, 4 or x." ;;
esac esac
done done
echo echo
color_cyan "----------------------------------------------------------------" color_cyan "----------------------------------------------------------------"
color_cyan "Selected Tiling WM: $TWM" color_cyan "Selected Tiling WM: $TWM"
color_cyan "----------------------------------------------------------------" color_cyan "----------------------------------------------------------------"
export TWM
pause_if_debug pause_if_debug
#------------------------------------------ #------------------------------------------
# 5. Tiling Window Manager installation # 3 Tiling Window Manager installation
#------------------------------------------ #------------------------------------------
case "$TWM" in case "$TWM" in
chadwm|hyprland|mango|niri) chadwm|hyprland|mango|niri)
@@ -236,7 +232,8 @@ case "$TWM" in
SCRIPT_NAME="$SCRIPT_DIR/${TWM}.sh" SCRIPT_NAME="$SCRIPT_DIR/${TWM}.sh"
if [[ -f "$SCRIPT_NAME" ]]; then if [[ -f "$SCRIPT_NAME" ]]; then
color_cyan "Running $SCRIPT_NAME" 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 else
color_red "Error: $SCRIPT_NAME not found!" color_red "Error: $SCRIPT_NAME not found!"
exit 1 exit 1
@@ -246,14 +243,11 @@ case "$TWM" in
color_gray "No tiling window manager selected, skipping TWM installation." color_gray "No tiling window manager selected, skipping TWM installation."
;; ;;
esac esac
pause_if_debug pause_if_debug
echo echo
color_yellow "----------------------------------------------------------------" color_yellow "----------------------------------------------------------------"
color_yellow "End Detection" color_yellow "End Detection"
color_yellow "----------------------------------------------------------------" color_yellow "----------------------------------------------------------------"
color_green "Fedora setup complete." color_green "Fedora setup complete."
color_red "The installation has finished. A reboot is recommended." color_red "The installation has finished. A reboot is recommended."
# Reboots are dangerous to automate; we use a shorter timeout and default to No # Reboots are dangerous to automate; we use a shorter timeout and default to No