#!/bin/bash

set -e

SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
source $SCRIPT_DIR/parse-args "$@"

export DEBIAN_FRONTEND=noninteractive
apt update --yes

# if --full was passed, run full-upgrade
if [ "${FULL}" = "1" ]; then
    apt --yes full-upgrade
fi

# if ARGS is not empty, install the packages
if [ ${#ARGS[@]} -gt 0 ]; then
    apt install --yes --no-install-recommends "${ARGS[@]}"
fi

apt autoremove --yes
apt clean
rm -rf /var/lib/apt/lists/*