[WIP] shellcheck linting

This commit is contained in:
Juan David Hurtado G
2024-12-08 20:57:43 -05:00
parent 7e6a9fa896
commit 8808e8a5a4
7 changed files with 18 additions and 14 deletions

View File

@@ -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}

View File

@@ -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}"

View File

@@ -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

View File

@@ -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

View File

@@ -41,7 +41,7 @@ help|-h|--help)
;;
esac
if [ $# -lt 1 -o $# -gt 2 ]; then
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
usage
fi

View File

@@ -50,7 +50,7 @@ help|-h|--help)
;;
esac
if [ $# -lt 1 -o $# -gt 2 ]; then
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
usage
fi

View File

@@ -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