Fixed permission problem. Improving debugging.
This commit is contained in:
+17
-15
@@ -94,14 +94,14 @@ hierarchy_preparation() {
|
||||
}
|
||||
|
||||
hardware_detection() {
|
||||
local TMPFILE="/tmp/nixos-installation-hw-detection.json"
|
||||
local TMPFILE="/run/user/1000/numbus-installer/hw_detection.json"
|
||||
|
||||
ssh_to_host "nix-shell -p jq pciutils usbutils smartmontools iproute2 --run 'bash -s'" << SSHEND >> "${STDOUT}" 2>> "${STDERR}"
|
||||
set -euo pipefail
|
||||
|
||||
if [[ ${DEBUG} -eq 1 ]]; then
|
||||
mkdir -${MKDIR_FLAGS} "${STDOUT}"
|
||||
mkdir -${MKDIR_FLAGS} "${STDERR}"
|
||||
mkdir -${MKDIR_FLAGS} "${REMOTE_STDOUT%std.log}"
|
||||
mkdir -${MKDIR_FLAGS} "${REMOTE_STDERR%err.log}"
|
||||
fi
|
||||
|
||||
# --- Initialize Global JSON Output ---
|
||||
@@ -124,13 +124,13 @@ detect_graphics() {
|
||||
OLD_IFS="\$IFS"
|
||||
IFS=\$'n'
|
||||
|
||||
for line in \$(lspci | grep -e VGA -e 3D >> "${STDOUT}" 2>> "${STDERR}"); do
|
||||
for line in \$(lspci | grep -e VGA -e 3D >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}"); 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}" >> "${STDOUT}" 2>> "${STDERR}"; then
|
||||
if echo "\${line}" | grep -i "\${b}" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}"; then
|
||||
brand="\${b}"
|
||||
fi
|
||||
done
|
||||
@@ -178,7 +178,7 @@ detect_corals() {
|
||||
local corals="[]"
|
||||
|
||||
# Check PCIe Coral (Google ID 1ac1:089a)
|
||||
if lspci -nn | grep -iq "1ac1:089a" >> "${STDOUT}" 2>> "${STDERR}"; then
|
||||
if lspci -nn | grep -iq "1ac1:089a" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}"; then
|
||||
local pcie_count
|
||||
pcie_count=\$(lspci -nn | grep -ic "1ac1:089a")
|
||||
for ((i=1; i<=pcie_count; i++)); do
|
||||
@@ -188,7 +188,7 @@ detect_corals() {
|
||||
fi
|
||||
|
||||
# Check USB Coral (Google ID 18d1:9302)
|
||||
if lsusb >> "${STDOUT}" 2>> "${STDERR}" | grep -iq "18d1:9302"; then
|
||||
if lsusb | grep -iq "18d1:9302" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}"; then
|
||||
local usb_count
|
||||
usb_count=\$(lsusb | grep -ic "18d1:9302")
|
||||
for ((i=1; i<=usb_count; i++)); do
|
||||
@@ -223,7 +223,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 >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}" | awk '{print \$5}' | head -n1)
|
||||
|
||||
for iface_path in /sys/class/net/*; do
|
||||
[[ -e "\$iface_path" ]] || continue
|
||||
@@ -281,9 +281,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" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_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" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}" || echo "1")
|
||||
|
||||
if [[ "\$disk" == nvme* ]]; then
|
||||
disk_type="NVMe"
|
||||
@@ -297,7 +297,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" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}" || echo "0")
|
||||
local size_gb
|
||||
size_gb=\$(awk "BEGIN {printf \"%.2f\", \$size_bytes/1073741824}")
|
||||
|
||||
@@ -311,8 +311,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" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}"; then
|
||||
if smartctl -H "\$dev_path" | grep -iq -e "PASSED" -e "OK" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}"; then
|
||||
health="PASSED"
|
||||
else
|
||||
health="FAILED"
|
||||
@@ -343,8 +343,8 @@ 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}"
|
||||
[[ ${DEBUG} -eq 1 ]] && scp -i "${TMP_EXTRA_PATH}/home/numbus-admin/.ssh/id_ed25519" "${TARGET_USER}@${LIVE_TARGET_IP}":"${STDOUT}" "${INSTALL_DIR}/logs/hw_std.log" >> "${STDOUT}" 2>> "${STDERR}"
|
||||
[[ ${DEBUG} -eq 1 ]] && scp -i "${TMP_EXTRA_PATH}/home/numbus-admin/.ssh/id_ed25519" "${TARGET_USER}@${LIVE_TARGET_IP}":"${STDERR}" "${INSTALL_DIR}/logs/hw_err.log" >> "${STDOUT}" 2>> "${STDERR}"
|
||||
[[ ${DEBUG} -eq 1 ]] && scp -i "${TMP_EXTRA_PATH}/home/numbus-admin/.ssh/id_ed25519" "${TARGET_USER}@${LIVE_TARGET_IP}":"${REMOTE_STDOUT}" "${INSTALL_DIR}/logs/hw_std.log" >> "${STDOUT}" 2>> "${STDERR}"
|
||||
[[ ${DEBUG} -eq 1 ]] && scp -i "${TMP_EXTRA_PATH}/home/numbus-admin/.ssh/id_ed25519" "${TARGET_USER}@${LIVE_TARGET_IP}":"${REMOTE_STDERR}" "${INSTALL_DIR}/logs/hw_err.log" >> "${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"
|
||||
@@ -758,6 +758,8 @@ if [[ ${DEBUG-0} -eq 1 ]]; then
|
||||
MV_FLAGS="vu"
|
||||
STDOUT="${INSTALL_DIR}/web/logs/std.log"
|
||||
STDERR="${INSTALL_DIR}/web/logs/err.log"
|
||||
REMOTE_STDOUT="/run/user/1000/numbus-installer/std.log"
|
||||
REMOTE_STDERR="/run/user/1000/numbus-installer/err.log"
|
||||
else
|
||||
DEBUG=0
|
||||
FILES_CP_FLAGS="au"
|
||||
|
||||
Reference in New Issue
Block a user