#!/usr/bin/env bash

# omarchy:summary=Install the server extras: nmtui for the network and tufw for the firewall
# omarchy:requires-sudo=true

# Based: NetworkManager's TUI from apt and tufw's deb from its releases,
# Linux only; macOS has networksetup and its own firewall.

set -eo pipefail

source omarchy-require-linux

tufw_version=0.2.7

echo "Installing the server extras..."
omarchy-pkg-add network-manager ufw

if omarchy-cmd-missing tufw; then
  tmp=$(mktemp -d)
  trap 'rm -rf "$tmp"' EXIT
  curl -fL --progress-bar "https://github.com/peltho/tufw/releases/download/v$tufw_version/tufw_${tufw_version}_linux_$(dpkg --print-architecture).deb" -o "$tmp/tufw.deb"
  sudo apt-get install -y "$tmp/tufw.deb"
fi
