Update postinstall.sh

This commit is contained in:
2026-02-28 12:34:29 -08:00
parent 483077bb97
commit 7d514987a3
+238 -110
View File
@@ -1,132 +1,260 @@
#!/bin/bash
#!/bin/zsh
# Post install script for Fedora
# Author Jacob Schantli
# Version 0.1
# Author: Jacob Schantli
# Version: 0.2
echo "Post install script for Fedora to setup as per how I like it"
sleep 5
# -----------------------------------------------------------------------------
# Helper Functions
# -----------------------------------------------------------------------------
echo "----------------------------------------------------"
echo "Modifying /etc/dnf/dnf.conf for faster downloads."
echo "----------------------------------------------------"
sleep 2
# Text that will be added to the file
text_to_append="max_parallel_downloads=10
defaultyes=True
keepcache=True"
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
#File path
file_path="/etc/dnf/dnf.conf"
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
# Append the text to the end of the file
echo "$text_to_append" | sudo tee -a "$file_path"
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
echo "Modification has been completed"
sleep 3
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
echo "----------------------------------------------------"
echo "Installing Microsoft Core Fonts and Meslo Nerd Font."
echo "----------------------------------------------------"
sleep 2
echo "Installing prerequisites..."
sudo dnf upgrade --refresh
sudo dnf install -y curl cabextract xorg-x11-font-utils fontconfig
# 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
}
echo "Installing Microsoft Core Fonts..."
# 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
echo "Downloading and installing MesloLGS Nerd Font for Powerlevel10k..."
# Create a temporary directory to work in
mkdir -p ~/.tmp-fonts
cd ~/.tmp-fonts || exit
log_info "Downloading and installing MesloLGS Nerd Font..."
TEMP_FONT_DIR="$HOME/.tmp-fonts"
mkdir -p "$TEMP_FONT_DIR"
cd "$TEMP_FONT_DIR" || exit
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf
FONTS=(
"MesloLGS%20NF%20Regular.ttf"
"MesloLGS%20NF%20Bold.ttf"
"MesloLGS%20NF%20Italic.ttf"
"MesloLGS%20NF%20Bold%20Italic.ttf"
)
sudo mkdir -p /usr/local/share/fonts/MesloLGS
sudo mv ./*.ttf /usr/local/share/fonts/MesloLGS/
for font in "${FONTS[@]}"; do
wget -N "https://github.com/romkatv/powerlevel10k-media/raw/master/$font"
check_status "Downloading $font" "non-critical"
done
# Clean up temporary directory
cd ~
rm -rf ~/.tmp-fonts
TARGET_FONT_DIR="/usr/local/share/fonts/MesloLGS"
if [ ! -d "$TARGET_FONT_DIR" ]; then
sudo mkdir -p "$TARGET_FONT_DIR"
fi
echo "Updating font cache..."
sudo fc-cache -fv
echo "Font installation complete."
sleep 3
sudo mv ./*.ttf "$TARGET_FONT_DIR/"
check_status "Moving fonts" "non-critical"
echo "----------------------------------------------------"
echo "Adding RPM Fusion repositories."
echo "----------------------------------------------------"
sleep 2
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
echo "Repositories have been added."
sleep 3
echo "----------------------------------------------------"
echo "Installing most used software."
echo "----------------------------------------------------"
sudo dnf install -y gnome-tweaks steam lutris btop fastfetch jstest-gtk yaru-icon-theme distrobox
flatpak install flathub -y com.discordapp.Discord
flatpak install flathub -y com.github.tchx84.Flatseal
flatpak install flathub -y net.nokyan.Resources
flatpak install flathub -y com.mattjakeman.ExtensionManager
flatpak install flathub -y io.github.realmazharhussain.GdmSettings
flatpak install flathub -y io.github.dvlv.boxbuddyrs
flatpak install flathub -y it.mijorus.gearlever
flatpak install flathub -y io.github.fastrizwaan.WineZGUI
flatpak install flathub -y com.vysp3r.ProtonPlus
flatpak install flathub -y io.missioncenter.MissionCenter
flatpak install flathub -y io.github.peazip.PeaZip
flatpak install flathub -y io.github.fastrizwaan.WineZGUI
flatpak install flathub -y app.devsuite.Ptyxis
flatpak install flathub -y re.sonny.Junction
flatpak install flathub -y com.github.rafostar.Clapper
flatpak install flathub -y io.github.flattool.Ignition
flatpak install flathub -y io.github.swordpuffin.rewaita
flatpak install flathub -y page.tesk.Refine
flatpak install flathub -y io.gitlab.adhami3310.Converter
flatpak install flathub -y com.bitwarden.desktop
flatpak install flathub -y com.usebottles.bottles
flatpak install flathub -y com.ulaa.Ulaa
flatpak install flathub -y com.bambulab.BambuStudio
flatpak install flathub -y com.collaboraoffice.Office
echo "Software has been installed."
sleep 3
echo "Installing cachyos kernel"
sudo dnf copr enable bieszczaders/kernel-cachyos
sudo dnf install -y kernel-cachyos kernel-cachyos-devel-matched
echo "Cachyos has been installed."
sleep 3
echo "Installing Cachyos addons"
sudo dnf copr enable bieszczaders/kernel-cachyos-addons
sudo dnf swap zram-generator-defaults cachyos-settings
sudo dracut -f
sudo dnf -y install scx-scheds scx-tools
sudo dnf -y install scx-manager
sudo dnf -y install ananicy-cpp
# Cleanup
cd ~
rm -rf "$TEMP_FONT_DIR"
echo "CachyOS addons complete."
sleep 3
log_info "Updating font cache..."
sudo fc-cache -fv
check_status "Font cache update" "non-critical"
echo "Installing LinuxToys"
curl -fsSL https://linux.toys/install.sh | bash
log_info "----------------------------------------------------"
log_info "Adding RPM Fusion repositories."
log_info "----------------------------------------------------"
echo "Installing Starship"
sudo dnf copr enable atim/starship
sudo dnf install starship -y
sleep 1
text_to_append_bash="eval "$(starship init bash)"
keepcache=True"
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"
#File path
file_path_bash="~/.bashrc"
log_info "----------------------------------------------------"
log_info "Installing most used software."
log_info "----------------------------------------------------"
# Append the text to the end of the file
echo "$text_to_append_bash" | sudo tee -a "$file_path_bash"
starship preset gruvbox-rainbow -o ~/.config/starship.toml
DNF_PACKAGES=(
"gnome-tweaks"
"steam"
"lutris"
"btop"
"fastfetch"
"jstest-gtk"
"yaru-icon-theme"
"distrobox"
)
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 "Post-install script completed successfully!"
log_info "----------------------------------------------------"