Files
starburst/0-setup-linux.sh
T
2026-07-06 11:09:34 +02:00

275 lines
7.3 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
set -euo pipefail
##########################
# Color helpers (no tput)
##########################
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
PURPLE='\033[0;35m'
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' "$YELLOW"; }
color_cyan() { printf '%b' "$CYAN"; }
color_red() { printf '%b' "$RED"; }
color_green() { printf '%b' "$GREEN"; }
color_reset() { printf '%b' "$RESET"; }
##########################
# OS Detection
##########################
echo
color_yellow
echo "################################################################"
echo "################### Start OS Detection"
echo "################################################################"
color_reset
echo
source /etc/os-release
OS_ID="${ID,,}"
OS_LIKE="${ID_LIKE:-}"
OS_LIKE="${OS_LIKE,,}"
OS_VERSION="${VERSION_ID:-unknown}"
OS_PRETTY="$PRETTY_NAME"
OS=""
case "$OS_ID" in
arch) OS="arch" ;;
debian) OS="debian" ;;
ubuntu) OS="ubuntu" ;;
fedora) OS="fedora" ;;
*)
if [[ "$OS_LIKE" == *"ubuntu"* ]]; then
OS="ubuntu"
elif [[ "$OS_LIKE" == *"arch"* ]]; then
OS="arch"
elif [[ "$OS_LIKE" == *"debian"* ]]; then
OS="debian"
elif [[ "$OS_LIKE" == *"fedora"* || "$OS_LIKE" == *"rhel"* ]]; then
OS="fedora"
fi
;;
esac
if [[ -n "$OS" ]]; then
color_cyan
echo "################################################################################"
echo "Detected OS: $OS ($OS_PRETTY)"
echo "Version: $OS_VERSION"
echo "################################################################################"
color_reset
else
color_red
echo "################################################################################"
echo "ERROR: Unsupported or unknown Linux distribution."
echo "Detected: ID=$OS_ID, ID_LIKE=${OS_LIKE:-empty}"
echo "################################################################################"
color_reset
exit 1
fi
##########################
# Desktop Environment Detection / Selection
##########################
echo
color_yellow
echo "################################################################"
echo "################### Desktop Environment Selection"
echo "################################################################"
color_reset
echo
DE_RAW="${XDG_CURRENT_DESKTOP:-${DESKTOP_SESSION:-}}"
DE=""
case "${DE_RAW,,}" in
*xfce*) DE="xfce" ;;
*plasma*|*kde*) DE="plasma" ;;
*gnome*) DE="gnome" ;;
""|none) DE="" ;;
esac
if [[ -n "$DE" ]]; then
echo
color_cyan
echo "################################################################################"
echo "Detected Desktop Environment: $DE (${DE_RAW})"
echo "################################################################################"
color_reset
else
echo
echo "No Desktop Environment detected. Select one to install:"
while true; do
echo " 1) XFCE"
echo " 2) Plasma"
echo " 3) GNOME"
echo " x) None (default)"
# Added timeout to avoid hanging
if ! read -t 15 -rp "Enter choice [1/2/3/x] (default: x): " choice; then
choice="x"
fi
case "${choice,,}" in
1) DE="xfce"; break ;;
2) DE="plasma"; break ;;
3) DE="gnome"; break ;;
x|"") DE="none"; break ;;
*) echo "Invalid option. Please enter 1, 2, 3, or x." ;;
esac
done
echo
color_cyan
echo "################################################################################"
echo "Selected Desktop Environment: $DE"
echo "################################################################################"
color_reset
fi
##########################
# Tiling Window Manager Selection
##########################
echo
color_yellow
echo "################################################################"
echo "################### Tiling WM Selection"
echo "################################################################"
color_reset
echo
while true; do
echo
echo "Select a tiling window manager:"
echo " 1) CHADWM"
echo " 2) Hyprland"
echo " 3) Niri"
echo " x) None (default)"
if ! read -t 15 -rp "Enter choice [1/2/3/x] (default: x): " choice; then
choice="x"
fi
case "${choice,,}" in
1) TWM="chadwm"; break ;;
2) TWM="hyprland"; break ;;
3) TWM="niri"; break ;;
x|"") TWM="none"; break ;;
*) echo "Invalid option. Please enter 1, 2, 3 or x." ;;
esac
done
echo
color_cyan
echo "################################################################################"
echo "Selected Tiling WM: $TWM"
echo "################################################################################"
color_reset
##########################
# Installation Level Selection
##########################
echo
color_yellow
echo "################################################################"
echo "################### Installation Level Selection"
echo "################################################################"
color_reset
echo
while true; do
echo
echo "Select installation level:"
echo " 1) minimal"
echo " 2) full"
echo " 3) workstation"
echo " 4) server"
if ! read -t 15 -rp "Enter choice [1/2/3/4] (default: 1): " choice; then
choice="1"
fi
case "$choice" in
1|"") INSTALL_LEVEL="minimal"; break ;;
2) INSTALL_LEVEL="full"; break ;;
3) INSTALL_LEVEL="workstation"; break ;;
4) INSTALL_LEVEL="server"; break ;;
*) echo "Invalid option. Please enter 1, 2, 3, or 4." ;;
esac
done
echo
color_cyan
echo "################################################################################"
echo "Selected Installation Level: $INSTALL_LEVEL"
echo "################################################################################"
color_reset
##########################
# Export selections for OS script
##########################
export DETECTED_OS="$OS"
export DETECTED_DE="$DE_RAW"
export SELECTED_DE="$DE"
export SELECTED_TWM="$TWM"
export INSTALL_LEVEL
##########################
# Determine OS script
##########################
case "$OS" in
debian) OS_SCRIPT="./${SCRIPT_VERSION}/debian.sh" ;;
ubuntu) OS_SCRIPT="./${SCRIPT_VERSION}/ubuntu.sh" ;;
arch) OS_SCRIPT="./${SCRIPT_VERSION}/arch.sh" ;;
fedora) OS_SCRIPT="./${SCRIPT_VERSION}/fedora.sh" ;;
*)
color_red
echo
echo "No OS script available for $OS"
color_reset
exit 1
;;
esac
##########################
# Preflight check & run
##########################
if [[ ! -f "$OS_SCRIPT" ]]; then
color_red
echo
echo "ERROR: OS script not found: $OS_SCRIPT"
color_reset
exit 1
fi
if [[ ! -x "$OS_SCRIPT" ]]; then
chmod +x "$OS_SCRIPT"
fi
echo
color_cyan
echo "Running OS script: $OS_SCRIPT"
color_reset
bash "$OS_SCRIPT" || {
color_red
echo
echo "ERROR: OS script failed: $OS_SCRIPT"
color_reset
exit 1
}
echo
color_yellow
echo "################################################################"
echo "End Detection"
echo "################################################################"
color_reset