#!/bin/sh

# colour for output
txtbld=$(tput bold)
txtund=${txtbld}$(tput sgr 0 1)
txtred=$(tput setaf 1)
txtyellow=$(tput setaf 3)
txtblue=$(tput setaf 4)
txtreset=$(tput sgr0)

# establish default package list exists
PKG_LIST=""
if [ -e "/var/rsm/rsm-pkglist" ]; then
	PKG_LIST="/var/rsm/rsm-pkglist"
else
        echo -e "${txtbld}${txtred}The package list(/usr/share/setup/pkglist) could not be found, please reinstall rsm-setup.${txtreset}\n" 1>&2
        echo -e "Aborting...\n" 
        exit 1
fi

PACMAN_CMD="pacman "
PACKAGES=$(cat $PKG_LIST)

echo "${txtbld}${txtblue}Downloading Packages...${txtreset}"
$PACMAN_CMD -Sy --noconfirm
$PACMAN_CMD -Sw --noconfirm $PACKAGES

echo "${txtbld}${txtblue}Installing Packages...${txtreset}"
$PACMAN_CMD -S --noconfirm $PACKAGES

echo "${txtbld}${txtblue}Cleaning Package Cache...${txtreset}"
$PACMAN_CMD -Scc --noconfirm

echo "${txtbld}${txtblue}Setting up default services...${txtreset}"
systemctl enable snmpd
systemctl restart snmpd



