Files
Fedora-post-install-script/fedora_post_install.sh
2026-03-12 21:07:58 +01:00

145 lines
5.1 KiB
Bash

#!/bin/bash
#Automatically set up all the nice stuff in Fedora
#Just a lazier way to do this: https://github.com/wz790/Fedora-Noble-Setup?tab=readme-ov-file
#Check if we're running this as root
if [[ $EUID > 0 ]]; then
echo "We'll need root permissions for where we're going."
sudo su -
fi
echo "adding RPM fusion repos & updating DNF"
# Get the free repository (most stuff you need)
dnf install -y https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm &> /dev/null
# Get the nonfree repository (NVIDIA drivers, some codecs)
dnf install -y https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm &> /dev/null
# Installing nushell
echo "[gemfury-nushell]
name=Gemfury Nushell Repo
baseurl=https://yum.fury.io/nushell/
enabled=1
gpgcheck=0
gpgkey=https://yum.fury.io/nushell/gpg.key" | tee /etc/yum.repos.d/fury-nushell.repo
dnf install -y nushell &> /dev/null
# Update everything so it all plays nice together
echo "Updating everything..."
dnf group upgrade core -y &> /dev/null
dnf check-update &> /dev/null
dnf update -y &> /dev/null
###Firmware updates
# See what can be updated
fwupdmgr get-devices &> /dev/null
# Refresh the firmware database
fwupdmgr refresh --force &> /dev/null
# Check for updates
fwupdmgr get-updates &> /dev/null
# Apply them
fwupdmgr update &> /dev/null
###Flathub
echo "Fixing flathub"
# Remove the limited Fedora repo
flatpak remote-delete fedora &> /dev/null
# Add the good stuff
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo &> /dev/null
###GFX time
echo "Updating GFX drivers"
# Identify the GFX chip
lspci=$(lspci | grep -i 'vga\|3d\|2d') &> /dev/null
# Install the appropriate drivers
# AMD
if [[ $lspci =~ AMD ]]; then
echo "AMD GPU found, installing drivers..."
dnf install -y mesa-dri-drivers mesa-vulkan-drivers vulkan-loader mesa-libGLU mesa-va-drivers-freeworld mesa-vdpau-drivers-freeworld &> /dev/null
fi
# Intel
if [[ $lspci =~ Intel ]]; then
echo "Intel GPU found, installing drivers..."
dnf install -y mesa-dri-drivers mesa-vulkan-drivers vulkan-loader mesa-libGLU intel-media-driver &> /dev/null
fi
# Nvidia
if [[ $lspci =~ Nvidia ]]; then
echo "Nvidia GPU found, installing drivers..."
# Install kernel headers and dev tools
dnf install -y kernel-devel kernel-headers gcc make dkms acpid libglvnd-glx libglvnd-opengl libglvnd-devel pkgconfig &> /dev/null
# Set open kernel module macro (one-time step for RTX 4000+)
sh -c 'echo "%_with_kmod_nvidia_open 1" > /etc/rpm/macros.nvidia-kmod' &> /dev/null
# Install the Nvidia driver
echo "Building Nvidia driver, this step will take 5-15 minutes. Blame Nvidia, not me."
dnf install -y akmod-nvidia xorg-x11-drv-nvidia-cuda &> /dev/null
echo "Nvidia build complete. Check if it worked after rebooting by running nvidia-smi"
dnf install -y libva-nvidia-driver &> /dev/null
fi
###Video codecs
echo "Installing video codecs"
dnf swap -y ffmpeg-free ffmpeg --allowerasing &> /dev/null
dnf install -y gstreamer1-plugins-{bad-\*,good-\*,base} gstreamer1-plugin-openh264 gstreamer1-libav lame\* --exclude=gstreamer1-plugins-bad-free-devel &> /dev/null
dnf group install -y multimedia &> /dev/null
dnf group install -y sound-and-video &> /dev/null
dnf install -y ffmpeg-libs libva libva-utils openh264 gstreamer1-plugin-openh264 mozilla-openh264 &> /dev/null
dnf config-manager --set-enabled fedora-cisco-openh264 &> /dev/null
dnf update -y &> /dev/null
###Archive support
echo "Installing archive support"
dnf install -y p7zip p7zip-plugins unrar &> /dev/null
###MS fonts
echo "Installing MS fonts"
dnf install -y curl cabextract xorg-x11-font-utils fontconfig &> /dev/null
rpm -i --nodigest --nosignature https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm &> /dev/null
fc-cache -fv &> /dev/null
###AppImage support
echo "Adding AppImage support"
dnf install -y fuse fuse-libs &> /dev/null
flatpak install -y flathub it.mijorus.gearlever &> /dev/null
# AppImage autoupdate
# Create the service unit
tee /etc/systemd/system/flatpak-update.service > /dev/null <<'EOF'
[Unit]
Description=Update Flatpak apps automatically
[Service]
Type=oneshot
ExecStart=/usr/bin/flatpak update -y --noninteractive
EOF
# Create the timer unit
tee /etc/systemd/system/flatpak-update.timer > /dev/null <<'EOF'
[Unit]
Description=Run Flatpak update every 24 hours
Wants=network-online.target
Requires=network-online.target
After=network-online.target
[Timer]
OnBootSec=120
OnUnitActiveSec=24h
[Install]
WantedBy=timers.target
EOF
# Reload systemd and enable the timer
systemctl daemon-reload &> /dev/null
systemctl enable --now flatpak-update.timer &> /dev/null
###Bit-perfect audio support
sed -i 's+\#default\.clock\.rate+default.clock.rate+g' /usr/share/pipewire/pipewire.conf
sed -i 's+\#default\.clock\.allowed-rates.*+default.clock.allowed-rates = [ 44100, 48000, 88200, 96000, 192000 ]+g' /usr/share/pipewire/pipewire.conf
cp /etc/pipewire/pipewire.conf /etc/pipewire/pipewire.conf.bak &> /dev/null
cp /usr/share/pipewire/pipewire.conf /etc/pipewire/pipewire.conf -f &> /dev/null
###All done
echo "Script completed, please reboot."