From be6a0e1b5f5b5b7fa6bd56d2412246f5a40dfbd3 Mon Sep 17 00:00:00 2001 From: Christer Edwards Date: Mon, 24 Feb 2020 19:27:51 -0700 Subject: [PATCH] quiet login message on container login --- usr/local/share/bastille/bootstrap.sh | 65 +++++++++++++++------------ 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/usr/local/share/bastille/bootstrap.sh b/usr/local/share/bastille/bootstrap.sh index c96acc9e..e59d3172 100644 --- a/usr/local/share/bastille/bootstrap.sh +++ b/usr/local/share/bastille/bootstrap.sh @@ -265,6 +265,7 @@ bootstrap_directories() { else mkdir -p "${bastille_releasesdir}/${RELEASE}" fi + ## create subsequent releases/XX.X-RELEASE datasets elif [ ! -d "${bastille_releasesdir}/${RELEASE}" ]; then if [ "${bastille_zfs_enable}" = "YES" ]; then @@ -301,42 +302,45 @@ bootstrap_release() { FETCH_VALIDATION="0" if [ -f "${bastille_cachedir}/${RELEASE}/${_archive}.txz" ]; then echo -e "${COLOR_GREEN}Extracting ${PLATFORM_OS} ${RELEASE} ${_archive}.txz.${COLOR_RESET}" - /usr/bin/tar -C "${bastille_releasesdir}/${RELEASE}" -xf "${bastille_cachedir}/${RELEASE}/${_archive}.txz" - if [ "$?" -ne 0 ]; then + if /usr/bin/tar -C "${bastille_releasesdir}/${RELEASE}" -xf "${bastille_cachedir}/${RELEASE}/${_archive}.txz"; then + ## silence motd at container login + touch "${bastille_releasesdir}/${RELEASE}/root/.hushlogin" + touch "${bastille_releasesdir}/${RELEASE}/usr/share/skel/dot.hushlogin" + else echo -e "${COLOR_RED}Failed to extract ${_archive}.txz.${COLOR_RESET}" exit 1 fi else - ## get the manifest for dist files checksum validation - if [ ! -f "${bastille_cachedir}/${RELEASE}/MANIFEST" ]; then - fetch "${UPSTREAM_URL}/MANIFEST" -o "${bastille_cachedir}/${RELEASE}/MANIFEST" || FETCH_VALIDATION="1" - fi + ## get the manifest for dist files checksum validation + if [ ! -f "${bastille_cachedir}/${RELEASE}/MANIFEST" ]; then + fetch "${UPSTREAM_URL}/MANIFEST" -o "${bastille_cachedir}/${RELEASE}/MANIFEST" || FETCH_VALIDATION="1" + fi - if [ "${FETCH_VALIDATION}" -ne "0" ]; then - ## perform cleanup only for stale/empty directories on failure - if [ "${bastille_zfs_enable}" = "YES" ]; then - if [ -n "${bastille_zfs_zpool}" ]; then - if [ ! "$(ls -A "${bastille_cachedir}/${RELEASE}")" ]; then - zfs destroy "${bastille_zfs_zpool}/${bastille_zfs_prefix}/cache/${RELEASE}" - fi - if [ ! "$(ls -A "${bastille_releasesdir}/${RELEASE}")" ]; then - zfs destroy "${bastille_zfs_zpool}/${bastille_zfs_prefix}/releases/${RELEASE}" - fi - fi + if [ "${FETCH_VALIDATION}" -ne "0" ]; then + ## perform cleanup only for stale/empty directories on failure + if [ "${bastille_zfs_enable}" = "YES" ]; then + if [ -n "${bastille_zfs_zpool}" ]; then + if [ ! "$(ls -A "${bastille_cachedir}/${RELEASE}")" ]; then + zfs destroy "${bastille_zfs_zpool}/${bastille_zfs_prefix}/cache/${RELEASE}" fi - if [ -d "${bastille_cachedir}/${RELEASE}" ]; then - if [ ! "$(ls -A "${bastille_cachedir}/${RELEASE}")" ]; then - rm -rf "${bastille_cachedir}/${RELEASE}" - fi + if [ ! "$(ls -A "${bastille_releasesdir}/${RELEASE}")" ]; then + zfs destroy "${bastille_zfs_zpool}/${bastille_zfs_prefix}/releases/${RELEASE}" fi - if [ -d "${bastille_releasesdir}/${RELEASE}" ]; then - if [ ! "$(ls -A "${bastille_releasesdir}/${RELEASE}")" ]; then - rm -rf "${bastille_releasesdir}/${RELEASE}" - fi fi - echo -e "${COLOR_RED}Bootstrap failed.${COLOR_RESET}" - exit 1 fi + if [ -d "${bastille_cachedir}/${RELEASE}" ]; then + if [ ! "$(ls -A "${bastille_cachedir}/${RELEASE}")" ]; then + rm -rf "${bastille_cachedir}/${RELEASE}" + fi + fi + if [ -d "${bastille_releasesdir}/${RELEASE}" ]; then + if [ ! "$(ls -A "${bastille_releasesdir}/${RELEASE}")" ]; then + rm -rf "${bastille_releasesdir}/${RELEASE}" + fi + fi + echo -e "${COLOR_RED}Bootstrap failed.${COLOR_RESET}" + exit 1 + fi ## fetch for missing dist files if [ ! -f "${bastille_cachedir}/${RELEASE}/${_archive}.txz" ]; then @@ -365,8 +369,11 @@ bootstrap_release() { ## extract the fetched dist files if [ -f "${bastille_cachedir}/${RELEASE}/${_archive}.txz" ]; then echo -e "${COLOR_GREEN}Extracting ${PLATFORM_OS} ${RELEASE} ${_archive}.txz.${COLOR_RESET}" - /usr/bin/tar -C "${bastille_releasesdir}/${RELEASE}" -xf "${bastille_cachedir}/${RELEASE}/${_archive}.txz" - if [ "$?" -ne 0 ]; then + if /usr/bin/tar -C "${bastille_releasesdir}/${RELEASE}" -xf "${bastille_cachedir}/${RELEASE}/${_archive}.txz"; then + ## silence motd at container login + touch "${bastille_releasesdir}/${RELEASE}/root/.hushlogin" + touch "${bastille_releasesdir}/${RELEASE}/usr/share/skel/dot.hushlogin" + else echo -e "${COLOR_RED}Failed to extract ${_archive}.txz.${COLOR_RESET}" exit 1 fi