#!/bin/bash
# Info: Script to install OS packages
# Author: JesusPerezLorenzo  
# Release: 1.0 
# Date: 30-10-2023
USAGE="install-os.sh "

[ "$1" == "-h"  ] && echo "$USAGE"  && exit 1

function _update_os {
    chmod 1777 /tmp
    echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections
    local codename=$(grep VERSION_CODENAME /etc/os-release | cut -f2 -d"=" ) 
    if [ "$codename"  == "bookworm" ] ; then 
      echo "APT::Get::Update::SourceListWarnings::NonFreeFirmware \"false\";" | sudo tee '/etc/apt/apt.conf.d/no-bookworm-firmware.conf'
    fi
    DEBIAN_FRONTEND=noninteractive sudo apt-get update
    DEBIAN_FRONTEND=noninteractive sudo apt-get upgrade -y
    DEBIAN_FRONTEND=noninteractive sudo apt-get -y -qq install sudo curl wget git jq dialog apt-utils gnupg \
      network-manager \
      nfs-common sysstat sshfs \
      netcat-traditional iputils-ping \
      apt-transport-https ca-certificates \
      software-properties-common
    DEBIAN_FRONTEND=noninteractive sudo apt autoremove -y
}

[ -r "./env-os"  ] && . ./env-os
# Update and add packages to installation
_update_os