Skip to content

Instantly share code, notes, and snippets.

@florian-h05
Last active December 11, 2024 16:58
Show Gist options
  • Save florian-h05/73a63aee63d9a7250f20b921465d9e45 to your computer and use it in GitHub Desktop.
Save florian-h05/73a63aee63d9a7250f20b921465d9e45 to your computer and use it in GitHub Desktop.
Install & configure a fresh installation of Fedora Workstation for my personal requirements
#!/bin/bash
# Purpose: Install & configure a fresh installation of Fedora Workstation for my personal requirements.
# Author: Florian Hotze
# License: MIT License
# Prerequisites:
# Install Fedora KDE Plasma Spin on hard drive.
# Pre-run tasks:
# - Setup timeshift backups, see https://mutschler.dev/linux/fedora-btrfs-33/
# - For ASUS laptops, see https://asus-linux.org/wiki/fedora-guide/
# - For NVIDIA GPU, install drivers, see https://rpmfusion.org/Howto/NVIDIA
# use X11 instead of Wayland, see https://docs.fedoraproject.org/en-US/quick-docs/configuring-xorg-as-default-gnome-session/
# Post-run tasks:
# - Install CA certificate, see https://docs.fedoraproject.org/en-US/quick-docs/using-shared-system-certificates/#proc_adding-new-certificates
# - Install mTLS client certificate
# - Install SSH keys (~/.ssh folder) if not generated by this script
# - Distribute SSH key to hosts and Git servers
# - Setup SSH key for Git operations, see https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent
# - Setup SSH key for Git Commit Signing, see https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key#telling-git-about-your-ssh-key
# - Add SSH key to GitHub, see https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account
# - Setup network shares
# - Setup Mozilla Thunderbird mail (~/.thunderbird folder)
# - Install JetBrains Toolbox: curl -fsSL https://raw.githubusercontent.com/nagygergo/jetbrains-toolbox-install/master/jetbrains-toolbox.sh | bash
# Optional post-run tasks:
# - Add toggle-airplane.bash script, see https://gist.github.com/florian-h05/09c87f043f929fb0a53db5597cbc6f9f.
# - For ASUS laptops, add keyboard backlight script, see https://gist.github.com/florian-h05/08c1004d7af4e141afd959eee7cee20a.
# - For ASUS laptops with AniMe matrix, see https://github.com/florian-h05/anime-matrix-datetime-battery.
# - When OpenRazer/Polychromatic is installed: Sign the openrazer kernel modules, see:
# https://gist.github.com/sbueringer/bd8cec239c44d66967cf307d808f10c4 and
# https://gist.github.com/sbueringer/bd8cec239c44d66967cf307d808f10c4?permalink_comment_id=3827174#gistcomment-3827174
# - Install SDKMAN! (https://sdkman.io/) to install more JDKs (e.g. Oracle GraalVM)
# - Install Ruby Version Manager (rvm) for openHAB website deployment, see https://rvm.io/rvm/install
RED='\033[0;31m'
NC='\033[0m' # No Color
echo_red () {
echo -e "${RED}${1}${NC}"
}
echo_run () {
echo -e "${RED}command:${NC} ${1}"
$1
}
USERNAME=${1}
if [${USERNAME} == ""]; then echo_red "Please provider your username as argument." && exit 1; fi
if [ "$EUID" -ne 0 ]; then echo_red "Please run as root" && exit 1; fi
# System upgrade/update
echo_red "\nPerforming system upgrade ..."
echo_run "dnf upgrade --refresh"
echo_red "\nPlease reboot!"
echo_run "dnf update"
# RPM Fusion package repositories
echo_red "\nAdding PRM Fusion repositories ..."
echo_run "dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm"
echo_run "dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm"
# EarlyOOM (prevents system becoming unresponsive due to OOM)
echo_red "\nInstalling EarlyOOM ..."
echo_run "dnf install earlyoom -y"
echo_run "systemctl enable --now earlyoom"
# SSH server
echo_red "Do you want to enable SSH server? (y/N)"
read -r choice
case "${choice}" in
y|Y ) systemctl enable sshd;;
n|N ) ;;
*) ;;
esac
### cifs-utils for Samba network shares
echo_red "\nInstalling cifs-utils for mounting SMB shares ..."
echo_run "dnf install cifs-utils -y"
# Enable AirPlay support for pipewire audio daemon (see https://wiki.archlinux.org/title/PipeWire)
# Doesn't work at the moment!
#echo_red "\nEnabling AirPlay support for pipewire audio daemon ..."
#echo_run "mkdir -p /etc/pipewire/pipewire.conf.d"
#echo_run 'printf "context.modules = [
# {
# name = libpipewire-module-raop-discover
# args = { }
# }
#]" | tee /etc/pipewire/pipewire.conf.d/raop-discover.conf > /dev/null'
# Install Chromium browser
echo_red "\nInstalling Chromium ..."
echo_run "dnf install chromium -y"
# Install fastfetch for system stats
echo_red "\nInstalling fastfetch (system stats) ..."
echo_run "dnf install fastfetch -y"
echo_red "Enabling fastfetch on shell login for user (.bashrc) ..."
echo_run 'echo "fastfetch" | tee -a "/home/${USERNAME}/.bashrc" > /dev/null'
# Install fish shell, mosh & tmux
echo_red "\nInstalling fish shell, mosh & tmux ..."
echo_run "dnf install fish mosh tmux -y"
# Causes trouble with KWayland!
#echo_red "Configuring fish as default shell for user (.bashrc) ..."
#echo '# See https://wiki.archlinux.org/title/fish
#if [[ $(ps --no-header --pid=$PPID --format=comm) != "fish" && -z ${BASH_EXECUTION_STRING} ]]; then
# shopt -q login_shell
# LOGIN_OPTION="--login" || LOGIN_OPTION=""
# exec fish $LOGIN_OPTION
#fi' | tee -a /home/${USERNAME}/.bashrc > /dev/null
# Install Ansible
echo_red "\nInstalling Ansible ..."
echo_run "dnf install ansible -y"
# Install Keepass password manager
echo_red "\nInstalling KeepassXC ..."
echo_run "dnf install keepassxc -y"
# Install Visual Studio Code
echo_red "\nInstalling Visual Studio Code ..."
echo_run "rpm --import https://packages.microsoft.com/keys/microsoft.asc"
echo "Setting up repo ..."
sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
dnf update
echo_run "dnf install code -y"
# Install Git
echo_red "\nInstalling Git ..."
echo_run "dnf install git -y"
# Setup Git
setup_git () {
echo_red "\nConfiguring Git ..."
echo -n "Set Git username (prename surname): "
read -r gitUsername
echo -n "Set Git email: "
read -r gitEmail
sudo -H -u ${USERNAME} bash -c 'git config --global user.name "${gitUsername}"'
sudo -H -u ${USERNAME} bash -c 'git config --global user.email "${gitEmail}"'
echo_red "Please remember to setup the commit signing key, see https://docs.github.com/en/authentication/managing-commit-signature-verification"
}
echo_red "Do you want to setup Git? (y/N)"
read -r choice
case "${choice}" in
y|Y ) setup_git;;
n|N ) ;;
*) ;;
esac
# Install GitHub CLI
echo_red "\nInstalling GitHub CLI ..."
echo_run "dnf install gh -y"
# Setup SSH key
setup_sshkey () {
echo_red "\nGenerating SSH key ..."
mkdir "/home/${USERNAME}/.ssh"
echo_run "ssh-keygen -t ed25519 -f /home/${USERNAME}/.ssh/id_ed25519"
chown -R "${USERNAME}:${USERNAME}" "/home/${USERNAME}/.ssh"
echo_run "tail /home/${USERNAME}/.ssh/id_ed25519.pub"
}
echo_red "\nDo you want to generate a SSH key? (y/N)"
read -r choice
case "${choice}" in
y|Y ) setup_sshkey;;
n|N ) ;;
*) ;;
esac
# Setup GPG key
setup_gpgkey () {
echo_red "\nGenerating GPG key ..."
echo_run "gpg --homedir /home/${USERNAME}/.gnupg --full-generate-key"
chown -R "${USERNAME}:${USERNAME}" "/home/${USERNAME}/.gnupg"
}
echo_red "\nDo you want to generate a GPG key? (y/N)"
read -r choice
case "${choice}" in
y|Y ) setup_gpgkey;;
n|N ) ;;
*) ;;
esac
# Install Adoptium Temurin repo
adoptiumRepo="[Adoptium]
name=Adoptium
baseurl=https://packages.adoptium.net/artifactory/rpm/fedora/\$releasever/\$basearch
enabled=1
gpgcheck=1
gpgkey=https://packages.adoptium.net/artifactory/api/gpg/key/public"
echo_red "\Adding Adoptium repo ..."
echo "${adoptiumRepo}" > /etc/yum.repos.d/adoptium.repo
# Install Java 17
echo_red "\nInstalling Java 17 JDK ..."
echo_run "dnf install temurin-17-jdk -y"
# Install Java 21
echo_red "\nInstalling Java 21 JDK ..."
echo_run "dnf install temurin-21-jdk -y"
# Install Apache Maven build system
echo_red "\nInstalling Apache Maven ..."
echo_run "dnf install maven -y"
# Install Shellcheck (linter for .bash and more)
echo_red "\nInstalling Shellcheck ..."
echo_run "dnf install ShellCheck -y"
# Install Mozilla Thunderbird
echo_red "\nInstalling Mozilla Thunderbird ..."
echo_run "dnf install thunderbird -y"
# Install OnlyOffice
install_onlyoffice () {
echo_red "\nInstalling OnlyOffice ..."
echo_run "flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo"
echo_run "flatpak install flathub org.onlyoffice.desktopeditors -y"
}
echo_red "\nDo you want to install OnlyOffice? (y/N)"
read -r choice
case "${choice}" in
y|Y ) install_onlyoffice;;
n|N ) ;;
*) ;;
esac
# Install Synology Drive client
install_synologydrive () {
echo_red "\nInstalling Synology Drive client ..."
echo_run "flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo"
echo_run "flatpak install flathub com.synology.SynologyDrive -y"
}
echo_red "\nDo you want to install Synology Drive client? (y/N)"
read -r choice
case "${choice}" in
y|Y ) install_synologydrive;;
n|N ) ;;
*) ;;
esac
# Install Cider (Apple Music)
install_cider () {
echo_red "\nInstalling Cider (Apple Music) ..."
echo_run "flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo"
echo_run "flatpak install flathub sh.cider.Cider -y"
}
echo_red "\nDo you want to install Cider (Apple Music)? (y/N)"
read -r choice
case "${choice}" in
y|Y ) install_cider;;
n|N ) ;;
*) ;;
esac
# Install Solaar to manage Logitech devices
install_solaar() {
echo_red "\nInstalling Solaar (Logitech device manager) ..."
echo_run "dnf install solaar -y"
}
echo_red "\nDo you want to install Solaar (Logitech device manager)? (y/N)"
read -r choice
case "${choice}" in
y|Y ) install_solaar;;
n|N ) ;;
*) ;;
esac
# Install OpenRazer and Polychromatic (Razer Synapse alternative)
install_razer () {
echo_red "\nInstalling OpenRazer ..."
sudo gpasswd -a $USERNAME plugdev
echo_run "dnf install kernel-devel -y"
echo_run "dnf config-manager --add-repo https://download.opensuse.org/repositories/hardware:/razer/Fedora_$(rpm -E %fedora)/hardware:razer.repo"
echo_run "dnf install openrazer-meta -y"
echo_red "\nOpenRazer requires an reboot to complete the driver installation, please reboot later."
echo_red "\nInstalling Polychromatic ..."
echo_run "dnf install polychromatic -y"
}
echo_red "\nDo you want to install Razer device manager? (y/N)"
read -r choice
case "${choice}" in
y|Y ) install_razer;;
n|N ) ;;
*) ;;
esac
# Install Discord
install_discord () {
echo_red "\nInstalling Discord ..."
echo_run "dnf install dnf-plugins-core -y"
echo_run "flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo"
echo_run "flatpak install flathub com.discordapp.Discord -y"
}
echo_red "\nDo you want to install Discord? (y/N)"
read -r choice
case "${choice}" in
y|Y ) install_discord;;
n|N ) ;;
*) ;;
esac
# Install iCloud
install_icloud () {
echo_red "\nInstalling iCloud ..."
echo_run "dnf install snapd -y"
echo_run "ln -s /var/lib/snapd/snap /snap"
echo_run "snap install icloud-for-linux"
}
echo_red "\nDo you want to install iCloud? (y/N)"
read -r choice
case "${choice}" in
y|Y ) install_icloud;;
n|N ) ;;
*) ;;
esac
#!/bin/fish
# Purpose: Continue installation & configuration of a fresh installation of Fedora Workstation for my personal requirements from fish shell.
# Author: Florian Hotze
# License: MIT License
# Prerequisites:
# Run fedora-setup.bash, then open fish shell. Run with "fish fedora-setup-fish.bash".
# Post-Run tasks:
# - Setup default Node versions: "set --universal nvm_default_version 16"
# - Make sure that JAVA_HOME is always set: Add to ~/.config/fish/config.fish:
# set -gx JAVA_HOME $(readlink -nf $(which java) | xargs dirname | xargs dirname)
# Optional post-run tasks:
# - Enable SDKMAN! for fish if SDKMAN! is installed, see https://gist.github.com/fedragon/cccf6d65dd6e0da1dc2a1200db8412f4
# - Install rvm fish integration (https://rvm.io/integration/fish) if rvm is installed
set RED '\033[0;31m'
set NC '\033[0m' # No Color
function echo_red -a msg
echo -e "$RED$msg$NC"
end
# Install fisher (package manager for fish shell)
echo_red "\nInstalling fisher ..."
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher
# Install NodeJS version manager (nvm)
echo_red "\nInstalling NodeJS version manager ..."
fisher install jorgebucaran/nvm.fish
nvm install latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment