#!/bin/bash # Post install script for Fedora # Author: Jacob Schantli # Version: 0.5 # ----------------------------------------------------------------------------- # Helper Functions # ----------------------------------------------------------------------------- # Colors for output GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[1;33m' NC='\033[0m' # No Color log_info() { echo -e "${GREEN}[INFO]${NC} $1" } log_error() { echo -e "${RED}[ERROR]${NC} $1" } log_warn() { echo -e "${YELLOW}[WARN]${NC} $1" } # Check if the last command was successful check_status() { if [ $? -eq 0 ]; then log_info "$1 successful." else log_error "$1 failed." # If the second argument is "critical", exit the script if [ "$2" == "critical" ]; then log_error "Critical error encountered. Exiting." exit 1 fi fi } # Append text to a file if it doesn't already exist append_to_file_if_missing() { local file="$1" local text="$2" local description="$3" local use_sudo="$4" if grep -Fq "$text" "$file"; then log_warn "$description already exists in $file. Skipping." else if [ "$use_sudo" == "true" ]; then echo "$text" | sudo tee -a "$file" > /dev/null else echo "$text" >> "$file" fi log_info "Added $description to $file." fi } # ----------------------------------------------------------------------------- # Main Script # ----------------------------------------------------------------------------- log_info "Starting Post-install script for Fedora..." sleep 2 # Ensure sudo permissions are available upfront sudo -v while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & log_info "----------------------------------------------------" log_info "Modifying /etc/dnf/dnf.conf for faster downloads." log_info "----------------------------------------------------" DNF_CONF="/etc/dnf/dnf.conf" if [ -f "$DNF_CONF" ]; then append_to_file_if_missing "$DNF_CONF" "max_parallel_downloads=10" "max_parallel_downloads" "true" append_to_file_if_missing "$DNF_CONF" "defaultyes=True" "defaultyes" "true" append_to_file_if_missing "$DNF_CONF" "keepcache=True" "keepcache" "true" else log_error "$DNF_CONF not found!" fi sleep 1 log_info "----------------------------------------------------" log_info "Installing Microsoft Core Fonts and Meslo Nerd Font." log_info "----------------------------------------------------" log_info "Updating system and installing prerequisites..." sudo dnf upgrade --refresh -y check_status "System upgrade" "critical" sudo dnf install -y curl cabextract xorg-x11-font-utils fontconfig wget check_status "Prerequisites installation" "critical" log_info "Installing Microsoft Core Fonts..." if rpm -q msttcore-fonts-installer > /dev/null 2>&1; then log_warn "Microsoft Core Fonts already installed." else sudo rpm -i https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm check_status "Microsoft Core Fonts installation" "non-critical" fi log_info "Downloading and installing MesloLGS Nerd Font..." TEMP_FONT_DIR="$HOME/.tmp-fonts" mkdir -p "$TEMP_FONT_DIR" cd "$TEMP_FONT_DIR" || exit FONTS=( "MesloLGS%20NF%20Regular.ttf" "MesloLGS%20NF%20Bold.ttf" "MesloLGS%20NF%20Italic.ttf" "MesloLGS%20NF%20Bold%20Italic.ttf" ) for font in "${FONTS[@]}"; do wget -N "https://github.com/romkatv/powerlevel10k-media/raw/master/$font" check_status "Downloading $font" "non-critical" done TARGET_FONT_DIR="/usr/local/share/fonts/MesloLGS" if [ ! -d "$TARGET_FONT_DIR" ]; then sudo mkdir -p "$TARGET_FONT_DIR" fi sudo mv ./*.ttf "$TARGET_FONT_DIR/" check_status "Moving fonts" "non-critical" # Cleanup cd ~ rm -rf "$TEMP_FONT_DIR" log_info "Updating font cache..." sudo fc-cache -fv check_status "Font cache update" "non-critical" log_info "----------------------------------------------------" log_info "Adding RPM Fusion repositories." log_info "----------------------------------------------------" sudo dnf install -y \ https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \ https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm check_status "RPM Fusion repositories installation" "non-critical" log_info "----------------------------------------------------" log_info "Installing most used software." log_info "----------------------------------------------------" DNF_PACKAGES=( "gnome-tweaks" "steam" "lutris" "btop" "fastfetch" "jstest-gtk" "yaru-icon-theme" "distrobox" "pipx" ) log_info "Installing DNF packages..." sudo dnf install -y "${DNF_PACKAGES[@]}" check_status "DNF packages installation" "non-critical" # Ensure flatpak is set up if ! command -v flatpak &> /dev/null; then log_info "Flatpak not found. Installing..." sudo dnf install -y flatpak fi log_info "Adding Flathub remote..." flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo check_status "Flathub remote add" "non-critical" FLATPAK_PACKAGES=( "com.discordapp.Discord" "com.github.tchx84.Flatseal" "net.nokyan.Resources" "com.mattjakeman.ExtensionManager" "io.github.realmazharhussain.GdmSettings" "io.github.dvlv.boxbuddyrs" "it.mijorus.gearlever" "io.github.fastrizwaan.WineZGUI" "com.vysp3r.ProtonPlus" "io.missioncenter.MissionCenter" "io.github.peazip.PeaZip" "app.devsuite.Ptyxis" "re.sonny.Junction" "com.github.rafostar.Clapper" "io.github.flattool.Ignition" "io.github.swordpuffin.rewaita" "page.tesk.Refine" "io.gitlab.adhami3310.Converter" "com.bitwarden.desktop" "com.usebottles.bottles" "com.ulaa.Ulaa" "com.bambulab.BambuStudio" "com.collaboraoffice.Office" ) log_info "Installing Flatpak packages..." for app in "${FLATPAK_PACKAGES[@]}"; do log_info "Installing $app..." flatpak install flathub -y "$app" check_status "Flatpak $app" "non-critical" done log_info "----------------------------------------------------" log_info "Installing CachyOS kernel" log_info "----------------------------------------------------" sudo dnf copr enable -y bieszczaders/kernel-cachyos check_status "Enabling CachyOS Copr" "non-critical" sudo dnf install -y kernel-cachyos kernel-cachyos-devel-matched check_status "CachyOS Kernel installation" "non-critical" log_info "Installing CachyOS addons" sudo dnf copr enable -y bieszczaders/kernel-cachyos-addons check_status "Enabling CachyOS Addons Copr" "non-critical" sudo dnf swap -y zram-generator-defaults cachyos-settings sudo dracut -f sudo dnf -y install scx-scheds scx-tools scx-manager ananicy-cpp check_status "CachyOS addons installation" "non-critical" log_info "----------------------------------------------------" log_info "Installing LinuxToys" log_info "----------------------------------------------------" curl -fsSL https://linux.toys/install.sh | bash check_status "LinuxToys installation" "non-critical" log_info "----------------------------------------------------" log_info "Installing Starship" log_info "----------------------------------------------------" sudo dnf copr enable -y atim/starship sudo dnf install starship -y check_status "Starship installation" "non-critical" # Configure .bashrc BASHRC="$HOME/.bashrc" STARSHIP_INIT='eval "$(starship init bash)"' if [ -f "$BASHRC" ]; then append_to_file_if_missing "$BASHRC" "$STARSHIP_INIT" "Starship init" "false" else log_warn "$BASHRC not found. Skipping Starship init configuration." fi # Apply preset mkdir -p ~/.config starship preset gruvbox-rainbow -o ~/.config/starship.toml check_status "Starship preset configuration" "non-critical" log_info "----------------------------------------------------" log_info "Installing GNOME extensions" log_info "----------------------------------------------------" # Ensure pipx is installed and path is set if ! command -v pipx &> /dev/null; then log_info "pipx not found. Installing..." sudo dnf install -y pipx pipx ensurepath fi # Install gnome-extensions-cli log_info "Installing gnome-extensions-cli..." pipx install gnome-extensions-cli --system-site-packages check_status "gnome-extensions-cli installation" "non-critical" # Define the tool path explicitly to avoid 'pipx run' overhead/warnings EXTENSION_TOOL="$HOME/.local/bin/gnome-extensions-cli" GNOME_EXTENSIONS=( "dash-to-dock@micxgx.gmail.com" "app-grid-wizard@mirzadeh.pro" "appindicatorsupport@rgcjonas.gmail.com" "blur-my-shell@aunetx" "caffeine@patapon.info" "dynamic-music-pill@andbal" "gnome-fuzzy-app-search@gnome-shell-extensions.Czarlie.gitlab.com" "IP-Finder@linxgem33.com" "lan-ip-address@mrhuber.com" "update-extension@purejava.org" "user-theme@gnome-shell-extensions.gcampax.github.com" ) log_info "Installing GNOME extensions..." log_info "NOTE: A popup may appear asking you to confirm installation for each extension." log_info "If the extension is already installed, no popup will appear." for extension in "${GNOME_EXTENSIONS[@]}"; do log_info "Processing $extension..." # Install (using the direct binary path) "$EXTENSION_TOOL" install "$extension" # Attempt to enable the extension (in case it's installed but disabled) log_info "Ensuring $extension is enabled..." gnome-extensions enable "$extension" # Prompt user to press Enter to continue read -p "Press Enter to continue (if a popup appeared, confirm it first)..." check_status "GNOME Extension $extension" "non-critical" done log_info "----------------------------------------------------" log_info "Post-install script completed successfully!" log_info "----------------------------------------------------"