Update postinstall.sh

This commit is contained in:
2026-02-28 12:34:29 -08:00
parent 483077bb97
commit 7d514987a3
+236 -108
View File
@@ -1,132 +1,260 @@
#!/bin/bash #!/bin/bash
#!/bin/zsh
# Post install script for Fedora # Post install script for Fedora
# Author Jacob Schantli # Author: Jacob Schantli
# Version 0.1 # Version: 0.2
echo "Post install script for Fedora to setup as per how I like it" # -----------------------------------------------------------------------------
sleep 5 # Helper Functions
# -----------------------------------------------------------------------------
echo "----------------------------------------------------" # Colors for output
echo "Modifying /etc/dnf/dnf.conf for faster downloads." GREEN='\033[0;32m'
echo "----------------------------------------------------" RED='\033[0;31m'
sleep 2 YELLOW='\033[1;33m'
# Text that will be added to the file NC='\033[0m' # No Color
text_to_append="max_parallel_downloads=10
defaultyes=True
keepcache=True"
#File path log_info() {
file_path="/etc/dnf/dnf.conf" echo -e "${GREEN}[INFO]${NC} $1"
}
# Append the text to the end of the file log_error() {
echo "$text_to_append" | sudo tee -a "$file_path" echo -e "${RED}[ERROR]${NC} $1"
}
echo "Modification has been completed" log_warn() {
sleep 3 echo -e "${YELLOW}[WARN]${NC} $1"
}
echo "----------------------------------------------------" # Check if the last command was successful
echo "Installing Microsoft Core Fonts and Meslo Nerd Font." check_status() {
echo "----------------------------------------------------" if [ $? -eq 0 ]; then
sleep 2 log_info "$1 successful."
echo "Installing prerequisites..." else
sudo dnf upgrade --refresh log_error "$1 failed."
sudo dnf install -y curl cabextract xorg-x11-font-utils fontconfig # 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 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..." log_info "Downloading and installing MesloLGS Nerd Font..."
# Create a temporary directory to work in TEMP_FONT_DIR="$HOME/.tmp-fonts"
mkdir -p ~/.tmp-fonts mkdir -p "$TEMP_FONT_DIR"
cd ~/.tmp-fonts || exit cd "$TEMP_FONT_DIR" || exit
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf FONTS=(
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf "MesloLGS%20NF%20Regular.ttf"
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf "MesloLGS%20NF%20Bold.ttf"
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf "MesloLGS%20NF%20Italic.ttf"
"MesloLGS%20NF%20Bold%20Italic.ttf"
)
sudo mkdir -p /usr/local/share/fonts/MesloLGS for font in "${FONTS[@]}"; do
sudo mv ./*.ttf /usr/local/share/fonts/MesloLGS/ wget -N "https://github.com/romkatv/powerlevel10k-media/raw/master/$font"
check_status "Downloading $font" "non-critical"
done
# Clean up temporary directory TARGET_FONT_DIR="/usr/local/share/fonts/MesloLGS"
cd ~ if [ ! -d "$TARGET_FONT_DIR" ]; then
rm -rf ~/.tmp-fonts sudo mkdir -p "$TARGET_FONT_DIR"
fi
echo "Updating font cache..." sudo mv ./*.ttf "$TARGET_FONT_DIR/"
sudo fc-cache -fv check_status "Moving fonts" "non-critical"
echo "Font installation complete."
sleep 3
echo "----------------------------------------------------" # Cleanup
echo "Adding RPM Fusion repositories." cd ~
echo "----------------------------------------------------" rm -rf "$TEMP_FONT_DIR"
sleep 2
sudo dnf install -y \ 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/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \
https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-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." check_status "RPM Fusion repositories installation" "non-critical"
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
echo "CachyOS addons complete." log_info "----------------------------------------------------"
sleep 3 log_info "Installing most used software."
log_info "----------------------------------------------------"
echo "Installing LinuxToys" DNF_PACKAGES=(
curl -fsSL https://linux.toys/install.sh | bash "gnome-tweaks"
"steam"
"lutris"
"btop"
"fastfetch"
"jstest-gtk"
"yaru-icon-theme"
"distrobox"
)
echo "Installing Starship" log_info "Installing DNF packages..."
sudo dnf copr enable atim/starship sudo dnf install -y "${DNF_PACKAGES[@]}"
sudo dnf install starship -y check_status "DNF packages installation" "non-critical"
sleep 1
text_to_append_bash="eval "$(starship init bash)"
keepcache=True"
#File path # Ensure flatpak is set up
file_path_bash="~/.bashrc" if ! command -v flatpak &> /dev/null; then
log_info "Flatpak not found. Installing..."
sudo dnf install -y flatpak
fi
# Append the text to the end of the file log_info "Adding Flathub remote..."
echo "$text_to_append_bash" | sudo tee -a "$file_path_bash" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
starship preset gruvbox-rainbow -o ~/.config/starship.toml 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 "----------------------------------------------------"