diff --git a/usr/local/share/bastille/bootstrap.sh b/usr/local/share/bastille/bootstrap.sh index bfad535e..295ebf67 100644 --- a/usr/local/share/bastille/bootstrap.sh +++ b/usr/local/share/bastille/bootstrap.sh @@ -216,6 +216,8 @@ bootstrap_release() { if [ -f "${bastille_releasesdir}/${RELEASE}/COPYRIGHT" ]; then ## check distfiles list and skip existing cached files bastille_bootstrap_archives=$(echo "${bastille_bootstrap_archives}" | sed "s/base//") + # TODO check how to handle this + # shellcheck disable=SC2010 bastille_cached_files=$(ls "${bastille_cachedir}/${RELEASE}" | grep -v "MANIFEST" | tr -d ".txz") for distfile in ${bastille_cached_files}; do bastille_bootstrap_archives=$(echo "${bastille_bootstrap_archives}" | sed "s/${distfile}//") @@ -452,7 +454,7 @@ HW_MACHINE_ARCH=$(sysctl hw.machine_arch | awk '{ print $2 }') # bootstrapping from aarch64/arm64 Debian or Ubuntu require a different value for ARCH # create a new variable -if [ "${HW_MACHINE_ARCH}" == "aarch64" ]; then +if [ "${HW_MACHINE_ARCH}" = "aarch64" ]; then HW_MACHINE_ARCH_LINUX="arm64" else HW_MACHINE_ARCH_LINUX=${HW_MACHINE_ARCH} diff --git a/usr/local/share/bastille/clone.sh b/usr/local/share/bastille/clone.sh index 48a4417d..fee55737 100644 --- a/usr/local/share/bastille/clone.sh +++ b/usr/local/share/bastille/clone.sh @@ -58,6 +58,7 @@ validate_ip() { if [ -n "${ip6}" ]; then info "Valid: (${ip6})." IPX_ADDR="ip6.addr" + # shellcheck disable=SC2034 IP6_MODE="new" else local IFS @@ -104,8 +105,8 @@ update_jailconf_vnet() { bastille_jail_rc_conf="${bastille_jailsdir}/${NEWNAME}/root/etc/rc.conf" # Determine number of containers and define an uniq_epair - local list_jails_num=$(bastille list jails | wc -l | awk '{print $1}') - local num_range=$(expr "${list_jails_num}" + 1) + local list_jails_num="$(bastille list jails | wc -l | awk '{print $1}')" + local num_range="$(expr "${list_jails_num}" + 1)" jail_list=$(bastille list jail) for _num in $(seq 0 "${num_range}"); do if [ -n "${jail_list}" ]; then @@ -125,7 +126,7 @@ update_jailconf_vnet() { sed -i '' "s|ifconfig_e0b_bastille.*_name|ifconfig_e0b_${uniq_epair}_name|" "${bastille_jail_rc_conf}" # If 0.0.0.0 set DHCP, else set static IP address - if [ "${IP}" == "0.0.0.0" ]; then + if [ "${IP}" = "0.0.0.0" ]; then sysrc -f "${bastille_jail_rc_conf}" ifconfig_vnet0="SYNCDHCP" else sysrc -f "${bastille_jail_rc_conf}" ifconfig_vnet0="inet ${IP}" diff --git a/usr/local/share/bastille/destroy.sh b/usr/local/share/bastille/destroy.sh index 9d9e9996..9bdb6057 100644 --- a/usr/local/share/bastille/destroy.sh +++ b/usr/local/share/bastille/destroy.sh @@ -172,7 +172,7 @@ destroy_rel() { if [ "${FORCE}" = "1" ]; then ## remove cache on force if [ -d "${bastille_cachedir}/${TARGET}" ]; then - rm -rf "${bastille_cachedir}/${TARGET}" + rm -rf "${bastille_cachedir:?}/${TARGET}" fi fi echo diff --git a/usr/local/share/bastille/import.sh b/usr/local/share/bastille/import.sh index 391dfc9d..34cda5fc 100644 --- a/usr/local/share/bastille/import.sh +++ b/usr/local/share/bastille/import.sh @@ -79,7 +79,7 @@ while [ $# -gt 0 ]; do TARGET="${2}" shift ;; - -*|--*) + --*|-*) error_notify "Unknown Option." usage ;; @@ -281,7 +281,7 @@ EOF >> "${bastille_jailsdir}/${TARGET_TRIM}/fstab" # Work with the symlinks - cd "${bastille_jailsdir}/${TARGET_TRIM}/root" + cd "${bastille_jailsdir}/${TARGET_TRIM}/root" || error_exit "Failed to change directory." update_symlinks else # Generate new empty fstab file @@ -324,7 +324,7 @@ update_config() { >> "${bastille_jailsdir}/${TARGET_TRIM}/fstab" # Work with the symlinks - cd "${bastille_jailsdir}/${TARGET_TRIM}/root" + cd "${bastille_jailsdir}/${TARGET_TRIM}/root" || error_exit "Failed to change directory." update_symlinks } @@ -377,7 +377,7 @@ update_symlinks() { for _link in ${SYMLINKS}; do if [ -L "${_link}" ]; then ln -sf /.bastille/${_link} ${_link} - elif [ "${ALLOW_EMPTY_DIRS_TO_BE_SYMLINKED:-0}" = "1" -a -d "${_link}" ]; then + elif [ "${ALLOW_EMPTY_DIRS_TO_BE_SYMLINKED:-0}" = "1" ] && [ -d "${_link}" ]; then # -F will enforce that the directory is empty and replaced by the symlink ln -sfF /.bastille/${_link} ${_link} || EXIT_CODE=$? if [ "${EXIT_CODE:-0}" != "0" ]; then diff --git a/usr/local/share/bastille/service.sh b/usr/local/share/bastille/service.sh index 23b8e589..92fa4f27 100644 --- a/usr/local/share/bastille/service.sh +++ b/usr/local/share/bastille/service.sh @@ -41,7 +41,7 @@ help|-h|--help) ;; esac -if [ $# -lt 1 -o $# -gt 2 ]; then +if [ $# -lt 1 ] || [ $# -gt 2 ]; then usage fi diff --git a/usr/local/share/bastille/tags.sh b/usr/local/share/bastille/tags.sh index de24044c..65ed802f 100644 --- a/usr/local/share/bastille/tags.sh +++ b/usr/local/share/bastille/tags.sh @@ -50,7 +50,7 @@ help|-h|--help) ;; esac -if [ $# -lt 1 -o $# -gt 2 ]; then +if [ $# -lt 1 ] || [ $# -gt 2 ]; then usage fi diff --git a/usr/local/share/bastille/update.sh b/usr/local/share/bastille/update.sh index 3bd033f8..4304a73a 100644 --- a/usr/local/share/bastille/update.sh +++ b/usr/local/share/bastille/update.sh @@ -143,9 +143,10 @@ template_update() { templates_update() { # Update all templates _updated_templates=0 - if [ -d ${bastille_templatesdir} ]; then - for _template_path in $(ls -d ${bastille_templatesdir}/*/*); do - if [ -d $_template_path/.git ]; then + if [ -d "${bastille_templatesdir}" ]; then + # shellcheck disable=SC2045 + for _template_path in $(ls -d "${bastille_templatesdir}/*/*"); do + if [ -d "$_template_path/.git" ]; then BASTILLE_TEMPLATE=$(echo "$_template_path" | awk -F / '{ print $(NF-1) "/" $NF }') template_update