Automating Server Setup with Basic Bash Scripts
From Manual Commands to Repeatable Scripts
The first step towards automation is often the simplest: turning a series of manual commands into a reusable bash script. The ‘Ubuntu System Administration Guide’ emphasizes this as a foundational practice for ensuring consistency and saving time. Instead of typing the same commands over and over to set up a service, you can execute a single script.
Example: A Docker Installation Script
The book provides a practical example of a script named `install_docker.sh`. This script contains all the commands needed to update the system, add the Docker repository and its GPG key, and finally, install the Docker Engine. By making the script executable with `chmod +x install_docker.sh` and running it, you can perform a complete and correct Docker installation every single time, eliminating the risk of manual error. This script also serves as living documentation for your setup process.
This post is based from content of the book Ubuntu System adminstration guide. And the book can be found here https://www.amazon.com/stores/Mattias-Hemmingsson/author/B0FF5CQX13