From 7c62c9fb18382e55f44362314edb39cf771df3a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Fri, 25 Jun 2021 10:18:24 +0200 Subject: [PATCH 1/2] Change default LNS server to TTS Community Edition (v3) --- start_common.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/start_common.sh b/start_common.sh index 6b1fa85..7251dd4 100644 --- a/start_common.sh +++ b/start_common.sh @@ -1,18 +1,19 @@ # Defaults to TTN server v2, EU region -TTN_STACK_VERSION=${TTN_STACK_VERSION:-2} +TTN_STACK_VERSION=${TTN_STACK_VERSION:-3} if [ $TTN_STACK_VERSION -eq 2 ]; then TTN_REGION=${TTN_REGION:-"eu"} TC_URI=${TC_URI:-"wss://lns.${TTN_REGION}.thethings.network:443"} - TC_TRUST=${TC_TRUST:-$(curl --silent "https://letsencrypt.org/certs/trustid-x3-root.pem.txt")} elif [ $TTN_STACK_VERSION -eq 3 ]; then TTN_REGION=${TTN_REGION:-"eu1"} TC_URI=${TC_URI:-"wss://${TTN_REGION}.cloud.thethings.network:8887"} - TC_TRUST=${TC_TRUST:-$(curl --silent "https://letsencrypt.org/certs/{trustid-x3-root.pem.txt,isrgrootx1.pem}")} else echo -e "\033[91mERROR: Wrong TTN_STACK_VERSION value, should be either 2 o 3.\033[0m" balena-idle fi +# Get certificate +TC_TRUST=${TC_TRUST:-$(curl --silent "https://letsencrypt.org/certs/{trustid-x3-root.pem.txt,isrgrootx1.pem}")} + # Check configuration if [ "$TC_URI" == "" ] || [ "$TC_TRUST" == "" ] then @@ -22,9 +23,6 @@ fi echo "Server: $TC_URI" -# Sanitize TC_TRUST -#TC_TRUST=$(echo $TC_TRUST | sed 's/-----BEGIN CERTIFICATE-----/-----BEGIN CERTIFICATE-----\n/' | sed 's/-----END CERTIFICATE-----/\n-----END CERTIFICATE-----/' | sed 's/\n\n/\n/g') - # declare map of hardware pins to GPIO on Raspberry Pi declare -a pinToGPIO pinToGPIO=( -1 -1 -1 2 -1 3 -1 4 14 -1 15 17 18 27 -1 22 23 -1 24 10 -1 9 25 11 8 -1 7 0 1 5 -1 6 12 13 -1 19 16 26 20 -1 21) From d10e509bbf35ac06018e63f80426442f4fee6f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Fri, 25 Jun 2021 10:19:40 +0200 Subject: [PATCH 2/2] Fix sanitizing TC_TRUST --- start_common.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/start_common.sh b/start_common.sh index 7251dd4..d564ba1 100644 --- a/start_common.sh +++ b/start_common.sh @@ -14,6 +14,9 @@ fi # Get certificate TC_TRUST=${TC_TRUST:-$(curl --silent "https://letsencrypt.org/certs/{trustid-x3-root.pem.txt,isrgrootx1.pem}")} +# Sanitize TC_TRUST +TC_TRUST=$(echo $TC_TRUST | sed 's/\s//g' | sed 's/-----BEGINCERTIFICATE-----/-----BEGIN CERTIFICATE-----\n/g' | sed 's/-----ENDCERTIFICATE-----/\n-----END CERTIFICATE-----\n/g' | sed 's/\n+/\n/g') + # Check configuration if [ "$TC_URI" == "" ] || [ "$TC_TRUST" == "" ] then