Improving debugging.

This commit is contained in:
Raphaël Numbus
2026-05-25 17:31:43 +02:00
parent adbbda4a9d
commit 354b3a8aa8
+16 -16
View File
@@ -73,7 +73,7 @@ cleanup() {
rm -${DIR_RM_FLAGS} "${INSTALL_DIR}"
fi
if [[ -n "${BRIDGE_PID:-}" ]] && ps -p ${BRIDGE_PID} > "${STDOUT}" 2> "${STDERR}"; then
if [[ -n "${BRIDGE_PID:-}" ]] && ps -p ${BRIDGE_PID} >> "${STDOUT}" 2>> "${STDERR}"; then
kill ${BRIDGE_PID}
fi
@@ -96,7 +96,7 @@ hierarchy_preparation() {
hardware_detection() {
local TMPFILE="/tmp/nixos-installation-hw-detection.json"
ssh_to_host "nix-shell -p jq pciutils usbutils smartmontools iproute2 --run 'bash -s'" << SSHEND > "${STDOUT}" 2> "${STDERR}"
ssh_to_host "nix-shell -p jq pciutils usbutils smartmontools iproute2 --run 'bash -s'" << SSHEND >> "${STDOUT}" 2>> "${STDERR}"
set -euo pipefail
# --- Initialize Global JSON Output ---
@@ -183,7 +183,7 @@ detect_corals() {
local corals="[]"
# Check PCIe Coral (Google ID 1ac1:089a)
if lspci -nn > "${STDOUT}" 2> "${STDERR}" | grep -iq "1ac1:089a"; then
if lspci -nn >> "${STDOUT}" 2>> "${STDERR}" | grep -iq "1ac1:089a"; then
local pcie_count
pcie_count=\$(lspci -nn | grep -ic "1ac1:089a")
for ((i=1; i<=pcie_count; i++)); do
@@ -193,7 +193,7 @@ detect_corals() {
fi
# Check USB Coral (Google ID 18d1:9302)
if lsusb > "${STDOUT}" 2> "${STDERR}" | grep -iq "18d1:9302"; then
if lsusb >> "${STDOUT}" 2>> "${STDERR}" | grep -iq "18d1:9302"; then
local usb_count
usb_count=\$(lsusb | grep -ic "18d1:9302")
for ((i=1; i<=usb_count; i++)); do
@@ -228,7 +228,7 @@ detect_zigbee() {
detect_network() {
local networks="[]"
local default_iface
default_iface=\$(ip -4 route show default > "${STDOUT}" 2> "${STDERR}" | awk '{print \$5}' | head -n1)
default_iface=\$(ip -4 route show default >> "${STDOUT}" 2>> "${STDERR}" | awk '{print \$5}' | head -n1)
for iface_path in /sys/class/net/*; do
[[ -e "\$iface_path" ]] || continue
@@ -286,9 +286,9 @@ detect_disks() {
# Disk Type Mapping
local disk_type="Other"
local transport
transport=\$(lsblk -d -n -o TRAN "\$dev_path" > "${STDOUT}" 2> "${STDERR}" || echo "")
transport=\$(lsblk -d -n -o TRAN "\$dev_path" >> "${STDOUT}" 2>> "${STDERR}" || echo "")
local rotational
rotational=\$(lsblk -d -n -o ROTA "\$dev_path" > "${STDOUT}" 2> "${STDERR}" || echo "1")
rotational=\$(lsblk -d -n -o ROTA "\$dev_path" >> "${STDOUT}" 2>> "${STDERR}" || echo "1")
if [[ "\$disk" == nvme* ]]; then
disk_type="NVMe"
@@ -302,7 +302,7 @@ detect_disks() {
# Size in GB
local size_bytes
size_bytes=\$(lsblk -d -n -b -o SIZE "\$dev_path" > "${STDOUT}" 2> "${STDERR}" || echo "0")
size_bytes=\$(lsblk -d -n -b -o SIZE "\$dev_path" >> "${STDOUT}" 2>> "${STDERR}" || echo "0")
local size_gb
size_gb=\$(awk "BEGIN {printf \"%.2f\", \$size_bytes/1073741824}")
@@ -316,8 +316,8 @@ detect_disks() {
# Health Assessment (Requires smartctl)
local health="N/A"
if echo "${LIVE_TARGET_PASSWORD}" | sudo -S smartctl -H "\$dev_path" > "${STDOUT}" 2> "${STDERR}"; then
if smartctl -H "\$dev_path" > "${STDOUT}" 2> "${STDERR}" | grep -iq "PASSED\|OK"; then
if echo "${LIVE_TARGET_PASSWORD}" | sudo -S smartctl -H "\$dev_path" >> "${STDOUT}" 2>> "${STDERR}"; then
if smartctl -H "\$dev_path" >> "${STDOUT}" 2>> "${STDERR}" | grep -iq "PASSED\|OK"; then
health="PASSED"
else
health="FAILED"
@@ -347,7 +347,7 @@ detect_disks
echo "\$HW_REPORT" | jq '.' > "$TMPFILE"
SSHEND
scp -i "${TMP_EXTRA_PATH}/home/numbus-admin/.ssh/id_ed25519" "${TARGET_USER}@${LIVE_TARGET_IP}":"${TMPFILE}" "${HW_DATA_FILE}" > "${STDOUT}" 2> "${STDERR}"
scp -i "${TMP_EXTRA_PATH}/home/numbus-admin/.ssh/id_ed25519" "${TARGET_USER}@${LIVE_TARGET_IP}":"${TMPFILE}" "${HW_DATA_FILE}" >> "${STDOUT}" 2>> "${STDERR}"
if ssh_to_host "sudo nixos-generate-config --no-filesystems --show-hardware-config" > ${TMP_EXTRA_PATH}/etc/nixos/hardware-configuration.nix; then
echo -e "\n ✅ Hardware configuration generated"
@@ -365,12 +365,12 @@ launch_gui() {
echo -e "\n 🚀 Launching Numbus Configurator..."
echo -e " ➡️ You will now proceed to the configuration of your device through your browser"
python3 "${BRIDGE_SCRIPT}" > "${STDOUT}" 2> "${STDERR}" &
python3 "${BRIDGE_SCRIPT}" >> "${STDOUT}" 2>> "${STDERR}" &
export BRIDGE_PID=$!
local START_URL="http://localhost:${WEBSERVER_PORT}/pages/index.html"
xdg-open "${START_URL}" > "${STDOUT}" 2> "${STDERR}" || open "${START_URL}" > "${STDOUT}" 2> "${STDERR}" || true
xdg-open "${START_URL}" >> "${STDOUT}" 2>> "${STDERR}" || open "${START_URL}" >> "${STDOUT}" 2>> "${STDERR}" || true
sleep 5
@@ -389,7 +389,7 @@ setup_ssh() {
echod "\n ➡️ Copying SSH key to target host '${TARGET_USER}@${LIVE_TARGET_IP}'..."
if sshpass -p "${LIVE_TARGET_PASSWORD}" ssh-copy-id -o StrictHostKeyChecking=no -i "${TMP_EXTRA_PATH}/home/numbus-admin/.ssh/id_ed25519" "${TARGET_USER}@${LIVE_TARGET_IP}" > "${STDOUT}" 2> "${STDERR}"; then
if sshpass -p "${LIVE_TARGET_PASSWORD}" ssh-copy-id -o StrictHostKeyChecking=no -i "${TMP_EXTRA_PATH}/home/numbus-admin/.ssh/id_ed25519" "${TARGET_USER}@${LIVE_TARGET_IP}" >> "${STDOUT}" 2>> "${STDERR}"; then
echod "\n ✅ SSH key copied successfully"
else
echo -e "\n ❌ Failed to copy SSH key. Please check the host IP and password."
@@ -566,7 +566,7 @@ cloudflare_dns_setup() {
for id in ${RECORD_IDS}; do
curl -s -X DELETE "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${id}" \
-H "Authorization: Bearer ${CLOUDFLARE_DNS_API_TOKEN}" \
-H "Content-Type: application/json" > "${STDOUT}" 2> "${STDERR}"
-H "Content-Type: application/json" >> "${STDOUT}" 2>> "${STDERR}"
done
create_records "${SUBDOMAIN}"
@@ -666,7 +666,7 @@ postrun_action() {
FOUND="false"
i="0"
while [[ "${FOUND}" == "false" ]]; do
if ping -c1 -W1 $HOME_SERVER_IP > "${STDOUT}" 2> "${STDERR}"; then
if ping -c1 -W1 $HOME_SERVER_IP >> "${STDOUT}" 2>> "${STDERR}"; then
FOUND="true"
echo -e "\n✅ Ping ${HOME_SERVER_IP} successful ! Continuing..."
else