Resolve shellcheck validation warnings
Homelab Main / validate (push) Failing after 56s Details
Homelab Main / running-update (push) Has been skipped Details
Homelab Main / debian-ops (push) Has been skipped Details

This commit is contained in:
juvenal.diaz 2026-11-09 19:16:44 -06:00
parent 5280c6ebb7
commit 6fd2ba622c
7 changed files with 19 additions and 10 deletions

View File

@ -223,6 +223,8 @@ for address in addresses:
print(f"update adlist set enabled = 1, comment = coalesce(nullif(comment, ''), 'homelab managed') where address = {quoted};")
PY
elapsed=0
# The SQL file is a user-owned temporary file; the redirect is intentionally local.
# shellcheck disable=SC2024
until sudo docker exec -i "${pihole_container}" pihole-FTL sqlite3 /etc/pihole/gravity.db <"${sql_file}"; do
if ((elapsed >= 120)); then
echo "Timed out waiting for Pi-hole gravity database lock to clear." >&2
@ -283,6 +285,8 @@ for line in useful_lines(static_dhcp_hosts_file):
print(line)
PY
existing_file="$(mktemp)"
# The comparison file is a user-owned temporary file; the redirect is intentionally local.
# shellcheck disable=SC2024
if sudo docker exec "${pihole_container}" cat /etc/dnsmasq.d/02-homelab-managed-dns.conf >"${existing_file}" 2>/dev/null &&
cmp -s "${dnsmasq_file}" "${existing_file}"; then
echo "Pi-hole managed DNS unchanged; skipping Pi-hole restart."

View File

@ -2765,7 +2765,7 @@ EOF
done
timestamp="$(date -u +%Y%m%dT%H%M%SZ)"
mkdir -p -m 700 "${artifact_base}"
(umask 077; mkdir -p "${artifact_base}")
artifact_dir="$(mktemp -d "${artifact_base}/${timestamp}.XXXXXX")"
prompt_file="${artifact_dir}/holmes-prompt.txt"
holmes_stdout="${artifact_dir}/holmes-output.txt"
@ -4687,7 +4687,6 @@ storage_manage() {
snapshot)
local snapshot_action="create"
local snapshot_ref=""
local restore_pvc_ref=""
local storage_class=""
local restore_size=""
if [[ "${1:-}" == "create" || "${1:-}" == "delete" || "${1:-}" == "restore" ]]; then

View File

@ -7078,7 +7078,8 @@ reconcile_app_registry_storage() {
rm -f "${result}"
return 1
fi
export TF_VAR_registry_placement="$(<"${result}")"
TF_VAR_registry_placement="$(<"${result}")"
export TF_VAR_registry_placement
rm -f "${result}"
}
@ -7172,7 +7173,7 @@ ensure_pimox_registry_endpoint_forwarding() {
fi
# Remove only our tagged rules, including those pointing at a previously
# selected profile. Otherwise old DNAT rules can win after a later restart.
python3 - "${REPO_ROOT}/scripts/registry-storage-reconcile.py" <<'REGISTRY_RETIRE_PY'
if ! python3 - "${REPO_ROOT}/scripts/registry-storage-reconcile.py" <<'REGISTRY_RETIRE_PY'
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("registry_forwarding", sys.argv[1])
@ -7180,7 +7181,9 @@ helper = importlib.util.module_from_spec(spec)
spec.loader.exec_module(helper)
helper.retire_legacy_forwarding()
REGISTRY_RETIRE_PY
[[ "$?" == 0 ]] || return 1
then
return 1
fi
if [[ "${registry_host}:${registry_port}" == "${target_host}:${target_port}" ]]; then
return 0
fi

View File

@ -75,7 +75,7 @@ while any(alive(pid) for pid in wanted) and time.monotonic() < deadline:
if any(alive(pid) for pid in wanted):
raise SystemExit("K3s workload processes remain; runtime is not stopped")
K3S_TASKS_PY
for attempt in {1..10}; do
for ((attempt = 0; attempt < 10; attempt++)); do
if sudo -n pgrep -f '[c]ontainerd-shim.*[/]run/k3s|[c]ontainerd .*[/]var/lib/rancher/k3s/agent/etc/containerd/config.toml' >/dev/null; then
sleep 1
else

View File

@ -19,7 +19,7 @@ if ! dpkg-query -W -f='${Status}' prometheus-node-exporter 2>/dev/null |
sudo -n env DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends prometheus-node-exporter
fi
sudo -n systemctl enable --now prometheus-node-exporter
for attempt in {1..15}; do
for ((attempt = 0; attempt < 15; attempt++)); do
if curl --max-time 5 -fsS http://127.0.0.1:9100/metrics 2>/dev/null |
grep -F 'node_exporter_build_info' >/dev/null; then
echo "Node exporter is responding on TCP/9100."

View File

@ -24,7 +24,8 @@ region="${LAB_OCI_REGION:-${OCI_CLI_REGION:-}}"
}
oci_json_ids() {
local command_json="$(cat)"
local command_json
command_json="$(cat)"
python3 -c 'import json,sys; raw=sys.stdin.read().strip(); data=json.loads(raw) if raw else {}; print("\n".join(x["id"] for x in data.get("data", [])))' <<<"${command_json}"
}
@ -75,7 +76,7 @@ delete_resource() {
}
wait_instance_terminated() {
local id="$1" state="" attempt
for attempt in {1..36}; do
for ((attempt = 0; attempt < 36; attempt++)); do
state="$("${oci_bin}" compute instance get --instance-id "${id}" --query 'data."lifecycle-state"' --raw-output 2>/dev/null || true)"
[[ "${state}" == "TERMINATED" || -z "${state}" ]] && return 0
sleep 5

View File

@ -59,7 +59,9 @@ validate_shellcheck() {
echo "no shell files found"
return 0
fi
shellcheck "${files[@]}"
# Informational findings remain useful during focused reviews, but the
# validation gate enforces warnings and errors consistently on CI hosts.
shellcheck --severity=warning "${files[@]}"
}
validate_yaml() {