From 50f624e9e407aeee055cc0926d931e221c45a649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Numbus?= Date: Mon, 25 May 2026 16:54:57 +0200 Subject: [PATCH] Improved debugging features. Added quotes to live.yaml. Improving hardware detection. --- script/deploy.sh | 73 +++++++++++++++++++++++++------------- web/pages/preparation.html | 2 +- 2 files changed, 50 insertions(+), 25 deletions(-) diff --git a/script/deploy.sh b/script/deploy.sh index 249c4e3..dd92477 100755 --- a/script/deploy.sh +++ b/script/deploy.sh @@ -69,7 +69,7 @@ cleanup() { rm -${DIR_RM_FLAGS} "/run/user/$(id -u)/numbus-installer" - if [[ -n "${BRIDGE_PID:-}" ]] && ps -p ${BRIDGE_PID} > /dev/null; then + if [[ -n "${BRIDGE_PID:-}" ]] && ps -p ${BRIDGE_PID} > "${STDOUT}" 2> "${STDERR}"; then kill ${BRIDGE_PID} fi } @@ -106,7 +106,32 @@ append_to_report() { # --- 1. Detect Graphics --- detect_graphics() { local gpus="[]" - + local brand + local renderer + local product + + for line in lspci | grep VGA; do + local pci_addr + + pci_addr="\$(lspci | grep VGA | head -c 7)" + + # Brand + for b in Intel AMD NVIDIA; do + if [[ echo "\${line}" | grep -i "\${b}" ]]; then + brand="\${b}" + fi + done + + # Renderer info + + + # Product name + + # + done + + + # Iterate over all VGA and 3D controllers while read -r pci_addr; do local brand="Unknown" @@ -152,7 +177,7 @@ detect_corals() { local corals="[]" # Check PCIe Coral (Google ID 1ac1:089a) - if lspci -nn 2>/dev/null | 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 @@ -162,7 +187,7 @@ detect_corals() { fi # Check USB Coral (Google ID 18d1:9302) - if lsusb 2>/dev/null | 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 @@ -197,7 +222,7 @@ detect_zigbee() { detect_network() { local networks="[]" local default_iface - default_iface=\$(ip -4 route show default 2>/dev/null | 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 @@ -255,9 +280,9 @@ detect_disks() { # Disk Type Mapping local disk_type="Other" local transport - transport=\$(lsblk -d -n -o TRAN "\$dev_path" 2>/dev/null || echo "") + transport=\$(lsblk -d -n -o TRAN "\$dev_path" > "${STDOUT}" 2> "${STDERR}" || echo "") local rotational - rotational=\$(lsblk -d -n -o ROTA "\$dev_path" 2>/dev/null || echo "1") + rotational=\$(lsblk -d -n -o ROTA "\$dev_path" > "${STDOUT}" 2> "${STDERR}" || echo "1") if [[ "\$disk" == nvme* ]]; then disk_type="NVMe" @@ -271,7 +296,7 @@ detect_disks() { # Size in GB local size_bytes - size_bytes=\$(lsblk -d -n -b -o SIZE "\$dev_path" 2>/dev/null || 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}") @@ -285,8 +310,8 @@ detect_disks() { # Health Assessment (Requires smartctl) local health="N/A" - if echo "${LIVE_TARGET_PASSWORD}" | sudo -S smartctl -H "\$dev_path" >/dev/null 2>&1; then - if smartctl -H "\$dev_path" 2>/dev/null | 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" @@ -314,9 +339,9 @@ detect_disks # --- Output --- echo "\$HW_REPORT" | jq '.' > "$TMPFILE" -SSHEND +SSHEND > "${STDOUT}" 2> "${STDERR}" - scp -i "${TMP_EXTRA_PATH}/home/numbus-admin/.ssh/id_ed25519" "${TARGET_USER}@${LIVE_TARGET_IP}":"${TMPFILE}" "${HW_DATA_FILE}" &> /dev/null + 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" @@ -334,12 +359,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}" > /dev/null 2>&1 & + python3 "${BRIDGE_SCRIPT}" > "${STDOUT}" 2> "${STDERR}" & export BRIDGE_PID=$! local START_URL="http://localhost:${WEBSERVER_PORT}/pages/index.html" - xdg-open "${START_URL}" 2>/dev/null || open "${START_URL}" 2>/dev/null || true + xdg-open "${START_URL}" > "${STDOUT}" 2> "${STDERR}" || open "${START_URL}" > "${STDOUT}" 2> "${STDERR}" || true sleep 5 @@ -356,14 +381,10 @@ setup_ssh() { chmod 700 "${TMP_EXTRA_PATH}/home/numbus-admin/.ssh/" ssh-keygen -t "ed25519" -C "numbus-admin@numbus-${DEVICE_TYPE}" -f "${TMP_EXTRA_PATH}/home/numbus-admin/.ssh/id_ed25519" -N "" -q - if [[ ${DEBUG} -eq 1 ]]; then - echo -e "\n āž”ļø Copying SSH key to target host '${TARGET_USER}@${LIVE_TARGET_IP}'..." - fi + 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}"; then - if [[ ${DEBUG} -eq 1 ]]; then - echo -e "\n āœ… SSH key copied successfully" - fi + 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." exit 1 @@ -473,7 +494,7 @@ EOF done local SSH_KEYS_FORMATTED="" - if [[ "$(declare -p AUTHORIZED_SSH_PUBLIC_KEY 2>/dev/null)" =~ "declare -a" ]]; then + if [[ "$(declare -p AUTHORIZED_SSH_PUBLIC_KEY)" =~ "declare -a" ]]; then for key in "${AUTHORIZED_SSH_PUBLIC_KEY[@]}"; do SSH_KEYS_FORMATTED+=" $key"$'\n' done @@ -539,7 +560,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" > /dev/null 2>&1 + -H "Content-Type: application/json" > > "${STDOUT}" 2> "${STDERR}" done create_records "${SUBDOMAIN}" @@ -639,7 +660,7 @@ postrun_action() { FOUND="false" i="0" while [[ "${FOUND}" == "false" ]]; do - if ping -c1 -W1 $HOME_SERVER_IP >/dev/null 2>&1; then + if ping -c1 -W1 $HOME_SERVER_IP > "${STDOUT}" 2> "${STDERR}"; then FOUND="true" echo -e "\nāœ… Ping ${HOME_SERVER_IP} successful ! Continuing..." else @@ -730,6 +751,8 @@ if [[ ${DEBUG-0} -eq 1 ]]; then DIR_RM_FLAGS="rvf" MKDIR_FLAGS="pv" MV_FLAGS="vu" + STDOUT="std.log" + STDERR="err.log" else DEBUG=0 FILES_CP_FLAGS="au" @@ -737,6 +760,8 @@ else DIR_RM_FLAGS="rf" MKDIR_FLAGS="p" MV_FLAGS="u" + STDOUT="/dev/null" + STDERR="/dev/null" fi IP_REGEX='^([0-9]{1,3}\.){3}[0-9]{1,3}$' diff --git a/web/pages/preparation.html b/web/pages/preparation.html index a109f21..2ecb51c 100644 --- a/web/pages/preparation.html +++ b/web/pages/preparation.html @@ -77,7 +77,7 @@ const response = await fetch('/discovery', { method: 'POST', headers: { 'Content-Type': 'text/yaml' }, - body: jsyaml.dump(payload) + body: jsyaml.dump(payload, { quotingType: '"', forceQuotes: true }) }); if (response.ok) {