Update postinstall.sh
This commit is contained in:
+228
-100
@@ -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'
|
||||||
|
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
|
sleep 2
|
||||||
# Text that will be added to the file
|
|
||||||
text_to_append="max_parallel_downloads=10
|
|
||||||
defaultyes=True
|
|
||||||
keepcache=True"
|
|
||||||
|
|
||||||
#File path
|
# Ensure sudo permissions are available upfront
|
||||||
file_path="/etc/dnf/dnf.conf"
|
sudo -v
|
||||||
|
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
|
||||||
|
|
||||||
# Append the text to the end of the file
|
log_info "----------------------------------------------------"
|
||||||
echo "$text_to_append" | sudo tee -a "$file_path"
|
log_info "Modifying /etc/dnf/dnf.conf for faster downloads."
|
||||||
|
log_info "----------------------------------------------------"
|
||||||
|
|
||||||
echo "Modification has been completed"
|
DNF_CONF="/etc/dnf/dnf.conf"
|
||||||
sleep 3
|
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
|
||||||
|
|
||||||
echo "----------------------------------------------------"
|
log_info "----------------------------------------------------"
|
||||||
echo "Installing Microsoft Core Fonts and Meslo Nerd Font."
|
log_info "Installing Microsoft Core Fonts and Meslo Nerd Font."
|
||||||
echo "----------------------------------------------------"
|
log_info "----------------------------------------------------"
|
||||||
sleep 2
|
|
||||||
echo "Installing prerequisites..."
|
|
||||||
sudo dnf upgrade --refresh
|
|
||||||
sudo dnf install -y curl cabextract xorg-x11-font-utils fontconfig
|
|
||||||
|
|
||||||
echo "Installing Microsoft Core Fonts..."
|
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"
|
||||||
|
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 ~
|
cd ~
|
||||||
rm -rf ~/.tmp-fonts
|
rm -rf "$TEMP_FONT_DIR"
|
||||||
|
|
||||||
echo "Updating font cache..."
|
log_info "Updating font cache..."
|
||||||
sudo fc-cache -fv
|
sudo fc-cache -fv
|
||||||
echo "Font installation complete."
|
check_status "Font cache update" "non-critical"
|
||||||
sleep 3
|
|
||||||
|
log_info "----------------------------------------------------"
|
||||||
|
log_info "Adding RPM Fusion repositories."
|
||||||
|
log_info "----------------------------------------------------"
|
||||||
|
|
||||||
echo "----------------------------------------------------"
|
|
||||||
echo "Adding RPM Fusion repositories."
|
|
||||||
echo "----------------------------------------------------"
|
|
||||||
sleep 2
|
|
||||||
sudo dnf install -y \
|
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 "----------------------------------------------------"
|
log_info "----------------------------------------------------"
|
||||||
echo "Installing most used software."
|
log_info "Installing most used software."
|
||||||
echo "----------------------------------------------------"
|
log_info "----------------------------------------------------"
|
||||||
sudo dnf install -y gnome-tweaks steam lutris btop fastfetch jstest-gtk yaru-icon-theme distrobox
|
|
||||||
flatpak install flathub -y com.discordapp.Discord
|
DNF_PACKAGES=(
|
||||||
flatpak install flathub -y com.github.tchx84.Flatseal
|
"gnome-tweaks"
|
||||||
flatpak install flathub -y net.nokyan.Resources
|
"steam"
|
||||||
flatpak install flathub -y com.mattjakeman.ExtensionManager
|
"lutris"
|
||||||
flatpak install flathub -y io.github.realmazharhussain.GdmSettings
|
"btop"
|
||||||
flatpak install flathub -y io.github.dvlv.boxbuddyrs
|
"fastfetch"
|
||||||
flatpak install flathub -y it.mijorus.gearlever
|
"jstest-gtk"
|
||||||
flatpak install flathub -y io.github.fastrizwaan.WineZGUI
|
"yaru-icon-theme"
|
||||||
flatpak install flathub -y com.vysp3r.ProtonPlus
|
"distrobox"
|
||||||
flatpak install flathub -y io.missioncenter.MissionCenter
|
)
|
||||||
flatpak install flathub -y io.github.peazip.PeaZip
|
|
||||||
flatpak install flathub -y io.github.fastrizwaan.WineZGUI
|
log_info "Installing DNF packages..."
|
||||||
flatpak install flathub -y app.devsuite.Ptyxis
|
sudo dnf install -y "${DNF_PACKAGES[@]}"
|
||||||
flatpak install flathub -y re.sonny.Junction
|
check_status "DNF packages installation" "non-critical"
|
||||||
flatpak install flathub -y com.github.rafostar.Clapper
|
|
||||||
flatpak install flathub -y io.github.flattool.Ignition
|
# Ensure flatpak is set up
|
||||||
flatpak install flathub -y io.github.swordpuffin.rewaita
|
if ! command -v flatpak &> /dev/null; then
|
||||||
flatpak install flathub -y page.tesk.Refine
|
log_info "Flatpak not found. Installing..."
|
||||||
flatpak install flathub -y io.gitlab.adhami3310.Converter
|
sudo dnf install -y flatpak
|
||||||
flatpak install flathub -y com.bitwarden.desktop
|
fi
|
||||||
flatpak install flathub -y com.usebottles.bottles
|
|
||||||
flatpak install flathub -y com.ulaa.Ulaa
|
log_info "Adding Flathub remote..."
|
||||||
flatpak install flathub -y com.bambulab.BambuStudio
|
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
|
||||||
flatpak install flathub -y com.collaboraoffice.Office
|
check_status "Flathub remote add" "non-critical"
|
||||||
echo "Software has been installed."
|
|
||||||
sleep 3
|
FLATPAK_PACKAGES=(
|
||||||
echo "Installing cachyos kernel"
|
"com.discordapp.Discord"
|
||||||
sudo dnf copr enable bieszczaders/kernel-cachyos
|
"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
|
sudo dnf install -y kernel-cachyos kernel-cachyos-devel-matched
|
||||||
echo "Cachyos has been installed."
|
check_status "CachyOS Kernel installation" "non-critical"
|
||||||
sleep 3
|
|
||||||
echo "Installing Cachyos addons"
|
log_info "Installing CachyOS addons"
|
||||||
sudo dnf copr enable bieszczaders/kernel-cachyos-addons
|
sudo dnf copr enable -y bieszczaders/kernel-cachyos-addons
|
||||||
sudo dnf swap zram-generator-defaults cachyos-settings
|
check_status "Enabling CachyOS Addons Copr" "non-critical"
|
||||||
|
|
||||||
|
sudo dnf swap -y zram-generator-defaults cachyos-settings
|
||||||
sudo dracut -f
|
sudo dracut -f
|
||||||
sudo dnf -y install scx-scheds scx-tools
|
sudo dnf -y install scx-scheds scx-tools scx-manager ananicy-cpp
|
||||||
sudo dnf -y install scx-manager
|
check_status "CachyOS addons installation" "non-critical"
|
||||||
sudo dnf -y install ananicy-cpp
|
|
||||||
|
|
||||||
echo "CachyOS addons complete."
|
log_info "----------------------------------------------------"
|
||||||
sleep 3
|
log_info "Installing LinuxToys"
|
||||||
|
log_info "----------------------------------------------------"
|
||||||
echo "Installing LinuxToys"
|
|
||||||
curl -fsSL https://linux.toys/install.sh | bash
|
curl -fsSL https://linux.toys/install.sh | bash
|
||||||
|
check_status "LinuxToys installation" "non-critical"
|
||||||
|
|
||||||
echo "Installing Starship"
|
log_info "----------------------------------------------------"
|
||||||
sudo dnf copr enable atim/starship
|
log_info "Installing Starship"
|
||||||
|
log_info "----------------------------------------------------"
|
||||||
|
|
||||||
|
sudo dnf copr enable -y atim/starship
|
||||||
sudo dnf install starship -y
|
sudo dnf install starship -y
|
||||||
sleep 1
|
check_status "Starship installation" "non-critical"
|
||||||
text_to_append_bash="eval "$(starship init bash)"
|
|
||||||
keepcache=True"
|
|
||||||
|
|
||||||
#File path
|
# Configure .bashrc
|
||||||
file_path_bash="~/.bashrc"
|
BASHRC="$HOME/.bashrc"
|
||||||
|
STARSHIP_INIT='eval "$(starship init bash)"'
|
||||||
|
|
||||||
# Append the text to the end of the file
|
if [ -f "$BASHRC" ]; then
|
||||||
echo "$text_to_append_bash" | sudo tee -a "$file_path_bash"
|
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
|
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 "----------------------------------------------------"
|
||||||
|
|||||||
Reference in New Issue
Block a user