Added bootstrap checksum validation and minor fixes

This commit is contained in:
Jose
2019-11-02 16:05:49 -04:00
parent 973c2bc7b2
commit ae2b0ea0cb
3 changed files with 38 additions and 14 deletions

View File

@@ -262,18 +262,32 @@ bootstrap_release() {
echo -e "${COLOR_GREEN}Extracting FreeBSD ${RELEASE} ${_archive}.txz.${COLOR_RESET}" echo -e "${COLOR_GREEN}Extracting FreeBSD ${RELEASE} ${_archive}.txz.${COLOR_RESET}"
/usr/bin/tar -C "${bastille_releasesdir}/${RELEASE}" -xf "${bastille_cachedir}/${RELEASE}/${_archive}.txz" /usr/bin/tar -C "${bastille_releasesdir}/${RELEASE}" -xf "${bastille_cachedir}/${RELEASE}/${_archive}.txz"
else else
for _archive in ${bastille_bootstrap_archives}; do ## get the manifest for dist files checksum validation
if [ ! -f "${bastille_cachedir}/${RELEASE}/MANIFEST" ]; then
fetch ${UPSTREAM_URL}/MANIFEST -o ${bastille_cachedir}/${RELEASE}/MANIFEST
fi
## fetch for missing dist files ## fetch for missing dist files
if [ ! -f "${bastille_cachedir}/${RELEASE}/${_archive}.txz" ]; then if [ ! -f "${bastille_cachedir}/${RELEASE}/${_archive}.txz" ]; then
fetch ${UPSTREAM_URL}/${_archive}.txz -o ${bastille_cachedir}/${RELEASE}/${_archive}.txz fetch ${UPSTREAM_URL}/${_archive}.txz -o ${bastille_cachedir}/${RELEASE}/${_archive}.txz
fi fi
## compare checksums on the fetched dist files
if [ -f "${bastille_cachedir}/${RELEASE}/${_archive}.txz" ]; then
SHA256_DIST=$(grep -w "${_archive}.txz" ${bastille_cachedir}/${RELEASE}/MANIFEST | awk '{print $2}')
SHA256_FILE=$(sha256 -q ${bastille_cachedir}/${RELEASE}/${_archive}.txz)
if [ "${SHA256_FILE}" != "${SHA256_DIST}" ]; then
echo -e "${COLOR_RED}Failed validation for ${_archive}.txz, please retry bootstrap!${COLOR_RESET}"
rm ${bastille_cachedir}/${RELEASE}/${_archive}.txz
exit 1
fi
fi
## extract the fetched dist files ## extract the fetched dist files
if [ -f "${bastille_cachedir}/${RELEASE}/${_archive}.txz" ]; then if [ -f "${bastille_cachedir}/${RELEASE}/${_archive}.txz" ]; then
echo -e "${COLOR_GREEN}Extracting FreeBSD ${RELEASE} ${_archive}.txz.${COLOR_RESET}" echo -e "${COLOR_GREEN}Extracting FreeBSD ${RELEASE} ${_archive}.txz.${COLOR_RESET}"
/usr/bin/tar -C "${bastille_releasesdir}/${RELEASE}" -xf "${bastille_cachedir}/${RELEASE}/${_archive}.txz" /usr/bin/tar -C "${bastille_releasesdir}/${RELEASE}" -xf "${bastille_cachedir}/${RELEASE}/${_archive}.txz"
fi fi
done
fi fi
done done
echo echo

View File

@@ -79,6 +79,11 @@ destroy_jail() {
destroy_rel() { destroy_rel() {
bastille_rel_base="${bastille_releasesdir}/${NAME}" ## dir bastille_rel_base="${bastille_releasesdir}/${NAME}" ## dir
## check if this release have containers child
if grep -qwo "${NAME}" ${bastille_jailsdir}/*/fstab 2>/dev/null; then
echo -e "${COLOR_RED} ${NAME} base appears to have containers child.${COLOR_RESET}"
exit 1
fi
if [ ! -d "${bastille_rel_base}" ]; then if [ ! -d "${bastille_rel_base}" ]; then
echo -e "${COLOR_RED}Release base not found.${COLOR_RESET}" echo -e "${COLOR_RED}Release base not found.${COLOR_RESET}"

View File

@@ -47,23 +47,28 @@ if [ $# -gt 0 ]; then
usage usage
;; ;;
release|releases) release|releases)
REL_LIST=$(ls "${bastille_releasesdir}" | sed "s/\n//g") if [ -d "${bastille_releasesdir}" ]; then
for _REL in ${REL_LIST}; do REL_LIST=$(ls "${bastille_releasesdir}" | sed "s/\n//g")
if [ -f "${bastille_releasesdir}/${_REL}/root/.profile" ]; then for _REL in ${REL_LIST}; do
echo "${bastille_releasesdir}/${_REL}" if [ -f "${bastille_releasesdir}/${_REL}/root/.profile" ]; then
fi #echo "${bastille_releasesdir}/${_REL}"
done echo "${_REL}"
fi
done
fi
;; ;;
template|templates) template|templates)
find "${bastille_templatesdir}" -type d -maxdepth 2 find "${bastille_templatesdir}" -type d -maxdepth 2
;; ;;
jail|jails) jail|jails)
JAIL_LIST=$(ls "${bastille_jailsdir}" | sed "s/\n//g") if [ -d "${bastille_jailsdir}" ]; then
for _JAIL in ${JAIL_LIST}; do JAIL_LIST=$(ls "${bastille_jailsdir}" | sed "s/\n//g")
if [ -f "${bastille_jailsdir}/${_JAIL}/jail.conf" ]; then for _JAIL in ${JAIL_LIST}; do
echo "${_JAIL}" if [ -f "${bastille_jailsdir}/${_JAIL}/jail.conf" ]; then
fi echo "${_JAIL}"
done fi
done
fi
;; ;;
log|logs) log|logs)
find "${bastille_logsdir}" -type f -maxdepth 1 find "${bastille_logsdir}" -type f -maxdepth 1