Apply same improvement to pihole tricorder feature

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2021-09-07 11:15:36 +02:00
parent 606b05eec1
commit be68a5339c
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD
2 changed files with 11 additions and 6 deletions

View File

@ -1333,7 +1333,7 @@ analyze_pihole_log() {
curl_to_tricorder() { curl_to_tricorder() {
# Users can submit their debug logs using curl (encrypted) # Users can submit their debug logs using curl (encrypted)
log_write " * Using ${COL_GREEN}curl${COL_NC} for transmission." log_write " * Using ${COL_GREEN}curl${COL_NC} for transmission."
# transmit he log via TLS and store the token returned in a variable # transmit the log via TLS and store the token returned in a variable
tricorder_token=$(curl --silent --fail --show-error --upload-file ${PIHOLE_DEBUG_LOG} https://tricorder.pi-hole.net 2>&1) tricorder_token=$(curl --silent --fail --show-error --upload-file ${PIHOLE_DEBUG_LOG} https://tricorder.pi-hole.net 2>&1)
if [[ "${tricorder_token}" != "https://tricorder.pi-hole.net/"* ]]; then if [[ "${tricorder_token}" != "https://tricorder.pi-hole.net/"* ]]; then
log_write " * ${COL_GREEN}curl${COL_NC} failed, contact Pi-hole support for assistance." log_write " * ${COL_GREEN}curl${COL_NC} failed, contact Pi-hole support for assistance."

15
pihole
View File

@ -405,12 +405,17 @@ tricorderFunc() {
exit 1 exit 1
fi fi
tricorder_token="$(curl --no-progress-meter --upload-file "-" https://tricorder.pi-hole.net/upload < /dev/stdin)" tricorder_token=$(curl --silent --fail --show-error --upload-file "-" https://tricorder.pi-hole.net/upload < /dev/stdin 2>&1)
if [ -z "${tricorder_token}" ]; then if [[ "${tricorder_token}" != "https://tricorder.pi-hole.net/"* ]]; then
echo -e "${CROSS} uploading failed, contact Pi-hole support for assistance." echo -e "${CROSS} uploading failed, contact Pi-hole support for assistance."
exit 1 # Log curl error (if available)
if [ ! -z "${tricorder_token}" ]; then
echo -e "${INFO} Error message: ${COL_RED}${tricorder_token}${COL_NC}\\n"
tricorder_token=""
fi
exit 1
fi fi
echo "Upload successful, your token is: ${COL_BLUE}${tricorder_token}${COL_NC}" echo "Upload successful, your token is: ${COL_GREEN}${tricorder_token}${COL_NC}"
exit 0 exit 0
} }