Skip to content

Instantly share code, notes, and snippets.

@antoniordo
Created October 18, 2019 03:37
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save antoniordo/f0d44ae1669c7700648416c85a2046ab to your computer and use it in GitHub Desktop.
Save antoniordo/f0d44ae1669c7700648416c85a2046ab to your computer and use it in GitHub Desktop.
Configure fedora for Java development
#!/usr/bin/env bash
set -e
#==========================================================================================
# Configurations
#==========================================================================================
# Set hostname
PC_HOSTNAME=""
# Disable Wayland to use xorg as dafult
DISABLE_WAYLAND=false
#==========================================================================================
FEDORA_RELEASE=$(rpm -E %fedora)
TEMP_DOWNLOAD_DIRECTORY=$(mktemp -d)
DNF_REPOS_DIRECTORY="/etc/yum.repos.d"
function die_configuration_parameter() {
local parameter_name=$1
echo "Configuration of variable ${parameter_name} is needed to be set in script file"
echo "Edit the script with command: vi $0"
exit 2
}
function check_script_configuration() {
if [[ -z ${PC_HOSTNAME} ]]; then
die_configuration_parameter "PC_HOSTNAME"
fi
if [[ -z ${DISABLE_WAYLAND} ]]; then
die_configuration_parameter "DISABLE_WAYLAND"
fi
}
function check_non_root() {
if [[ ! $EUID -ne 0 ]]; then
echo "This script can't be executed as root"
exit 1
fi
}
check_non_root
check_script_configuration
echo ""
echo "==================================================================="
echo "Fedora Development Configuration"
echo "==================================================================="
echo "Please supply your password wheen needed."
echo ""
echo "Press enter to continue"
echo "To abort press ctrl + c"
read -p ""
clear
echo "[ Initializing ] ========================================================================="
echo 'Defaults:'"$USER"' !authenticate' | sudo tee -a /etc/sudoers
echo "[ Configure: System ] ===================================================================="
echo "${PC_HOSTNAME}" | sudo tee /etc/hostname
echo 'fs.inotify.max_user_watches = 524288' | sudo tee /etc/sysctl.d/fsinotify.conf
echo 'send dhcp-client-identifier = hardware;' | sudo tee -a /etc/dhcp/dhclient.conf
echo "[ Distro update ] ========================================================================"
sudo dnf update -y --refresh
echo "[ Configure: Third party repositories ] ======================================================"
# RPM Fusion repositories
sudo dnf install -y "https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-${FEDORA_RELEASE}.noarch.rpm"
sudo dnf install -y "https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-${FEDORA_RELEASE}.noarch.rpm"
# Chrome
sudo tee ${DNF_REPOS_DIRECTORY}/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
# Yarn repository
sudo wget 'https://dl.yarnpkg.com/rpm/yarn.repo' -O "${DNF_REPOS_DIRECTORY}/yarn.repo"
# VirtualBox repository
sudo wget 'http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo' -O "${DNF_REPOS_DIRECTORY}/virtualbox.repo"
echo "[ Install: Terminal tools ] =============================================================="
sudo dnf install -y zsh.x86_64 fish.x86_64 tilix.x86_64
OH_MY_ZSH_SCRIPT="${TEMP_DOWNLOAD_DIRECTORY}/install-oh_my_zsh.sh"
wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O "${OH_MY_ZSH_SCRIPT}"
sh "${OH_MY_ZSH_SCRIPT}" --unattended
echo "[ Install: Google Chrome ] ==============================================================="
sudo dnf install -y google-chrome-stable
echo "[ Install: Java tools for development ] =================================================="
sudo dnf install -y java-1.8.0-openjdk-src.x86_64 maven.noarch gradle.noarch scala.noarch groovy.noarch
echo "[ Install: Javascript tools for development ] ============================================"
sudo dnf install -y nodejs.x86_64 yarn.noarch
echo "[ Install: Virtual Box ] ================================================================="
sudo dnf install -y binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms
sudo dnf install -y kernel-devel-$(uname -r)
sudo dnf install -y VirtualBox-6.0.x86_64
sudo /usr/lib/virtualbox/vboxdrv.sh setup
echo "[ Install: Vangrant ] ===================================================================="
sudo dnf install -y vagrant.noarch
echo "[ Install: Vault ] ======================================================================="
sudo dnf install -y vault.noarch
echo "[ Install: Subversion ] ================================================================="
sudo dnf install -y subversion.x86_64
echo "[ Install: Gnome additions ] ============================================================"
sudo dnf install -y gnome-tweaks gnome-themes-extra.x86_64 epiphany.x86_64 gtk2-engines \
gtk-murrine-engine dconf-editor.x86_64 arc-theme.noarch
echo "[ Install: Database tools ] =============================================================="
sudo dnf install -y 'http://dbeaver.jkiss.org/files/dbeaver-ce-latest-stable.x86_64.rpm'
echo "[ Install: Docker ] ======================================================================"
sudo dnf remove docker docker-client docker-client-latest docker-common docker-latest \
docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux \
docker-engine
sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo 'https://download.docker.com/linux/fedora/docker-ce.repo'
sudo dnf install -y docker-ce docker-compose.noarch
sudo groupadd -f docker
sudo gpasswd -a "${USER}" docker
sudo systemctl enable docker
sudo systemctl restart docker
echo "[ Install: Command line tools ] =========================================================="
sudo dnf install -y vim jq xclip nano
echo "[ Configure: Development directories ] ==================================================="
mkdir -p "$HOME/dev/projects"
mkdir -p "$HOME/dev/apps"
mkdir -p "$HOME/dev/sdk"
mkdir -p "$HOME/dev/scripts"
mkdir -p "$HOME/.m2"
echo "export PATH=\$PATH:$HOME/dev/scripts" >>"$HOME/.profile"
echo "[ Configure: SSH ] ======================================================================="
sudo systemctl enable sshd
sudo systemctl start sshd
ssh-keygen -N '' -C "${USER}@${PC_HOSTNAME}-$(date -I)" -f "/home/${USER}/.ssh/id_rsa"
echo "[ Tear down ] ============================================================================"
if ${DISABLE_WAYLAND}; then
sudo sed --in-place=.bak -e 's/#WaylandEnable=false/WaylandEnable=false/g' /etc/gdm/custom.conf
fi
sudo sed --in-place=.bak -e "/Defaults:$USER/d" /etc/sudoers
rm -rf "$TEMP_DOWNLOAD_DIRECTORY"
echo ""
echo ""
echo "Finished!"
echo "Please restart the computer."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment