From 6a8c2f8e539b8fc6da5e9eb97aa836c105ae62fe Mon Sep 17 00:00:00 2001 From: Christer Edwards Date: Sun, 2 Dec 2018 08:23:27 -0700 Subject: [PATCH] 0.3.20181202 template targets --- usr/local/bin/bastille | 2 +- usr/local/share/bastille/template.sh | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/usr/local/bin/bastille b/usr/local/bin/bastille index e73d70a7..0885254f 100755 --- a/usr/local/bin/bastille +++ b/usr/local/bin/bastille @@ -32,7 +32,7 @@ . /usr/local/etc/bastille/bastille.conf ## version -BASTILLE_VERSION="0.3.20181130" +BASTILLE_VERSION="0.3.20181202" usage() { cat << EOF diff --git a/usr/local/share/bastille/template.sh b/usr/local/share/bastille/template.sh index a98d792c..3bdc2f37 100644 --- a/usr/local/share/bastille/template.sh +++ b/usr/local/share/bastille/template.sh @@ -57,6 +57,7 @@ fi ## global variables TEMPLATE=$2 bastille_template=${bastille_templatesdir}/${TEMPLATE} +bastille_template_TARGET=${bastille_template}/TARGET bastille_template_INCLUDE=${bastille_template}/INCLUDE bastille_template_PRE=${bastille_template}/PRE bastille_template_CONFIG=${bastille_template}/CONFIG @@ -72,6 +73,20 @@ for _jail in ${JAILS}; do echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}" + ## TARGET + if [ -s "${bastille_template_TARGET}" ]; then + if [ $(grep -E "(^|\b)\!${_jail}($|\b)" ${bastille_template_TARGET}) ]; then + echo -e "${COLOR_GREEN}TARGET: !${_jail}.${COLOR_RESET}" + echo + continue + fi + if [ ! $(grep -E "(^|\b)(${_jail}|ALL)($|\b)" ${bastille_template_TARGET}) ]; then + echo -e "${COLOR_GREEN}TARGET: ?${_jail}.${COLOR_RESET}" + echo + continue + fi + fi + ## INCLUDE if [ -s "${bastille_template_INCLUDE}" ]; then echo -e "${COLOR_GREEN}Detected INCLUDE.${COLOR_RESET}" @@ -113,8 +128,8 @@ for _jail in ${JAILS}; do if [ -s "${bastille_template_PKG}" ]; then echo -e "${COLOR_GREEN}Installing packages.${COLOR_RESET}" jexec -l "${_jail}" env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg bootstrap - jexec -l "${_jail}" /usr/sbin/pkg audit -F - jexec -l "${_jail}" /usr/sbin/pkg install $(cat ${bastille_template_PKG}) + jexec -l "${_jail}" env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg audit -F + jexec -l "${_jail}" env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg install $(cat ${bastille_template_PKG}) fi ## sysrc