#!/bin/bash # For fresh installs of Rocky (8) # Installs desktop environment + sets up distros get_base_distro() { local base_distro base_distro=$(grep '^ID_LIKE=' /etc/os-release | cut -d= -f2 | tr -d '"' | awk '{print $1}') if [ -z "$base_distro" ]; then # fallback to ID if ID_LIKE is not found base_distro=$(grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"' | awk '{print $1}') fi echo "$base_distro" } get_distro() { grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"' } get_version_id() { grep '^VERSION_ID=' /etc/os-release | cut -d= -f2 | tr -d '"' | cut -d '.' -f1 } require_root() { if [ "$(id -u)" -ne 0 ]; then echo "This script must be run as root." exit 1 fi } backup_existing_repo() { if [[ -f /etc/yum.repos.d/45drives.repo ]]; then mkdir -p /opt/45drives/archives/repos mv /etc/yum.repos.d/45drives.repo /opt/45drives/archives/repos/45drives-$(date +%F).repo echo "Existing 45Drives repo backed up." fi if [[ -f /etc/apt/sources.list.d/45drives.list ]]; then mkdir -p /opt/45drives/archives/repos mv /etc/apt/sources.list.d/45drives.list /opt/45drives/archives/repos/45drives-$(date +%F).list echo "Existing 45Drives APT repo backed up." fi } install_desktop_env() { if [[ $distro == "rhel" || $distro == "fedora" ]]; then echo "Installing XFCE Desktop Environment for Rocky/RHEL..." dnf update -y dnf install -y epel-release kernel-headers dnf groupinstall -y "Xfce" "base-x" echo "exec /usr/bin/xfce4-session" >> ~/.xinitrc systemctl set-default graphical fi } add_cockpit_overrides() { echo "Adding Cockpit override configurations..." cat > /usr/share/cockpit/45drives-system/override.json <