Update postinstall.sh

Added more options and a menu. This is very close to the final 1.0 release.
This commit is contained in:
2026-03-02 18:15:25 -08:00
parent 09e325ce59
commit ff4424941d
+297 -106
View File
@@ -2,7 +2,74 @@
# Post install script for Fedora
# Author: Jacob Schantli
# Version: 0.5
# Version: 0.90
# -----------------------------------------------------------------------------
# Global Configuration
# -----------------------------------------------------------------------------
DNF_PACKAGES=(
"gnome-tweaks"
"steam"
"lutris"
"btop"
"fastfetch"
"jstest-gtk"
"yaru-icon-theme"
"distrobox"
"pipx"
"bash-completion"
"tar"
"bat"
"tree"
"unzip"
"git"
"fzf"
"syncthing"
)
FLATPAK_PACKAGES=(
"com.discordapp.Discord"
"com.github.tchx84.Flatseal"
"net.nokyan.Resources"
"com.mattjakeman.ExtensionManager"
"io.github.realmazharhussain.GdmSettings"
"com.ranfdev.DistroShelf"
"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"
"org.mozilla.Thunderbird"
"io.github.martchus.syncthingtray"
"io.github.kolunmi.Bazaar"
)
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"
)
# -----------------------------------------------------------------------------
# Helper Functions
@@ -26,6 +93,10 @@ log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check if the last command was successful
check_status() {
if [ $? -eq 0 ]; then
@@ -60,16 +131,10 @@ append_to_file_if_missing() {
}
# -----------------------------------------------------------------------------
# Main Script
# Installation Functions
# -----------------------------------------------------------------------------
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 &
optimize_dnf() {
log_info "----------------------------------------------------"
log_info "Modifying /etc/dnf/dnf.conf for faster downloads."
log_info "----------------------------------------------------"
@@ -83,7 +148,9 @@ else
log_error "$DNF_CONF not found!"
fi
sleep 1
}
install_fonts() {
log_info "----------------------------------------------------"
log_info "Installing Microsoft Core Fonts and Meslo Nerd Font."
log_info "----------------------------------------------------"
@@ -103,39 +170,28 @@ else
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
log_info "Installing Meslo Nerd Font..."
FONT_NAME="MesloLGS Nerd Font Mono"
if fc-list :family | grep -iq "$FONT_NAME"; then
log_info "Font '$FONT_NAME' is already installed."
else
log_info "Installing font '$FONT_NAME'..."
FONT_URL="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Meslo.zip"
FONT_DIR="$HOME/.local/share/fonts"
TEMP_DIR=$(mktemp -d)
FONTS=(
"MesloLGS%20NF%20Regular.ttf"
"MesloLGS%20NF%20Bold.ttf"
"MesloLGS%20NF%20Italic.ttf"
"MesloLGS%20NF%20Bold%20Italic.ttf"
)
wget -O "$TEMP_DIR/$FONT_NAME.zip" "$FONT_URL"
unzip "$TEMP_DIR/$FONT_NAME.zip" -d "$TEMP_DIR"
mkdir -p "$FONT_DIR/$FONT_NAME"
mv "$TEMP_DIR"/*.ttf "$FONT_DIR/$FONT_NAME/"
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"
fc-cache -fv
rm -rf "$TEMP_DIR"
check_status "Meslo Nerd Font installation" "non-critical"
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"
install_repos() {
log_info "----------------------------------------------------"
log_info "Adding RPM Fusion repositories."
log_info "----------------------------------------------------"
@@ -144,23 +200,13 @@ 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"
}
install_software() {
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"
@@ -175,32 +221,6 @@ 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..."
@@ -208,6 +228,35 @@ for app in "${FLATPAK_PACKAGES[@]}"; do
check_status "Flatpak $app" "non-critical"
done
log_info "----------------------------------------------------"
log_info "Installing Homebrew and Gemini CLI"
log_info "----------------------------------------------------"
# Install Homebrew
if command_exists brew; then
log_info "Homebrew already installed."
else
log_info "Installing Homebrew..."
# Using NONINTERACTIVE=1 to avoid prompts during brew install
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add brew to path for the current session
if [ -d "/home/linuxbrew/.linuxbrew/bin" ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
elif [ -d "$HOME/.linuxbrew/bin" ]; then
eval "$($HOME/.linuxbrew/bin/brew shellenv)"
fi
check_status "Homebrew installation" "non-critical"
fi
# Install Gemini CLI
log_info "Installing gemini-cli via Homebrew..."
brew install gemini-cli
check_status "gemini-cli installation" "non-critical"
}
install_cachyos() {
log_info "----------------------------------------------------"
log_info "Installing CachyOS kernel"
log_info "----------------------------------------------------"
@@ -226,36 +275,105 @@ 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"
}
install_linuxtoys() {
log_info "----------------------------------------------------"
log_info "Installing LinuxToys"
log_info "----------------------------------------------------"
curl -fsSL https://linux.toys/install.sh | bash
check_status "LinuxToys installation" "non-critical"
}
install_shell_env() {
log_info "----------------------------------------------------"
log_info "Installing Starship"
log_info "Installing Shell Environment (Starship, FZF, Zoxide, MyBash)"
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"
# Install Starship
if command_exists starship; then
log_info "Starship already installed."
else
log_warn "$BASHRC not found. Skipping Starship init configuration."
log_info "Installing Starship..."
curl -sSL https://starship.rs/install.sh | sudo sh
check_status "Starship installation" "non-critical"
fi
# Apply preset
mkdir -p ~/.config
starship preset gruvbox-rainbow -o ~/.config/starship.toml
check_status "Starship preset configuration" "non-critical"
# Install FZF (Fallback if not installed via DNF)
if ! command_exists fzf; then
log_info "Installing FZF via git..."
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install --all
fi
# Install Zoxide
if command_exists zoxide; then
log_info "Zoxide already installed."
else
log_info "Installing Zoxide..."
curl -sSL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh
check_status "Zoxide installation" "non-critical"
fi
# Clone MyBash
log_info "Cloning MyBash configuration..."
GITPATH="$HOME/.local/share/mybash"
if [ -d "$GITPATH" ]; then
rm -rf "$GITPATH"
fi
mkdir -p "$HOME/.local/share"
if git clone https://gitea.schantli.ca/jschantli/mybash.git "$GITPATH"; then
log_info "MyBash cloned successfully."
# Link Config
log_info "Linking configuration files..."
OLD_BASHRC="$HOME/.bashrc"
# Check if .bashrc exists in the cloned repo
if [ -f "$GITPATH/.bashrc" ]; then
if [ -e "$OLD_BASHRC" ] && [ ! -e "$HOME/.bashrc.bak" ]; then
log_info "Backing up .bashrc to .bashrc.bak..."
mv "$OLD_BASHRC" "$HOME/.bashrc.bak"
fi
log_info "Linking new .bashrc..."
ln -svf "$GITPATH/.bashrc" "$HOME/.bashrc"
# Ensure Starship is initialized in the new .bashrc
if ! grep -q "starship init bash" "$HOME/.bashrc"; then
log_warn ".bashrc does not contain starship init. Appending it..."
echo 'eval "$(starship init bash)"' >> "$HOME/.bashrc"
fi
else
log_error "$GITPATH/.bashrc not found! Skipping .bashrc linking."
fi
# Check if starship.toml exists in the cloned repo
if [ -f "$GITPATH/starship.toml" ]; then
log_info "Linking starship.toml..."
mkdir -p "$HOME/.config"
ln -svf "$GITPATH/starship.toml" "$HOME/.config/starship.toml"
else
log_warn "$GITPATH/starship.toml not found! Skipping Starship config linking."
fi
# Check if config.jsonc exists in the cloned repo
if [ -f "$GITPATH/config.jsonc" ]; then
log_info "Linking config.jsonc..."
mkdir -p "$HOME/.config/fastfetch/"
ln -svf "$GITPATH/config.jsonc" "$HOME/.config/fastfetch/config.jsonc"
else
log_warn "$GITPATH/config.jsonc not found! Skipping fastfetch config linking."
fi
check_status "Linking config files" "non-critical"
else
log_error "Failed to clone MyBash repository. Skipping shell configuration."
fi
}
install_gnome_extensions() {
log_info "----------------------------------------------------"
log_info "Installing GNOME extensions"
log_info "----------------------------------------------------"
@@ -275,20 +393,6 @@ 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."
@@ -308,7 +412,94 @@ for extension in "${GNOME_EXTENSIONS[@]}"; do
check_status "GNOME Extension $extension" "non-critical"
done
}
# -----------------------------------------------------------------------------
# Main Menu
# -----------------------------------------------------------------------------
show_menu() {
clear
echo "===================================================="
echo " Fedora Post-Install Script - Main Menu"
echo "===================================================="
echo "1. Install Everything (Recommended)"
echo "2. Install Everything (No CachyOS Kernel)"
echo "3. Optimize DNF"
echo "4. Install Fonts"
echo "5. Add Repositories (RPM Fusion)"
echo "6. Install Software (DNF & Flatpak)"
echo "7. Install CachyOS Kernel"
echo "8. Install LinuxToys"
echo "9. Install Shell Environment (Starship, MyBash)"
echo "10. Install GNOME Extensions"
echo "0. Exit"
echo "===================================================="
read -p "Enter your choice [0-10]: " choice
}
# -----------------------------------------------------------------------------
# Main Execution
# -----------------------------------------------------------------------------
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 &
while true; do
show_menu
case $choice in
1)
optimize_dnf
install_fonts
install_repos
install_software
install_cachyos
install_linuxtoys
install_shell_env
install_gnome_extensions
log_info "All tasks completed successfully!"
break
;;
2)
optimize_dnf
install_fonts
install_repos
install_software
# install_cachyos (Skipped)
install_linuxtoys
install_shell_env
install_gnome_extensions
log_info "All tasks (except kernel) completed successfully!"
break
;;
3) optimize_dnf ;;
4) install_fonts ;;
5) install_repos ;;
6) install_software ;;
7) install_cachyos ;;
8) install_linuxtoys ;;
9) install_shell_env ;;
10) install_gnome_extensions ;;
0)
log_info "Exiting..."
exit 0
;;
*)
log_error "Invalid option. Please try again."
sleep 2
;;
esac
if [ "$choice" != "1" ] && [ "$choice" != "2" ]; then
read -p "Press Enter to return to the main menu..."
fi
done
log_info "----------------------------------------------------"
log_info "Post-install script completed successfully!"
log_info "Please restart your shell or run 'source ~/.bashrc' to see the changes."
log_info "----------------------------------------------------"