v3-revamp

This commit is contained in:
2026-07-06 17:01:17 +02:00
parent 301d383001
commit 3fceca6056
+215 -206
View File
@@ -58,236 +58,245 @@ pause_if_debug() {
fi fi
} }
#------------------------------------------ # ==========================================
# Script Version 3.0 # ADD THIS GUARD WRAPPER HERE:
#------------------------------------------ # ==========================================
echo if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
color_yellow "----------------------------------------------------------------"
color_yellow "Script version 3.0"
color_yellow "----------------------------------------------------------------"
echo
#------------------------------------------ # Put your entire interactive menu, OS detection, exports,
# OS Detection # and the logic that runs the OS_SCRIPT inside here.
#------------------------------------------
echo
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_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 "----------------------------------------------------------------"
color_cyan "Detected OS:" "$OS_PRETTY"
color_cyan "Version:" "$OS_VERSION"
color_cyan "----------------------------------------------------------------"
else
color_red "----------------------------------------------------------------"
color_red "ERROR: Unsupported or unknown Linux distribution."
color_red "Detected: ID=" "$OS_ID" "ID_LIKE=" "${OS_LIKE:-empty}"
color_red "----------------------------------------------------------------"
exit 1
fi
pause_if_debug
#------------------------------------------
# Desktop Environment Detection / Selection
#------------------------------------------
echo
color_yellow "----------------------------------------------------------------"
color_yellow "Desktop Environment Selection"
color_yellow "----------------------------------------------------------------"
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 echo
color_cyan "----------------------------------------------------------------" color_yellow "----------------------------------------------------------------"
color_cyan "Detected Desktop Environment:" "$DE" "${DE_RAW:-unknown}" color_yellow "Script version 3.0"
color_cyan "----------------------------------------------------------------" color_yellow "----------------------------------------------------------------"
else
#------------------------------------------
# OS Detection
#------------------------------------------
echo echo
color_gray "No Desktop Environment detected. Select one to install:" color_yellow "----------------------------------------------------------------"
color_yellow "Start OS Detection"
color_yellow "----------------------------------------------------------------"
echo 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 "----------------------------------------------------------------"
color_cyan "Detected OS:" "$OS_PRETTY"
color_cyan "Version:" "$OS_VERSION"
color_cyan "----------------------------------------------------------------"
else
color_red "----------------------------------------------------------------"
color_red "ERROR: Unsupported or unknown Linux distribution."
color_red "Detected: ID=" "$OS_ID" "ID_LIKE=" "${OS_LIKE:-empty}"
color_red "----------------------------------------------------------------"
exit 1
fi
pause_if_debug
#------------------------------------------
# Desktop Environment Detection / Selection
#------------------------------------------
echo
color_yellow "----------------------------------------------------------------"
color_yellow "Desktop Environment Selection"
color_yellow "----------------------------------------------------------------"
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 "----------------------------------------------------------------"
color_cyan "Detected Desktop Environment:" "$DE" "${DE_RAW:-unknown}"
color_cyan "----------------------------------------------------------------"
else
echo
color_gray "No Desktop Environment detected. Select one to install:"
echo
while true; do
echo " 1) XFCE"
echo " 2) Plasma"
echo " 3) GNOME"
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) 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 "----------------------------------------------------------------"
color_cyan "Selected Desktop Environment:" "$DE"
color_cyan "----------------------------------------------------------------"
fi
pause_if_debug
#------------------------------------------
# Tiling Window Manager Selection
#------------------------------------------
echo
color_yellow "----------------------------------------------------------------"
color_yellow "Tiling WM Selection"
color_yellow "----------------------------------------------------------------"
echo
while true; do while true; do
echo " 1) XFCE" echo
echo " 2) Plasma" color_gray "Select a tiling window manager:"
echo " 3) GNOME" echo
echo " 1) CHADWM"
echo " 2) Hyprland"
echo " 3) Niri"
echo " x) None (default)" echo " x) None (default)"
if ! read -t 15 -rp "Enter choice [1/2/3/x] (default: x): " choice; then if ! read -t 15 -rp "Enter choice [1/2/3/x] (default: x): " choice; then
choice="x" choice="x"
fi fi
case "${choice,,}" in case "${choice,,}" in
1) DE="xfce"; break ;; 1) TWM="chadwm"; break ;;
2) DE="plasma"; break ;; 2) TWM="hyprland"; break ;;
3) DE="gnome"; break ;; 3) TWM="niri"; break ;;
x|"") DE="none"; break ;; x|"") TWM="none"; break ;;
*) echo "Invalid option. Please enter 1, 2, 3, or x." ;; *) echo "Invalid option. Please enter 1, 2, 3 or x." ;;
esac esac
done done
echo echo
color_cyan "----------------------------------------------------------------" color_cyan "----------------------------------------------------------------"
color_cyan "Selected Desktop Environment:" "$DE" color_cyan "Selected Tiling WM:" "$TWM"
color_cyan "----------------------------------------------------------------" color_cyan "----------------------------------------------------------------"
fi
pause_if_debug pause_if_debug
#------------------------------------------ #------------------------------------------
# Tiling Window Manager Selection # Installation Level Selection
#------------------------------------------ #------------------------------------------
echo
color_yellow "----------------------------------------------------------------"
color_yellow "Tiling WM Selection"
color_yellow "----------------------------------------------------------------"
echo
while true; do
echo echo
color_gray "Select a tiling window manager:" color_yellow "----------------------------------------------------------------"
color_yellow "Installation Level Selection"
color_yellow "----------------------------------------------------------------"
echo echo
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 while true; do
1) TWM="chadwm"; break ;; echo
2) TWM="hyprland"; break ;; color_gray "Select installation level:"
3) TWM="niri"; break ;; echo
x|"") TWM="none"; break ;; echo " 1) minimal"
*) echo "Invalid option. Please enter 1, 2, 3 or x." ;; 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 "----------------------------------------------------------------"
color_cyan "Selected Installation Level:" "$INSTALL_LEVEL"
color_cyan "----------------------------------------------------------------"
pause_if_debug
#------------------------------------------
# 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="./debian/debian.sh" ;;
ubuntu) OS_SCRIPT="./ubuntu/ubuntu.sh" ;;
arch) OS_SCRIPT="./arch/arch.sh" ;;
fedora) OS_SCRIPT="./fedora/fedora.sh" ;;
*)
color_red "No OS script available for $OS"
exit 1
;;
esac esac
done
echo #------------------------------------------
color_cyan "----------------------------------------------------------------" # Preflight check & run
color_cyan "Selected Tiling WM:" "$TWM" #------------------------------------------
color_cyan "----------------------------------------------------------------" if [[ ! -f "$OS_SCRIPT" ]]; then
color_red "ERROR: OS script not found: $OS_SCRIPT"
pause_if_debug
#------------------------------------------
# Installation Level Selection
#------------------------------------------
echo
color_yellow "----------------------------------------------------------------"
color_yellow "Installation Level Selection"
color_yellow "----------------------------------------------------------------"
echo
while true; do
echo
color_gray "Select installation level:"
echo
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 "----------------------------------------------------------------"
color_cyan "Selected Installation Level:" "$INSTALL_LEVEL"
color_cyan "----------------------------------------------------------------"
pause_if_debug
#------------------------------------------
# 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="./debian/debian.sh" ;;
ubuntu) OS_SCRIPT="./ubuntu/ubuntu.sh" ;;
arch) OS_SCRIPT="./arch/arch.sh" ;;
fedora) OS_SCRIPT="./fedora/fedora.sh" ;;
*)
color_red "No OS script available for $OS"
exit 1 exit 1
;; fi
esac
#------------------------------------------ if [[ ! -x "$OS_SCRIPT" ]]; then
# Preflight check & run chmod +x "$OS_SCRIPT"
#------------------------------------------ fi
if [[ ! -f "$OS_SCRIPT" ]]; then
color_red "ERROR: OS script not found: $OS_SCRIPT"
exit 1
fi
if [[ ! -x "$OS_SCRIPT" ]]; then echo
chmod +x "$OS_SCRIPT" color_cyan "Running OS script: $OS_SCRIPT"
fi bash "$OS_SCRIPT" || {
color_red "ERROR: OS script failed: $OS_SCRIPT"
exit 1
}
echo echo
color_cyan "Running OS script: $OS_SCRIPT" color_yellow "----------------------------------------------------------------"
bash "$OS_SCRIPT" || { color_yellow "End Detection"
color_red "ERROR: OS script failed: $OS_SCRIPT" color_yellow "----------------------------------------------------------------"
exit 1
}
echo # ==========================================
color_yellow "----------------------------------------------------------------" # CLOSE THE GUARD WRAPPER AT THE VERY END OF THE FILE:
color_yellow "End Detection" # ==========================================
color_yellow "----------------------------------------------------------------" fi