Every time I provision a new instance, there is always a checklist of things to prepare first, like running apt-get update and so on. This is especially true if the server needs Docker. I used to rely on AI to generate the installation script for me, since setting up Docker properly involves handling certificates rather than just a simple install command.
To save time, I finally wrote a basic setup script. It doesn't include server hardening, I prefer doing that manually. At its core, the script simply installs Docker, tree, and a few other essential tools I need. If a project requires more complex configurations like web servers or advanced security setups, I’d rather use Ansible instead of a bash script. So, this tool is specifically designed for standalone VMs, not orchestrated environments.
How to Run It
Before you run anything, here is a preview and the source code of my script. It is always wiser to check the code before executing it on your machine.
https://raw.githubusercontent.com/ilhamlii21/script-tools/main/basic-setup.sh #!/usr/bin/env bash
set -euo pipefail
# --- Cek root ---
if [[ $EUID -ne 0 ]]; then
echo "Jalankan dengan sudo/root"; exit 1
fi
export DEBIAN_FRONTEND=noninteractive
echo "==> Update & upgrade sistem"
apt-get update -y
apt-get upgrade -y
echo "==> Install tools dasar"
apt-get install -y curl wget git vim htop net-tools unzip tree ca-certificates gnupg ufw
echo "==> Install Docker"
if ! command -v docker >/dev/null 2>&1; then
curl -fsSL https://get.docker.com | sh
else
echo "Docker sudah terpasang, dilewati"
fi
systemctl enable --now docker
# Tambahkan user yang menjalankan sudo ke grup docker
TARGET_USER="${SUDO_USER:-$USER}"
if [[ "$TARGET_USER" != "root" ]]; then
usermod -aG docker "$TARGET_USER"
echo "User $TARGET_USER ditambahkan ke grup docker (logout/login ulang)"
fi
echo "==> Selesai"
docker --version
docker compose version
tree --versionExecution Methods
- Go Curl
curl -fsSL https://raw.githubusercontent.com/ilhamlii21/script-tools/main/basic-setup.sh | sudo bashThis command will run the basic-setup.sh script directly using sudo, so make sure your current user has root access.
- Download first, then run
curl -fsSL https://raw.githubusercontent.com/ilhamlii21/script-tools/main/basic-setup.sh -o basic-setup.sh
less basic-setup.sh
sudo bash basic-setup.shThis method downloads the script to your local storage first, allowing you to review its contents using the less command before executing it with root privileges (sudo). This is a much safer approach to ensure there are no suspicious commands hidden in the code before running it on your server.
This installation takes up approximately 800MB
before
ilham@vm:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/root 29379712 1682988 27680340 6% /after
ilham@vm:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/root 29379712 2506104 26857224 9% /Conclusion
Ultimately, this script is really just here to make my own life easier, haha I’m sure everyone has their own preferences and workflows when it comes to server setups. If you have any suggestions or improvements, feel free to hit me up on Instagram, LinkedIn, email, or drop a comment in the field below.
Thank you!




No comments yet