#!/bin/bash # Filename: ubuntu-base.sh # Perform basic config/tuning of OS and services a newly installed Ubuntu server. # Run this script only once! # # To run to run use one of the below commands: # wget -O - -q https://go.poorna.net/go/ubuntu-base.sh | bash # curl -s https://go.poorna.net/go/ubuntu-base.sh | bash # Check that we are running this as root if [ "$(id -u)" -ne 0 ]; then echo 'ERROR: This script must be run as root.' exit 1 fi # Ensure that we are running on an ubuntu host . /etc/os-release if [ "$ID" != "ubuntu" ]; then echo 'ERROR: This script is intended to run only on an Ubuntu host.' exit 1 fi set -eoux pipefail echo 'Install packages' apt update; apt -y full-upgrade; apt clean echo 'Setting journald config to limit disk usage' mkdir /etc/systemd/journald.conf.d cat > /etc/systemd/journald.conf.d/override.conf < /etc/apt/apt.conf.d/50unattended-upgrades < /etc/systemd/system/apt-daily.timer.d/override.conf <