From 42b8b598802b12757ce92498da97e8a6ece6af2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Loun=C3=A8s=20Ksouri?= Date: Wed, 21 Apr 2021 15:04:12 +0200 Subject: [PATCH] Add debug trigger (#391) Co-authored-by: Luke Childs --- docker-compose.yml | 1 + events/triggers/debug | 25 +++++++++++++++++++++++++ scripts/debug | 4 +++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100755 events/triggers/debug diff --git a/docker-compose.yml b/docker-compose.yml index 9b886b3..806780f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -113,6 +113,7 @@ services: UPDATE_SIGNAL_FILE: "/signals/update" UPDATE_LOCK_FILE: "/statuses/update-in-progress" BACKUP_STATUS_FILE: "/statuses/backup-status.json" + DEBUG_STATUS_FILE: "/statuses/debug-status.json" TOR_PROXY_IP: "${TOR_PROXY_IP}" TOR_PROXY_PORT: "${TOR_PROXY_PORT}" TOR_HIDDEN_SERVICE_DIR: "/var/lib/tor" diff --git a/events/triggers/debug b/events/triggers/debug new file mode 100755 index 0000000..5255a33 --- /dev/null +++ b/events/triggers/debug @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +UMBREL_ROOT="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/../..)" +DEBUG_SCRIPT="${UMBREL_ROOT}/scripts/debug" + +cat < "${UMBREL_ROOT}/statuses/debug-status.json" +{"status": "processing"} +EOF + +json_encode () { + jq --null-input --raw-input 'reduce inputs as $line (""; . += "\($line)\n")' +} + +debug_json_string=$("${DEBUG_SCRIPT}" --dashboard | sed '/onion/d' | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" | json_encode) +dmesg_json_string=$(dmesg | json_encode) + +cat < "${UMBREL_ROOT}/statuses/debug-status.json" +{ + "status": "success", + "debug": ${debug_json_string}, + "dmesg": ${dmesg_json_string} +} +EOF + +echo "Debug result file generated" diff --git a/scripts/debug b/scripts/debug index 116e948..ab7a06e 100755 --- a/scripts/debug +++ b/scripts/debug @@ -179,7 +179,9 @@ if [[ ! -z "${UMBREL_OS:-}" ]]; then fi fi -if [[ "${1}" == "--upload" ]]; then +if [[ "${1}" == "--dashboard" ]]; then + echo "The debug script did not automatically detect any issues with your Umbrel." +elif [[ "${1}" == "--upload" ]]; then # This runs the script twice, but it works echo "This script could not automatically detect an issue with your Umbrel." echo "Please share the following links and paste it in the Umbrel Telegram group (https://t.me/getumbrel) so we can help you with your problem."