Ubuntu

by lblaboon
6 deployments · 5 still active · last rev. 8 days ago

Deploys an Ubuntu 18.04 server, optionally with Cockpit

Compatible with: Ubuntu 18.04 LTS
						#!/bin/bash

# <UDF name="cockpit" Label="Install Cockpit?" oneOf="Yes,No" default="Yes" />

# Set hostname
HOSTNAME=$(hostname)
FQDN=$(hostname -f)
IPV4=$(hostname -I | cut -d ' ' -f 1)
IPV6=$(hostname -I | cut -d ' ' -f 2)
hostnamectl set-hostname $HOSTNAME
echo "${IPV4} ${FQDN} ${HOSTNAME}" >> /etc/hosts
echo "${IPV6} ${FQDN} ${HOSTNAME}" >> /etc/hosts

# Update system
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get upgrade -y

# Install/configure UFW
apt-get install -y ufw
ufw default allow outgoing
ufw default deny incoming
ufw allow ssh
systemctl start ufw
systemctl enable ufw

if [[ $COCKPIT = "Yes" ]]; then
	# Install Cockpit
	apt-get install -y cockpit

	# Start Cockpit
	ufw allow 9090
	systemctl start cockpit.socket
	systemctl enable cockpit.socket
fi

# Cleanup
rm /root/StackScript
echo "Installation complete!"