Skip to content

Instantly share code, notes, and snippets.

@saikatm
Created April 16, 2025 03:04
Show Gist options
  • Save saikatm/bcab72e974211bbd359fd5be925b75ee to your computer and use it in GitHub Desktop.
Save saikatm/bcab72e974211bbd359fd5be925b75ee to your computer and use it in GitHub Desktop.
test run script
#!/bin/bash
# Complete Fedora System Setup Script
# This script will automatically configure a Fedora Linux system with
# optimized DNF settings, RPM Fusion repositories, Flathub, media codecs,
# preload, development tools, and install a curated set of applications.
# Exit if any command fails
set -e
# Function to handle errors
handle_error() {
echo "Error occurred at line $1"
exit 1
}
# Set trap to catch errors
trap 'handle_error $LINENO' ERR
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Please run this script with sudo privileges."
exit 1
fi
# Function to create autostart entry
create_autostart() {
local name="$1"
local exec_cmd="$2"
local comment="$3"
mkdir -p /etc/xdg/autostart
cat > "/etc/xdg/autostart/${name}.desktop" << EOF
[Desktop Entry]
Name=$name
Exec=$exec_cmd
Terminal=false
Type=Application
Comment=$comment
Categories=Utility;
X-GNOME-Autostart-enabled=true
EOF
echo "Created autostart entry for $name"
}
echo "===== Fedora System Setup Script ====="
echo "Starting system configuration..."
# Ask for confirmation before installing development tools
read -p "Do you want to install development tools (kernel headers, C development tools)? (y/n): " install_dev_tools
if [[ "$install_dev_tools" =~ ^[Yy]$ ]]; then
dev_tools_confirmed=true
echo "Development tools will be installed."
else
dev_tools_confirmed=false
echo "Development tools will be skipped."
fi
# Configure DNF
echo "Configuring DNF for optimal performance..."
cat > /etc/dnf/dnf.conf << EOF
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=False
skip_if_unavailable=True
fastestmirror=True
max_parallel_downloads=10
defaultyes=True
keepcache=True
EOF
echo "DNF configuration complete."
# Update system first
echo "Checking for updates..."
dnf update -y
echo "System update complete."
# Install development tools (if confirmed)
if [ "$dev_tools_confirmed" = true ]; then
echo "Installing development tools..."
dnf install -y kernel-headers kernel-devel
dnf group install -y "C Development Tools and Libraries"
echo "Development tools installed."
fi
# Enable RPM Fusion repositories
echo "Enabling RPM Fusion repositories..."
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
dnf groupupdate -y core
echo "RPM Fusion repositories enabled."
# Enable Flathub repo
echo "Enabling Flathub repository..."
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
echo "Flathub repository enabled."
# Enable media codecs
echo "Installing media codecs..."
dnf groupupdate -y multimedia --setop="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin
dnf groupupdate -y sound-and-video
echo "Media codecs installed."
# Enable preload
echo "Setting up preload for faster application startup..."
dnf copr enable -y elxreno/preload
dnf install -y preload
systemctl start preload
systemctl enable preload
echo "Preload setup complete."
# Install additional applications
echo "Installing additional applications..."
# Create a temporary file with the list of packages
cat > /tmp/pkgs-fedora.txt << EOF
lm_sensors-libs
android-tools
fish
flameshot
git
htop
kitty
lsd
micro
neofetch
nomacs
papirus-icon-theme
xclip
gnome-tweaks
duf
psensor
wofi
curl
EOF
# Install packages from the file
echo "Installing packages from the list..."
dnf install -y $(cat /tmp/pkgs-fedora.txt)
# Clean up temporary file
rm /tmp/pkgs-fedora.txt
# Install Oh My Fish for fish shell
echo "Installing Oh My Fish (OMF) for fish shell..."
# Install OMF for current user
if [ -n "$SUDO_USER" ]; then
su - $SUDO_USER -c "curl -L https://get.oh-my.fish | fish"
echo "Oh My Fish installed for user $SUDO_USER"
else
echo "Warning: Could not determine sudo user, skipping Oh My Fish installation"
fi
# Install AppImageLauncher
echo "Installing AppImageLauncher..."
dnf copr enable -y wvengen/appimagepool
dnf install -y appimagepool appimage-launcher
# Install Google Chrome
echo "Installing Google Chrome..."
cat > /etc/yum.repos.d/google-chrome.repo << EOF
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl.google.com/linux/linux_signing_key.pub
EOF
dnf install -y google-chrome-stable
# Install Flatpak applications
echo "Installing Flatpak applications..."
flatpak install -y flathub com.mega.MEGA
flatpak install -y flathub com.dropbox.Client
flatpak install -y flathub org.videolan.VLC
flatpak install -y flathub com.brave.Browser
flatpak install -y flathub org.qbittorrent.qBittorrent
flatpak install -y flathub com.github.jeromerobert.pdfarranger
# Configure applications to start automatically
echo "Setting up autostart applications..."
# AppImageLauncher
create_autostart "AppImageLauncher" "/usr/bin/appimagelauncherd" "AppImage launcher and integration daemon"
# Flameshot
create_autostart "Flameshot" "/usr/bin/flameshot" "Screenshot tool"
# Wofi (Rofi replacement for Wayland)
create_autostart "Wofi" "/usr/bin/wofi --show drun" "Application launcher for Wayland"
# MegaSync
create_autostart "MegaSync" "/usr/bin/flatpak run com.mega.MEGA" "MEGA file synchronization"
# Create user desktop entries for flatpak apps
mkdir -p /etc/skel/.local/share/applications
# Clean up residual packages
echo "Cleaning up package residues..."
dnf autoremove -y
dnf clean all
echo "===== System Setup Complete ====="
echo "Your Fedora system has been configured with:"
echo "- Optimized DNF settings"
echo "- RPM Fusion repositories (free and nonfree)"
echo "- Flathub repository"
echo "- Media codecs"
echo "- Preload for faster application startup"
if [ "$dev_tools_confirmed" = true ]; then
echo "- Development tools and libraries"
fi
echo "- Additional applications:"
echo " * System utilities (fish with Oh My Fish, flameshot, wofi, etc.)"
echo " * AppImageLauncher"
echo " * Google Chrome"
echo " * Flatpak apps (MegaSync, Dropbox, VLC, Brave, qBittorrent, PDF Arranger)"
echo ""
echo "- Autostart configured for:"
echo " * AppImageLauncher"
echo " * Flameshot"
echo " * Wofi (Wayland-compatible application launcher)"
echo " * MegaSync"
echo ""
echo "Installation done. Please reboot your system for all changes to take effect!"
echo "Command to reboot: sudo reboot now"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment