Improving debugging.
This commit is contained in:
+16
-16
@@ -73,7 +73,7 @@ cleanup() {
|
|||||||
rm -${DIR_RM_FLAGS} "${INSTALL_DIR}"
|
rm -${DIR_RM_FLAGS} "${INSTALL_DIR}"
|
||||||
fi
|
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}
|
kill ${BRIDGE_PID}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ hierarchy_preparation() {
|
|||||||
hardware_detection() {
|
hardware_detection() {
|
||||||
local TMPFILE="/tmp/nixos-installation-hw-detection.json"
|
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
|
set -euo pipefail
|
||||||
|
|
||||||
# --- Initialize Global JSON Output ---
|
# --- Initialize Global JSON Output ---
|
||||||
@@ -183,7 +183,7 @@ detect_corals() {
|
|||||||
local corals="[]"
|
local corals="[]"
|
||||||
|
|
||||||
# Check PCIe Coral (Google ID 1ac1:089a)
|
# 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
|
local pcie_count
|
||||||
pcie_count=\$(lspci -nn | grep -ic "1ac1:089a")
|
pcie_count=\$(lspci -nn | grep -ic "1ac1:089a")
|
||||||
for ((i=1; i<=pcie_count; i++)); do
|
for ((i=1; i<=pcie_count; i++)); do
|
||||||
@@ -193,7 +193,7 @@ detect_corals() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check USB Coral (Google ID 18d1:9302)
|
# 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
|
local usb_count
|
||||||
usb_count=\$(lsusb | grep -ic "18d1:9302")
|
usb_count=\$(lsusb | grep -ic "18d1:9302")
|
||||||
for ((i=1; i<=usb_count; i++)); do
|
for ((i=1; i<=usb_count; i++)); do
|
||||||
@@ -228,7 +228,7 @@ detect_zigbee() {
|
|||||||
detect_network() {
|
detect_network() {
|
||||||
local networks="[]"
|
local networks="[]"
|
||||||
local default_iface
|
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
|
for iface_path in /sys/class/net/*; do
|
||||||
[[ -e "\$iface_path" ]] || continue
|
[[ -e "\$iface_path" ]] || continue
|
||||||
@@ -286,9 +286,9 @@ detect_disks() {
|
|||||||
# Disk Type Mapping
|
# Disk Type Mapping
|
||||||
local disk_type="Other"
|
local disk_type="Other"
|
||||||
local transport
|
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
|
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
|
if [[ "\$disk" == nvme* ]]; then
|
||||||
disk_type="NVMe"
|
disk_type="NVMe"
|
||||||
@@ -302,7 +302,7 @@ detect_disks() {
|
|||||||
|
|
||||||
# Size in GB
|
# Size in GB
|
||||||
local size_bytes
|
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
|
local size_gb
|
||||||
size_gb=\$(awk "BEGIN {printf \"%.2f\", \$size_bytes/1073741824}")
|
size_gb=\$(awk "BEGIN {printf \"%.2f\", \$size_bytes/1073741824}")
|
||||||
|
|
||||||
@@ -316,8 +316,8 @@ detect_disks() {
|
|||||||
|
|
||||||
# Health Assessment (Requires smartctl)
|
# Health Assessment (Requires smartctl)
|
||||||
local health="N/A"
|
local health="N/A"
|
||||||
if echo "${LIVE_TARGET_PASSWORD}" | sudo -S smartctl -H "\$dev_path" > "${STDOUT}" 2> "${STDERR}"; 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
|
if smartctl -H "\$dev_path" >> "${STDOUT}" 2>> "${STDERR}" | grep -iq "PASSED\|OK"; then
|
||||||
health="PASSED"
|
health="PASSED"
|
||||||
else
|
else
|
||||||
health="FAILED"
|
health="FAILED"
|
||||||
@@ -347,7 +347,7 @@ detect_disks
|
|||||||
echo "\$HW_REPORT" | jq '.' > "$TMPFILE"
|
echo "\$HW_REPORT" | jq '.' > "$TMPFILE"
|
||||||
SSHEND
|
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
|
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"
|
echo -e "\n ✅ Hardware configuration generated"
|
||||||
@@ -365,12 +365,12 @@ launch_gui() {
|
|||||||
echo -e "\n 🚀 Launching Numbus Configurator..."
|
echo -e "\n 🚀 Launching Numbus Configurator..."
|
||||||
echo -e " ➡️ You will now proceed to the configuration of your device through your browser"
|
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=$!
|
export BRIDGE_PID=$!
|
||||||
|
|
||||||
local START_URL="http://localhost:${WEBSERVER_PORT}/pages/index.html"
|
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
|
sleep 5
|
||||||
|
|
||||||
@@ -389,7 +389,7 @@ setup_ssh() {
|
|||||||
|
|
||||||
echod "\n ➡️ Copying SSH key to target host '${TARGET_USER}@${LIVE_TARGET_IP}'..."
|
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"
|
echod "\n ✅ SSH key copied successfully"
|
||||||
else
|
else
|
||||||
echo -e "\n ❌ Failed to copy SSH key. Please check the host IP and password."
|
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
|
for id in ${RECORD_IDS}; do
|
||||||
curl -s -X DELETE "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${id}" \
|
curl -s -X DELETE "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${id}" \
|
||||||
-H "Authorization: Bearer ${CLOUDFLARE_DNS_API_TOKEN}" \
|
-H "Authorization: Bearer ${CLOUDFLARE_DNS_API_TOKEN}" \
|
||||||
-H "Content-Type: application/json" > "${STDOUT}" 2> "${STDERR}"
|
-H "Content-Type: application/json" >> "${STDOUT}" 2>> "${STDERR}"
|
||||||
done
|
done
|
||||||
|
|
||||||
create_records "${SUBDOMAIN}"
|
create_records "${SUBDOMAIN}"
|
||||||
@@ -666,7 +666,7 @@ postrun_action() {
|
|||||||
FOUND="false"
|
FOUND="false"
|
||||||
i="0"
|
i="0"
|
||||||
while [[ "${FOUND}" == "false" ]]; do
|
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"
|
FOUND="true"
|
||||||
echo -e "\n✅ Ping ${HOME_SERVER_IP} successful ! Continuing..."
|
echo -e "\n✅ Ping ${HOME_SERVER_IP} successful ! Continuing..."
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user