Bash scripts I keep up my sleeve

Has it ever happened that from time to time when installing one or another distribution kit, you needed to install the same programs? It happened to me often. I do not support distribution hopping (jumping from distribution to distribution), but sometimes there are releases that you want to feel with your hands and not on a virtual machine. For this I have a separate laptop that I use as a “test” one.

Performing the next installation of utilities on Linux, I thought, is it possible to quickly automate this process? And so it appeared l-scripts

What’s the idea? Write a repository that contains all the necessary scripts for installing one or another software that is not in the standard repositories of a particular system (we will divide the systems into three branches: Debian (deb), Red Hat (rpm), Arch Linux). And also scripts for quickly setting up the system so as not to mess around with the same tweaks from time to time.

You can, of course, follow the path of least resistance, write one large script for each system, or using the condition and command test check which package manager is installed and install packages from the array, but then we may install what we do not need. I allocated a separate script for each program I needed, wrote a comment at the top of each with 3 lines:

# Author: Daniil Shilo (daniilshilo-developer) <>
# Description: Что делает
# Destination: Как делает

These scripts are fairly easy to understand and well documented. I have declared a function message in order to notify the user about which process is happening now:

Alerting the user about the installation steps
Alerting the user about the installation steps

Also the example of such a script itself:

#!/usr/bin/env bash
# Author: Daniil Shilo (daniilshilo-developer) <>
# Description: Installs Sublime Text
# Destination: This script will import GPG keys for Sublime Text and install it

# Function for output messages
function message() {
	if ! [[ $2 ]]; then
		# Green bold text
		echo -e '33[1;32m'$1'33[0m'
		# Green, red and blue text
		echo -e '33[1;32m'$1'33[1;31m >> 33[1;34m'$2'33[0m'

message 'Installing Sublime Text' 'Importing gpg keys'
sudo rpm -v --import

message 'Installing Sublime Text' 'Adding Sublime Text repo'
sudo dnf config-manager --add-repo

message 'Installing Sublime Text' 'Installing Sublime Text'
sudo dnf install -y sublime-text

I will maintain scripts so that they are up-to-date and users can easily install programs from third-party repositories. If the user does not trust security, then all scripts are open source, you can always check what a particular script does.

How does this make life easier?

I admit that every Linux user who can understand these scripts can do all the actions that are described in them himself, but let’s say that we have the following case: a person needs to install Docker on his machine, he will have to google the docker site, look in the documentation for how exactly to install it and what needs to be done for this. (As a reminder, it is no longer possible to install Docker from the standard repositories on Fedora and Ubuntu, source link)

Instead, a person can simply clone the repository, select the branch that matches the system, and run, who will figure out how to install Docker himself and will do it without pain.

#!/usr/bin/env bash
# Author: Daniil Shilo (daniilshilo-developer) <>
# Description: Installs Docker Engine on Fedora
# Destination: This script will add Docker repository to local list of repositories and install docker-ce, docker-ce-cli packages

# Function for output messages
function message() {
	# Green bold text
	echo -e '33[1;32m'$1'33[0m'

message 'Removing old Docker instances'
sudo dnf remove -y docker 

message 'Adding Docker repositories to local list'
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager 

message 'Installing Docker on the machine'
sudo dnf install -y docker-ce 

message 'Starting Docker services'
sudo systemctl enable --now docker

message 'Post-installation steps'
sudo groupadd docker # Adding new group
sudo usermod -aG docker $USER # Adding current user to the group
newgrp docker # Activate privileges

If you want to contribute or you have an interesting script that will help users in one way or another, then I will always be glad to see your pull requests

Also, if you are interested in the topics of web development and Linux, then I will be glad to see you in my dev-log (tg)

Similar Posts

Leave a Reply