Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
326 changes: 184 additions & 142 deletions fedora_first_run.sh
Original file line number Diff line number Diff line change
@@ -1,172 +1,206 @@
#!/bin/bash

# Global variables
#the LABEL of the second nvme drive (steam library for me)
LABEL=crucial2tb
USER=nathan
GROUP=nathan
PERMISSION=755
HOSTNAME=nathan-legion
PRETTYHOSTNAME="Nathan's Gaming Laptop"
question () {
echo -n "$1 [y/N]: "
read -r response
response=$(echo "$response" | tr '[:upper:]' '[:lower:]')

if [[ "$response" == "y" || "$response" == "yes" ]]; then
return 1
else
return 0
fi
}

echo "Do you want to change the hostname to $PRETTYHOSTNAME? (y/n)"
read -r response
response=$(echo "$response" | tr '[:upper:]' '[:lower:]')
# Global variables
USERNAME=$USER
if [ ! -z $SUDO_USER ]; then
USERNAME=$SUDO_USER
fi
GROUP=$USERNAME
PERMISSION=755
NEWHOSTNAME="$(< /sys/devices/virtual/dmi/id/product_name)"
PRETTYHOSTNAME="$USERNAME's $NEWHOSTNAME"

if [[ "$response" == "y" || "$response" == "yes" ]]; then
echo "Changing Hostname..."
sudo hostnamectl set-hostname "$HOSTNAME"
sudo hostnamectl set-hostname "$PRETTYHOSTNAME" --pretty
# Device settings
question "Change the hostname to \"$PRETTYHOSTNAME\"?"
dochangehostname=$?

echo "Hostname changed to $PRETTYHOSTNAME."
else
echo "Hostname change aborted by the user."
question "Do you want to setup a second drive?"
dosetupseconddrive=$?
if [ "$dosetupseconddrive" == 1 ]; then
read -p "Drive label: " -r DRIVELABEL
fi

# Drivers / repos
question "Install Fedora multimedia codecs?"
doinstallmultimedia=$?

question "Enable RPM Fusion free and non-free?"
doenablerpmfusion=$?

if [ "$doenablerpmfusion" == 1 ]; then
question "Install nVidia drivers?"
doinstallnvidia=$?

question "Install additional codecs?"
doinstallcodecs=$?
if [ "$doinstallcodecs" == 1 ]; then
question "Install Intel(recent) hardware accelerated codec?"
doinstallintelcodec=$?

question "Install Intel(older) hardware accelerated codec?"
doinstallinteloldercodec=$?

question "Install AMD hardware accelerated codec?"
doinstallamdcodec=$?

question "Install nVidia hardware accelerated codec?"
doinstallnvidiacodec=$?
fi
fi

#Enable RPM Fusion:
echo "Enabling RPM Fusion free and non-free"
sudo dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
sudo dnf install -y https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
question "Install Flatpak and add Flathub repo?"
doinstallflatpakhub=$?

# Multimedia codecs, allows gifs, videos and all streaming services
echo "Installing Fedora multimedia codes"
sudo dnf group install -y Multimedia
# Software FOSS
question "Install git?"
doinstallgit=$?

# Syncthing
echo "Do you want to install Syncthing? (y/n)"
read -r response
question "Install Syncthing?"
doinstallsyncthing=$?

response=$(echo "$response" | tr '[:upper:]' '[:lower:]')
if [[ "$response" == "y" || "$response" == "yes" ]]; then
echo "Installing Syncthing..."
sudo dnf install -y syncthing
else
echo "Installation aborted by the user."
fi
question "Install VSCodium (from https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo)?"
doinstallvscodium=$?

if [ "$doenableflatpakhub" == 1 ]; then
question "Install Signal (from Flathub)?"
doinstallsignal=$?

#Setup second drive mount point
echo "Do you have a second drive you would like to setup (y/n)"
read -r response
response=$(echo "$response" | tr '[:upper:]' '[:lower:]')
if [[ "$response" == "y" || "$response" == "yes" ]]; then
echo "Creating mountpoint for second drive"
sudo mkdir /mnt/$LABEL
sudo chown -R $USER:$GROUP /mnt/$LABEL
sudo chmod $PERMISSION /mnt/$LABEL
else
echo "Installation aborted by the user."
question "Install 'Beyond All Reason'(from Flathub)?"
doinstallbeyondallreason=$?
fi

# Software non-FOSS
if [ "$doenablerpmfusion" == 1 ]; then
question "Install Steam (from rpmfusion-nonfree)?"
doinstallsteam=$?

# Extract UUID and FSTYPE from the drive labeled $LABEL
INFO=$(sudo blkid | grep "LABEL=\"$LABEL\"")
UUID=$(echo "$INFO" | awk -F '"' '{print $4}')
FSTYPE=$(echo "$INFO" | awk -F '"' '{print $8}')
question "Install Discord (from rpmfusion-nonfree)?"
doinstalldiscord=$?
fi
####

# Check if the UUID was successfully retrieved
if [ -n "$UUID" ]; then
echo "UUID of $LABEL: $UUID"
# Change hostname
if [ "$dochangehostname" == 1 ]; then
echo "Changing Hostname..."
sudo hostnamectl set-hostname "$NEWHOSTNAME"
sudo hostnamectl set-hostname "$PRETTYHOSTNAME" --pretty

# Prepare the fstab entry string
FSTAB_ENTRY="UUID=$UUID /mnt/$LABEL $FSTYPE defaults 0 2"
echo "Hostname changed to \"$PRETTYHOSTNAME\"."
fi

# Check if the entry already exists in fstab to avoid duplicates
if grep -q "$FSTAB_ENTRY" /etc/fstab; then
echo "Entry already exists in /etc/fstab."
# Setup second drive mount point
if [ "$dosetupseconddrive" == 1 ]; then
echo "Creating mountpoint for second drive"
sudo mkdir /mnt/$DRIVELABEL
sudo chown -R $USERNAME:$GROUP /mnt/$DRIVELABEL
sudo chmod $PERMISSION /mnt/$DRIVELABEL

# Extract UUID and FSTYPE from the drive labeled $DRIVELABEL
INFO=$(sudo blkid | grep "LABEL=\"$DRIVELABEL\"")
UUID=$(echo "$INFO" | awk -F '"' '{print $4}')
FSTYPE=$(echo "$INFO" | awk -F '"' '{print $8}')

# Check if the UUID was successfully retrieved
if [ -n "$UUID" ]; then
echo "UUID of $DRIVELABEL: $UUID"

# Prepare the fstab entry string
FSTAB_ENTRY="UUID=$UUID /mnt/$DRIVELABEL $FSTYPE defaults 0 2"

# Check if the entry already exists in fstab to avoid duplicates
if grep -q "$FSTAB_ENTRY" /etc/fstab; then
echo "Entry already exists in /etc/fstab."
else
# Append the new fstab entry
echo "$FSTAB_ENTRY" | sudo tee -a /etc/fstab > /dev/null
echo "New fstab entry added."

echo "running daemon-reload"
systemctl daemon-reload

echo "mounting $DRIVELABEL"
sudo mount -a
fi
else
# Append the new fstab entry
echo "$FSTAB_ENTRY" | sudo tee -a /etc/fstab > /dev/null
echo "New fstab entry added."
echo "No UUID found for the label $DRIVELABEL. Failed to setup second drive."
fi
else
echo "No UUID found for the label $LABEL"
fi

echo "running daemon-reload"
systemctl daemon-reload

echo "mounting $LABEL"
sudo mount -a

#install steam
echo "Do you want to install steam? (y/n)"
read -r response
response=$(echo "$response" | tr '[:upper:]' '[:lower:]')
if [[ "$response" == "y" || "$response" == "yes" ]]; then
echo "Installing steam..."
sudo dnf install -y steam
else
echo "Installation aborted by the user."
# Multimedia codecs, allows gifs, videos and all streaming services
if [ "$doinstallmultimedia" == 1 ]; then
echo "Installing Fedora multimedia codes"
sudo dnf group install -y Multimedia
fi

# Enable RPM Fusion
if [ "$doenablerpmfusion" == 1 ]; then
echo "Enabling RPM Fusion free and non-free"
sudo dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
sudo dnf install -y https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
fi

#install discord
echo "Do you want to install discord? (y/n)"
read -r response
response=$(echo "$response" | tr '[:upper:]' '[:lower:]')
if [[ "$response" == "y" || "$response" == "yes" ]]; then
echo "Installing discord..."
sudo dnf install -y discord
else
echo "Installation aborted by the user."
# Install nVidia drivers
if [ "$doinstallnvidia" == 1 ]; then
echo "Installing nVidia Drivers..."
sudo dnf update -y # and reboot if you are not on the latest kernel
sudo dnf install -y akmod-nvidia # rhel/centos users can use kmod-nvidia instead
sudo dnf install -y xorg-x11-drv-nvidia-cuda #optional for cuda/nvdec/nvenc support
fi

# Installing Git
echo "Do you want to install git? (y/n)"
read -r response
response=$(echo "$response" | tr '[:upper:]' '[:lower:]')
if [[ "$response" == "y" || "$response" == "yes" ]]; then
echo "Installing git..."
sudo dnf install -y git
else
echo "Installation aborted by the user."
if [ "$doinstallcodecs" == 1 ]; then
echo "Installing additional codecs..."
sudo dnf -y swap ffmpeg-free ffmpeg --allowerasing
sudo dnf -y groupupdate multimedia --setopt="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin
sudo dnf -y groupupdate sound-and-video

if [ "$doinstallintelcodec" == 1 ]; then
sudo dnf install -y intel-media-driver
fi
if [ "$doinstallinteloldercodec" == 1 ]; then
sudo dnf install -y libva-intel-driver
fi
if [ "$doinstallamdcodec" == 1 ]; then
sudo dnf -y swap mesa-va-drivers mesa-va-drivers-freeworld
sudo dnf -y swap mesa-vdpau-drivers mesa-vdpau-drivers-freeworld
fi
if [ "$doinstallnvidiacodec" == 1 ]; then
sudo dnf install -y nvidia-vaapi-driver
fi
fi

# Installing Flatpak
echo "Do you want to install flatpak? (y/n)"
read -r response
response=$(echo "$response" | tr '[:upper:]' '[:lower:]')
if [[ "$response" == "y" || "$response" == "yes" ]]; then
# Install Flatpak/Flathub
if [ "$doenableflatpakhub" == 1 ]; then
echo "Installing flatpak..."
sudo dnf install -y flatpak
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

else
echo "Installation aborted by the user."
fi

#Installing Signal
echo "Do you want to install signal (Flatpak)? (y/n)"
read -r response
response=$(echo "$response" | tr '[:upper:]' '[:lower:]')
if [[ "$response" == "y" || "$response" == "yes" ]]; then
echo "Installing signal..."
flatpak install flathub org.signal.Signal

else
echo "Installation aborted by the user."
# Install Git
if [ "$doinstallgit" == 1 ]; then
echo "Installing git..."
sudo dnf install -y git
fi

#Install Beyond All Reason
echo "Do you want to install Beyond All Reason (Flatpak)? (y/n)"
read -r response
response=$(echo "$response" | tr '[:upper:]' '[:lower:]')
if [[ "$response" == "y" || "$response" == "yes" ]]; then
echo "Installing Beyond All Reason..."
flatpak install flathub info.beyondallreason.bar

else
echo "Installation aborted by the user."
# Install Syncthing
if [ "$doinstallsyncthing" == 1 ]; then
echo "Installing Syncthing..."
sudo dnf install -y syncthing
fi

#Install codium
echo "Do you want to install Codium? (y/n)"
read -r response
response=$(echo "$response" | tr '[:upper:]' '[:lower:]')
if [[ "$response" == "y" || "$response" == "yes" ]]; then
# Install VSCodium
if [ "$doinstallvscodium" == 1 ]; then
echo "Installing Codium..."
GPG_KEY_URL="https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/-/raw/master/pub.gpg"
REPO_FILE="/etc/yum.repos.d/vscodium.repo"
Expand All @@ -186,20 +220,28 @@ if [[ "$response" == "y" || "$response" == "yes" ]]; then

# Install Codium using DNF
sudo dnf install -y codium
else
echo "Installation aborted by the user."
fi

#Install nVidia Drivers
echo "Do you want to install nVidia Drivers? (y/n)"
read -r response
response=$(echo "$response" | tr '[:upper:]' '[:lower:]')
if [[ "$response" == "y" || "$response" == "yes" ]]; then
echo "Installing nVidia Drivers..."
sudo dnf update -y # and reboot if you are not on the latest kernel
sudo dnf install akmod-nvidia # rhel/centos users can use kmod-nvidia instead
sudo dnf install xorg-x11-drv-nvidia-cuda #optional for cuda/nvdec/nvenc support
# Install Signal
if [ "$doinstallsignal" == 1 ]; then
echo "Installing signal..."
flatpak install flathub org.signal.Signal
fi

# Install Beyond All Reason
if [ "$doinstallbeyondallreason" == 1 ]; then
echo "Installing Beyond All Reason..."
flatpak install flathub info.beyondallreason.bar
fi

# Install Steam
if [ "$doinstallsteam" == 1 ]; then
echo "Installing steam..."
sudo dnf install -y steam
fi

else
echo "Installation aborted by the user."
# Install Discord
if [ "$doinstalldiscord" == 1 ]; then
echo "Installing discord..."
sudo dnf install -y discord
fi