Merge pull request #959 from BastilleBSD/tschettervictor-patch-1

This commit is contained in:
tschettervictor
2025-04-21 18:17:27 -06:00
committed by GitHub
4 changed files with 29 additions and 13 deletions

View File

@@ -76,11 +76,10 @@ CMD - run the specified command
CONFIG - set the specified property and value
CP/OVERLAY - copy specified files from template directory to specified path
inside jail
CP/OVERLAY - copy specified files from template directory to specified path inside jail
INCLUDE - specify a template to include. Make sure the template is
bootstrapped, or you are using the template url
bootstrapped, or you are using the template url
LIMITS - set the specified resource value for the jail
@@ -93,8 +92,7 @@ PKG - install specified packages inside jail
RDR - redirect specified ports to the jail
RENDER - replace ARG values inside specified files inside the jail. If a
directory is specified, ARGS will be replaced in all files
underneath
directory is specified, ARGS will be replaced in all files underneath
RESTART - restart the jail

View File

@@ -405,23 +405,41 @@ bootstrap_template() {
_url=${BASTILLE_TEMPLATE_URL}
_user=${BASTILLE_TEMPLATE_USER}
_repo=${BASTILLE_TEMPLATE_REPO%.*} # Remove the trailing ".git"
_template=${bastille_templatesdir}/${_user}/${_repo}
_raw_template_dir=${bastille_templatesdir}/${_user}/${_repo}
## support for non-git
if ! which -s git; then
error_notify "Git not found."
error_exit "Not yet implemented."
else
if [ ! -d "${_template}/.git" ]; then
git clone "${_url}" "${_template}" ||\
if [ ! -d "${_raw_template_dir}/.git" ]; then
git clone "${_url}" "${_raw_template_dir}" ||\
error_notify "Clone unsuccessful."
elif [ -d "${_template}/.git" ]; then
git -C "${_template}" pull ||\
elif [ -d "${_raw_template_dir}/.git" ]; then
git -C "${_raw_template_dir}" pull ||\
error_notify "Template update unsuccessful."
fi
fi
bastille verify "${_user}/${_repo}"
if [ ! -f ${_raw_template_dir}/Bastillefile ]; then
# Extract template in project/template format
find "${_raw_template_dir}" -type f -name Bastillefile | while read -r _file; do
_project="$(dirname "$(dirname ${_file})")"
_template="$(basename ${_project})"
_complete_template="$(basename ${_project})"/"$(basename "$(dirname ${_file})")"
cp -fR "${_project}" "${bastille_templatesdir}/${_template}"
bastille verify "${_complete_template}"
done
# Remove the cloned repo
if [ -n "${_user}" ]; then
rm -r "${bastille_templatesdir:?}/${_user:?}"
fi
else
# Verify a single template
bastille verify "${_user}/${_repo}"
fi
}
# Handle options.

View File

@@ -204,7 +204,7 @@ list_release(){
}
list_template(){
find "${bastille_templatesdir}" -type d -maxdepth 2
find "${bastille_templatesdir}" -type d -maxdepth 2 | sed 's#${bastille_templatesdir}/##g'
}
list_jail(){

View File

@@ -143,7 +143,7 @@ verify_template() {
if [ "${_hook_validate}" -lt 1 ]; then
error_notify "No valid template hooks found."
error_notify "Template discarded."
rm -rf "${bastille_template}"
rm -rf "${_template_path}"
exit 1
fi