mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-23 02:33:35 +01:00
update for 0.5.20191125
This commit is contained in:
30
AUTHORS.md
Normal file
30
AUTHORS.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# AUTHORS
|
||||||
|
|
||||||
|
## Lead
|
||||||
|
|
||||||
|
Christer Edwards [christer.edwards@gmail.com]
|
||||||
|
|
||||||
|
## Contributors
|
||||||
|
|
||||||
|
Barry McCormick
|
||||||
|
Jose Rivera
|
||||||
|
Giacomo Olgeni
|
||||||
|
Jan-Piet Mens
|
||||||
|
|
||||||
|
### Special thanks
|
||||||
|
Software doesn't happen in a vacuum. Thank you to the following people who may
|
||||||
|
not be found in the commit history.
|
||||||
|
|
||||||
|
Barry McCormick
|
||||||
|
Carlos Meza
|
||||||
|
Casandra Woodcox
|
||||||
|
Clint Savage
|
||||||
|
G. Clifford Williams
|
||||||
|
Jack Thomasson
|
||||||
|
Jun C Park
|
||||||
|
Justin Desilets
|
||||||
|
Larry Raab
|
||||||
|
Nate Taylor
|
||||||
|
Ryan Simpkins
|
||||||
|
Tim Gelter
|
||||||
|
Trevor Sharpe
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
. /usr/local/etc/bastille/bastille.conf
|
. /usr/local/etc/bastille/bastille.conf
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo -e "${COLOR_RED}Usage: bastille bootstrap [release|template].${COLOR_RESET}"
|
echo -e "${COLOR_RED}Usage: bastille bootstrap [release|template] [update].${COLOR_RESET}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,6 +337,18 @@ bootstrap_release() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bootstrap_template() {
|
bootstrap_template() {
|
||||||
|
|
||||||
|
## ${bastille_templatesdir}
|
||||||
|
if [ ! -d "${bastille_templatesdir}" ]; then
|
||||||
|
if [ "${bastille_zfs_enable}" = "YES" ]; then
|
||||||
|
if [ ! -z "${bastille_zfs_zpool}" ]; then
|
||||||
|
zfs create ${bastille_zfs_options} -o mountpoint=${bastille_templatesdir} ${bastille_zfs_zpool}/${bastille_zfs_prefix}/templates
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
mkdir -p "${bastille_templatesdir}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
## define basic variables
|
## define basic variables
|
||||||
_url=${BASTILLE_TEMPLATE_URL}
|
_url=${BASTILLE_TEMPLATE_URL}
|
||||||
_user=${BASTILLE_TEMPLATE_USER}
|
_user=${BASTILLE_TEMPLATE_USER}
|
||||||
@@ -382,7 +394,9 @@ bootstrap_template() {
|
|||||||
echo -e "${COLOR_GREEN}Detected OVERLAY hook.${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}Detected OVERLAY hook.${COLOR_RESET}"
|
||||||
while read _dir; do
|
while read _dir; do
|
||||||
echo -e "${COLOR_GREEN}[${_dir}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_dir}]:${COLOR_RESET}"
|
||||||
tree -a ${_template}/${_dir}
|
if [ -x $(which tree) ]; then
|
||||||
|
tree -a ${_template}/${_dir}
|
||||||
|
fi
|
||||||
done < ${_template}/OVERLAY
|
done < ${_template}/OVERLAY
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
@@ -391,7 +405,9 @@ bootstrap_template() {
|
|||||||
echo -e "${COLOR_YELLOW}CONFIG deprecated; rename to OVERLAY.${COLOR_RESET}"
|
echo -e "${COLOR_YELLOW}CONFIG deprecated; rename to OVERLAY.${COLOR_RESET}"
|
||||||
while read _dir; do
|
while read _dir; do
|
||||||
echo -e "${COLOR_GREEN}[${_dir}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_dir}]:${COLOR_RESET}"
|
||||||
tree -a ${_template}/${_dir}
|
if [ -x $(which tree) ]; then
|
||||||
|
tree -a ${_template}/${_dir}
|
||||||
|
fi
|
||||||
done < ${_template}/CONFIG
|
done < ${_template}/CONFIG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -446,7 +462,6 @@ http?://github.com/*/*|http?://gitlab.com/*/*)
|
|||||||
BASTILLE_TEMPLATE_REPO=$(echo "${1}" | awk -F / '{ print $5 }')
|
BASTILLE_TEMPLATE_REPO=$(echo "${1}" | awk -F / '{ print $5 }')
|
||||||
echo -e "${COLOR_GREEN}Template: ${1}${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}Template: ${1}${COLOR_RESET}"
|
||||||
echo
|
echo
|
||||||
bootstrap_directories
|
|
||||||
bootstrap_template
|
bootstrap_template
|
||||||
;;
|
;;
|
||||||
network)
|
network)
|
||||||
|
|||||||
@@ -42,19 +42,22 @@ help|-h|--help)
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ $# -gt 2 ] || [ $# -lt 2 ]; then
|
if [ $# -lt 2 ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = 'ALL' ]; then
|
TARGET="${1}"
|
||||||
|
shift
|
||||||
|
|
||||||
|
if [ "$TARGET" = 'ALL' ]; then
|
||||||
JAILS=$(jls name)
|
JAILS=$(jls name)
|
||||||
fi
|
fi
|
||||||
if [ "$1" != 'ALL' ]; then
|
if [ "$TARGET" != 'ALL' ]; then
|
||||||
JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)")
|
JAILS=$(jls name | grep -w "${1}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
jexec -l ${_jail} $2
|
jexec -l ${_jail} $@
|
||||||
echo
|
echo
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -42,18 +42,25 @@ help|-h|--help)
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ $# -gt 1 ] || [ $# -lt 1 ]; then
|
if [ $# -gt 2 ] || [ $# -lt 1 ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
if [ "$1" = 'ALL' ]; then
|
|
||||||
|
TARGET="${1}"
|
||||||
|
|
||||||
|
if [ "$TARGET" = 'ALL' ]; then
|
||||||
JAILS=$(jls name)
|
JAILS=$(jls name)
|
||||||
fi
|
fi
|
||||||
if [ "$1" != 'ALL' ]; then
|
if [ "$TARGET" != 'ALL' ]; then
|
||||||
JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)")
|
JAILS=$(jls name | grep -w "${1}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
jexec -l ${_jail} /usr/bin/login -f root
|
if [ ! -z "${2}" ]; then
|
||||||
|
jexec -l ${_jail} /usr/bin/login -f "${2}"
|
||||||
|
else
|
||||||
|
jexec -l ${_jail} /usr/bin/login -f root
|
||||||
|
fi
|
||||||
echo
|
echo
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
. /usr/local/etc/bastille/bastille.conf
|
. /usr/local/etc/bastille/bastille.conf
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo -e "${COLOR_RED}Usage: bastille cp [ALL|glob] '/path/to/source' 'path/to/dest'.${COLOR_RESET}"
|
echo -e "${COLOR_RED}Usage: bastille cp [ALL|glob] /path/to/source path/to/dest.${COLOR_RESET}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,16 +47,20 @@ if [ $# -gt 3 ] || [ $# -lt 3 ]; then
|
|||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = 'ALL' ]; then
|
TARGET="${1}"
|
||||||
|
CPSOURCE="${2}"
|
||||||
|
CPDEST="${3}"
|
||||||
|
|
||||||
|
if [ "$TARGET" = 'ALL' ]; then
|
||||||
JAILS=$(jls name)
|
JAILS=$(jls name)
|
||||||
fi
|
fi
|
||||||
if [ "$1" != 'ALL' ]; then
|
if [ "$TARGET" != 'ALL' ]; then
|
||||||
JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)")
|
JAILS=$(jls name | grep -w "${1}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
bastille_jail_path="$(jls -j "${_jail}" path)"
|
bastille_jail_path="$(jls -j "${_jail}" path)"
|
||||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
cp -av "$2" "${bastille_jail_path}/$3"
|
cp -av "${CPSOURCE}" "${bastille_jail_path}/${CPDEST}"
|
||||||
echo
|
echo
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ usage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
running_jail() {
|
running_jail() {
|
||||||
jls name | grep -E "(^|\b)${NAME}($|\b)"
|
jls name | grep -w "${NAME}"
|
||||||
}
|
}
|
||||||
|
|
||||||
validate_ip() {
|
validate_ip() {
|
||||||
|
|||||||
@@ -47,11 +47,13 @@ if [ $# -gt 1 ] || [ $# -lt 1 ]; then
|
|||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = 'ALL' ]; then
|
TARGET="${1}"
|
||||||
|
|
||||||
|
if [ "$TARGET" = 'ALL' ]; then
|
||||||
JAILS=$(jls name)
|
JAILS=$(jls name)
|
||||||
fi
|
fi
|
||||||
if [ "$1" != 'ALL' ]; then
|
if [ "$TARGET" != 'ALL' ]; then
|
||||||
JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)")
|
JAILS=$(jls name | grep -w "${1}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
|
|||||||
@@ -42,19 +42,22 @@ help|-h|--help)
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ $# -gt 2 ] || [ $# -lt 2 ]; then
|
if [ $# -lt 2 ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = 'ALL' ]; then
|
TARGET="${1}"
|
||||||
|
shift
|
||||||
|
|
||||||
|
if [ "${TARGET}" = 'ALL' ]; then
|
||||||
JAILS=$(jls name)
|
JAILS=$(jls name)
|
||||||
fi
|
fi
|
||||||
if [ "$1" != 'ALL' ]; then
|
if [ "${TARGET}" != 'ALL' ]; then
|
||||||
JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)")
|
JAILS=$(jls name | grep -w "${TARGET}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
jexec -l ${_jail} /usr/sbin/pkg $2
|
jexec -l ${_jail} /usr/sbin/pkg $@
|
||||||
echo
|
echo
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -42,20 +42,23 @@ help|-h|--help)
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ $# -gt 2 ] || [ $# -lt 2 ]; then
|
if [ $# -lt 2 ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = 'ALL' ]; then
|
TARGET=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
if [ "$TARGET" = 'ALL' ]; then
|
||||||
JAILS=$(jls name)
|
JAILS=$(jls name)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" != 'ALL' ]; then
|
if [ "$TARGET" != 'ALL' ]; then
|
||||||
JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)")
|
JAILS=$(jls name | grep -w "${1}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
jexec -l ${_jail} /usr/sbin/service $2
|
jexec -l ${_jail} /usr/sbin/service $@
|
||||||
echo
|
echo
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -47,19 +47,26 @@ if [ $# -gt 1 ] || [ $# -lt 1 ]; then
|
|||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = 'ALL' ]; then
|
TARGET="${1}"
|
||||||
JAILS=$(/usr/local/bin/bastille list jails)
|
|
||||||
|
if [ "$TARGET" = 'ALL' ]; then
|
||||||
|
JAILS=$(bastille list jails)
|
||||||
fi
|
fi
|
||||||
if [ "$1" != 'ALL' ]; then
|
if [ "$TARGET" != 'ALL' ]; then
|
||||||
JAILS=$(/usr/local/bin/bastille list jails | grep -w "$1")
|
JAILS=$(bastille list jails | grep -w "$TARGET")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
if [ $(jls name | grep ${_jail}) ]; then
|
## test if running
|
||||||
|
if [ $(jls name | grep -w ${_jail}) ]; then
|
||||||
echo -e "${COLOR_RED}[${_jail}]: Already started.${COLOR_RESET}"
|
echo -e "${COLOR_RED}[${_jail}]: Already started.${COLOR_RESET}"
|
||||||
elif [ ! $(jls name | grep ${_jail}) ]; then
|
|
||||||
|
## test if not running
|
||||||
|
elif [ ! $(jls name | grep -w ${_jail}) ]; then
|
||||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
jail -f "${bastille_jailsdir}/${_jail}/jail.conf" -c ${_jail}
|
jail -f "${bastille_jailsdir}/${_jail}/jail.conf" -c ${_jail}
|
||||||
|
|
||||||
|
## update ${bastille_jail_loopback}:network with added/removed addresses
|
||||||
if [ ! -z ${bastille_jail_loopback} ]; then
|
if [ ! -z ${bastille_jail_loopback} ]; then
|
||||||
pfctl -f /etc/pf.conf
|
pfctl -f /etc/pf.conf
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -47,18 +47,29 @@ if [ $# -gt 1 ] || [ $# -lt 1 ]; then
|
|||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = 'ALL' ]; then
|
TARGET="${1}"
|
||||||
|
|
||||||
|
if [ "${TARGET}" = 'ALL' ]; then
|
||||||
JAILS=$(jls name)
|
JAILS=$(jls name)
|
||||||
fi
|
fi
|
||||||
if [ "$1" != 'ALL' ]; then
|
if [ "${TARGET}" != 'ALL' ]; then
|
||||||
JAILS=$(jls name | grep -w "$1")
|
JAILS=$(jls name | grep -w "${TARGET}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
## test if not running
|
||||||
jail -f "${bastille_jailsdir}/${_jail}/jail.conf" -r ${_jail}
|
if [ ! $(jls name | grep -w "${_jail}") ]; then
|
||||||
if [ ! -z ${bastille_jail_loopback} ]; then
|
echo -e "${COLOR_RED}[${_jail}]: Not started.${COLOR_RESET}"
|
||||||
pfctl -f /etc/pf.conf
|
|
||||||
|
## test if running
|
||||||
|
elif [ $(jls name | grep -w "${_jail}") ]; then
|
||||||
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
|
jail -f "${bastille_jailsdir}/${_jail}/jail.conf" -r ${_jail}
|
||||||
|
|
||||||
|
## update ${bastille_jail_loopback}:network with added/removed addresses
|
||||||
|
if [ ! -z ${bastille_jail_loopback} ]; then
|
||||||
|
pfctl -f /etc/pf.conf
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -42,20 +42,23 @@ help|-h|--help)
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ $# -gt 2 ] || [ $# -lt 2 ]; then
|
if [ $# -lt 2 ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = 'ALL' ]; then
|
TARGET="${1}"
|
||||||
|
shift
|
||||||
|
|
||||||
|
if [ "$TARGET" = 'ALL' ]; then
|
||||||
JAILS=$(jls name)
|
JAILS=$(jls name)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" != 'ALL' ]; then
|
if [ "$TARGET" != 'ALL' ]; then
|
||||||
JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)")
|
JAILS=$(jls name | grep -w "${1}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
jexec -l ${_jail} /usr/sbin/sysrc $2
|
jexec -l ${_jail} /usr/sbin/sysrc $@
|
||||||
echo -e "${COLOR_RESET}"
|
echo -e "${COLOR_RESET}"
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
. /usr/local/etc/bastille/bastille.conf
|
. /usr/local/etc/bastille/bastille.conf
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo -e "${COLOR_RED}Usage: bastille template [ALL|glob] template.${COLOR_RESET}"
|
echo -e "${COLOR_RED}Usage: bastille template TARGET template/path.${COLOR_RESET}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,15 +47,23 @@ if [ $# -gt 2 ] || [ $# -lt 2 ]; then
|
|||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = 'ALL' ]; then
|
TARGET="${1}"
|
||||||
|
|
||||||
|
if [ "${TARGET}" = 'ALL' ]; then
|
||||||
JAILS=$(jls name)
|
JAILS=$(jls name)
|
||||||
fi
|
fi
|
||||||
if [ "$1" != 'ALL' ]; then
|
if [ "${TARGET}" != 'ALL' ]; then
|
||||||
JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)")
|
JAILS=$(jls name | grep -w "${TARGET}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
TEMPLATE="${2}"
|
||||||
|
|
||||||
|
if [ ! -d "${bastille_templatesdir}"/"${TEMPLATE}" ]; then
|
||||||
|
echo -e "${COLOR_RED}${TEMPLATE} not found.${COLOR_RESET}"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## global variables
|
## global variables
|
||||||
TEMPLATE=$2
|
|
||||||
bastille_template=${bastille_templatesdir}/${TEMPLATE}
|
bastille_template=${bastille_templatesdir}/${TEMPLATE}
|
||||||
bastille_template_TARGET=${bastille_template}/TARGET
|
bastille_template_TARGET=${bastille_template}/TARGET
|
||||||
bastille_template_INCLUDE=${bastille_template}/INCLUDE
|
bastille_template_INCLUDE=${bastille_template}/INCLUDE
|
||||||
@@ -76,7 +84,7 @@ for _jail in ${JAILS}; do
|
|||||||
|
|
||||||
## TARGET
|
## TARGET
|
||||||
if [ -s "${bastille_template_TARGET}" ]; then
|
if [ -s "${bastille_template_TARGET}" ]; then
|
||||||
if [ $(grep -E "(^|\b)\!${_jail}($|\b)" ${bastille_template_TARGET}) ]; then
|
if [ $(grep -w "${_jail}" ${bastille_template_TARGET}) ]; then
|
||||||
echo -e "${COLOR_GREEN}TARGET: !${_jail}.${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}TARGET: !${_jail}.${COLOR_RESET}"
|
||||||
echo
|
echo
|
||||||
continue
|
continue
|
||||||
@@ -90,7 +98,7 @@ for _jail in ${JAILS}; do
|
|||||||
|
|
||||||
## INCLUDE
|
## INCLUDE
|
||||||
if [ -s "${bastille_template_INCLUDE}" ]; then
|
if [ -s "${bastille_template_INCLUDE}" ]; then
|
||||||
echo -e "${COLOR_GREEN}Detected INCLUDE.${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:INCLUDE -- START${COLOR_RESET}"
|
||||||
while read _include; do
|
while read _include; do
|
||||||
echo
|
echo
|
||||||
echo -e "${COLOR_GREEN}INCLUDE: ${_include}${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}INCLUDE: ${_include}${COLOR_RESET}"
|
||||||
@@ -103,29 +111,35 @@ for _jail in ${JAILS}; do
|
|||||||
BASTILLE_TEMPLATE_REPO=$(echo "${_include}" | awk -F / '{ print $5}')
|
BASTILLE_TEMPLATE_REPO=$(echo "${_include}" | awk -F / '{ print $5}')
|
||||||
bastille template ${_jail} ${BASTILLE_TEMPLATE_PROJECT}/${BASTILLE_TEMPLATE_REPO}
|
bastille template ${_jail} ${BASTILLE_TEMPLATE_PROJECT}/${BASTILLE_TEMPLATE_REPO}
|
||||||
done < "${bastille_template_INCLUDE}"
|
done < "${bastille_template_INCLUDE}"
|
||||||
|
echo -e "${COLOR_GREEN}[${_jail}]:INCLUDE -- END${COLOR_RESET}"
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## PRE
|
## PRE
|
||||||
if [ -s "${bastille_template_PRE}" ]; then
|
if [ -s "${bastille_template_PRE}" ]; then
|
||||||
echo -e "${COLOR_GREEN}Executing PRE-command(s).${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:PRE -- START${COLOR_RESET}"
|
||||||
jexec -l ${_jail} /bin/sh < "${bastille_template_PRE}" || exit 1
|
jexec -l ${_jail} /bin/sh < "${bastille_template_PRE}" || exit 1
|
||||||
|
echo -e "${COLOR_GREEN}[${_jail}]:PRE -- END${COLOR_RESET}"
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## CONFIG / OVERLAY
|
## CONFIG / OVERLAY
|
||||||
if [ -s "${bastille_template_OVERLAY}" ]; then
|
if [ -s "${bastille_template_OVERLAY}" ]; then
|
||||||
echo -e "${COLOR_GREEN}Copying files...${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:OVERLAY -- START${COLOR_RESET}"
|
||||||
while read _dir; do
|
while read _dir; do
|
||||||
cp -a "${bastille_template}/${_dir}" "${bastille_jail_path}" || exit 1
|
cp -av "${bastille_template}/${_dir}" "${bastille_jail_path}" || exit 1
|
||||||
done < ${bastille_template_OVERLAY}
|
done < ${bastille_template_OVERLAY}
|
||||||
echo -e "${COLOR_GREEN}Copy complete.${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:OVERLAY -- END${COLOR_RESET}"
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
if [ -s "${bastille_template}/CONFIG" ]; then
|
if [ -s "${bastille_template}/CONFIG" ]; then
|
||||||
echo -e "${COLOR_YELLOW}CONFIG deprecated; rename to OVERLAY.${COLOR_RESET}"
|
echo -e "${COLOR_YELLOW}CONFIG deprecated; rename to OVERLAY.${COLOR_RESET}"
|
||||||
echo -e "${COLOR_GREEN}Copying files...${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:CONFIG -- START${COLOR_RESET}"
|
||||||
while read _dir; do
|
while read _dir; do
|
||||||
cp -a "${bastille_template}/${_dir}" "${bastille_jail_path}" || exit 1
|
cp -av "${bastille_template}/${_dir}" "${bastille_jail_path}" || exit 1
|
||||||
done < ${bastille_template}/CONFIG
|
done < ${bastille_template}/CONFIG
|
||||||
echo -e "${COLOR_GREEN}Copy complete.${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:CONFIG -- END${COLOR_RESET}"
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## FSTAB
|
## FSTAB
|
||||||
@@ -144,33 +158,42 @@ for _jail in ${JAILS}; do
|
|||||||
|
|
||||||
## PKG (bootstrap + pkg)
|
## PKG (bootstrap + pkg)
|
||||||
if [ -s "${bastille_template_PKG}" ]; then
|
if [ -s "${bastille_template_PKG}" ]; then
|
||||||
echo -e "${COLOR_GREEN}Installing packages.${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:PKG -- START${COLOR_RESET}"
|
||||||
jexec -l "${_jail}" env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg bootstrap || exit 1
|
jexec -l "${_jail}" env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg bootstrap || exit 1
|
||||||
jexec -l "${_jail}" env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg audit -F || exit 1
|
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}) || exit 1
|
jexec -l "${_jail}" env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg install $(cat ${bastille_template_PKG}) || exit 1
|
||||||
|
echo -e "${COLOR_GREEN}[${_jail}]:PKG -- END${COLOR_RESET}"
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## SYSRC
|
## SYSRC
|
||||||
if [ -s "${bastille_template_SYSRC}" ]; then
|
if [ -s "${bastille_template_SYSRC}" ]; then
|
||||||
echo -e "${COLOR_GREEN}Updating services.${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:SYSRC -- START${COLOR_RESET}"
|
||||||
while read _sysrc; do
|
while read _sysrc; do
|
||||||
jexec -l ${_jail} /usr/sbin/sysrc "${_sysrc}" || exit 1
|
jexec -l ${_jail} /usr/sbin/sysrc "${_sysrc}" || exit 1
|
||||||
done < "${bastille_template_SYSRC}"
|
done < "${bastille_template_SYSRC}"
|
||||||
|
echo -e "${COLOR_GREEN}[${_jail}]:SYSRC -- END${COLOR_RESET}"
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## SERVICE
|
## SERVICE
|
||||||
if [ -s "${bastille_template_SERVICE}" ]; then
|
if [ -s "${bastille_template_SERVICE}" ]; then
|
||||||
echo -e "${COLOR_GREEN}Managing services.${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:SERVICE -- START${COLOR_RESET}"
|
||||||
while read _service; do
|
while read _service; do
|
||||||
jexec -l ${_jail} /usr/sbin/service ${_service} || exit 1
|
jexec -l ${_jail} /usr/sbin/service ${_service} || exit 1
|
||||||
done < "${bastille_template_SERVICE}"
|
done < "${bastille_template_SERVICE}"
|
||||||
|
echo -e "${COLOR_GREEN}[${_jail}]:SERVICE -- END${COLOR_RESET}"
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## CMD
|
## CMD
|
||||||
if [ -s "${bastille_template_CMD}" ]; then
|
if [ -s "${bastille_template_CMD}" ]; then
|
||||||
echo -e "${COLOR_GREEN}Executing final command(s).${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:CMD -- START${COLOR_RESET}"
|
||||||
jexec -l ${_jail} /bin/sh < "${bastille_template_CMD}" || exit 1
|
jexec -l ${_jail} /bin/sh < "${bastille_template_CMD}" || exit 1
|
||||||
|
echo -e "${COLOR_GREEN}[${_jail}]:CMD -- END${COLOR_RESET}"
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${COLOR_GREEN}Template Complete.${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}Template Complete.${COLOR_RESET}"
|
||||||
echo
|
echo
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -46,12 +46,14 @@ if [ $# -gt 1 ] || [ $# -lt 1 ]; then
|
|||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = 'ALL' ]; then
|
TARGET="${1}"
|
||||||
|
|
||||||
|
if [ "$TARGET" = 'ALL' ]; then
|
||||||
JAILS=$(jls name)
|
JAILS=$(jls name)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" != 'ALL' ]; then
|
if [ "$TARGET" != 'ALL' ]; then
|
||||||
JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)")
|
JAILS=$(jls name | grep -w "${1}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
|
|||||||
@@ -87,16 +87,18 @@ if [ -z "${bastille_zfs_zpool}" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $# -gt 3 ] || [ $# -lt 2 ]; then
|
if [ $# -lt 2 ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = 'ALL' ]; then
|
TARGET="${1}"
|
||||||
|
|
||||||
|
if [ "$TARGET" = 'ALL' ]; then
|
||||||
JAILS=$(jls name)
|
JAILS=$(jls name)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" != 'ALL' ]; then
|
if [ "$TARGET" != 'ALL' ]; then
|
||||||
JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)")
|
JAILS=$(jls name | grep -w "${1}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$2" in
|
case "$2" in
|
||||||
|
|||||||
Reference in New Issue
Block a user