Lint bootstrap.sh

Lint with https://github.com/koalaman/shellcheck/wiki
This commit is contained in:
Egor Kuzmichev
2021-06-09 11:03:03 +03:00
parent b85d6347de
commit 9347fd0eae

View File

@@ -45,13 +45,13 @@ esac
#Validate if ZFS is enabled in rc.conf and bastille.conf. #Validate if ZFS is enabled in rc.conf and bastille.conf.
if [ "$(sysrc -n zfs_enable)" = "YES" ] && [ ! "${bastille_zfs_enable}" = "YES" ]; then if [ "$(sysrc -n zfs_enable)" = "YES" ] && [ ! "${bastille_zfs_enable}" = "YES" ]; then
warn "ZFS is enabled in rc.conf but not bastille.conf. Do you want to continue? (N|y)" warn "ZFS is enabled in rc.conf but not bastille.conf. Do you want to continue? (N|y)"
read answer read answer
case $answer in case $answer in
no|No|n|N|"") no|No|n|N|"")
error_exit "ERROR: Missing ZFS parameters. See bastille_zfs_enable." error_exit "ERROR: Missing ZFS parameters. See bastille_zfs_enable."
;; ;;
yes|Yes|y|Y) yes|Yes|y|Y)
continue # continue
;; ;;
esac esac
fi fi
@@ -85,7 +85,7 @@ validate_release_url() {
info "Bootstrapping ${PLATFORM_OS} distfiles..." info "Bootstrapping ${PLATFORM_OS} distfiles..."
# Alternate RELEASE/ARCH fetch support # Alternate RELEASE/ARCH fetch support
if [ "${OPTION}" = "--i386" -o "${OPTION}" = "--32bit" ]; then if [ "${OPTION}" = "--i386" ] || [ "${OPTION}" = "--32bit" ]; then
ARCH="i386" ARCH="i386"
RELEASE="${RELEASE}-${ARCH}" RELEASE="${RELEASE}-${ARCH}"
fi fi
@@ -253,12 +253,12 @@ bootstrap_release() {
fi fi
if [ -d "${bastille_cachedir}/${RELEASE}" ]; then if [ -d "${bastille_cachedir}/${RELEASE}" ]; then
if [ ! "$(ls -A "${bastille_cachedir}/${RELEASE}")" ]; then if [ ! "$(ls -A "${bastille_cachedir}/${RELEASE}")" ]; then
rm -rf "${bastille_cachedir}/${RELEASE}" rm -rf "${bastille_cachedir:?}/${RELEASE}"
fi fi
fi fi
if [ -d "${bastille_releasesdir}/${RELEASE}" ]; then if [ -d "${bastille_releasesdir}/${RELEASE}" ]; then
if [ ! "$(ls -A "${bastille_releasesdir}/${RELEASE}")" ]; then if [ ! "$(ls -A "${bastille_releasesdir}/${RELEASE}")" ]; then
rm -rf "${bastille_releasesdir}/${RELEASE}" rm -rf "${bastille_releasesdir:?}/${RELEASE}"
fi fi
fi fi
error_exit "Bootstrap failed." error_exit "Bootstrap failed."
@@ -266,8 +266,8 @@ bootstrap_release() {
## 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" if ! fetch "${UPSTREAM_URL}/${_archive}.txz" -o "${bastille_cachedir}/${RELEASE}/${_archive}.txz";
if [ "$?" -ne 0 ]; then then
## alert only if unable to fetch additional dist files ## alert only if unable to fetch additional dist files
error_notify "Failed to fetch ${_archive}.txz." error_notify "Failed to fetch ${_archive}.txz."
fi fi
@@ -336,7 +336,7 @@ bootstrap_template() {
$(which git) clone "${_url}" "${_template}" ||\ $(which git) clone "${_url}" "${_template}" ||\
error_notify "Clone unsuccessful." error_notify "Clone unsuccessful."
elif [ -d "${_template}/.git" ]; then elif [ -d "${_template}/.git" ]; then
cd "${_template}" && $(which git) pull ||\ (cd "${_template}" && $(which git) pull) ||\
error_notify "Template update unsuccessful." error_notify "Template update unsuccessful."
fi fi
fi fi
@@ -352,7 +352,7 @@ OPTION="${2}"
# Alternate RELEASE/ARCH fetch support(experimental) # Alternate RELEASE/ARCH fetch support(experimental)
if [ -n "${OPTION}" ] && [ "${OPTION}" != "${HW_MACHINE}" ] && [ "${OPTION}" != "update" ]; then if [ -n "${OPTION}" ] && [ "${OPTION}" != "${HW_MACHINE}" ] && [ "${OPTION}" != "update" ]; then
# Supported architectures # Supported architectures
if [ "${OPTION}" = "--i386" -o "${OPTION}" = "--32bit" ]; then if [ "${OPTION}" = "--i386" ] || [ "${OPTION}" = "--32bit" ]; then
HW_MACHINE="i386" HW_MACHINE="i386"
HW_MACHINE_ARCH="i386" HW_MACHINE_ARCH="i386"
else else
@@ -364,7 +364,7 @@ fi
case "${1}" in case "${1}" in
2.[0-9]*) 2.[0-9]*)
## check for MidnightBSD releases name ## check for MidnightBSD releases name
NAME_VERIFY=$(echo ${RELEASE}) NAME_VERIFY=$(echo "${RELEASE}")
UPSTREAM_URL="${bastille_url_midnightbsd}${HW_MACHINE_ARCH}/${NAME_VERIFY}" UPSTREAM_URL="${bastille_url_midnightbsd}${HW_MACHINE_ARCH}/${NAME_VERIFY}"
PLATFORM_OS="MidnightBSD" PLATFORM_OS="MidnightBSD"
validate_release_url validate_release_url