From 4c61632e3d389d4cfa1f66e9689660e18fc8899a Mon Sep 17 00:00:00 2001 From: Dominik Dzienia Date: Thu, 13 Mar 2025 08:18:07 +0000 Subject: [PATCH 1/4] Support for new mikr.us hostname naming scheme --- install.sh | 24 +++++++++++++----------- package.json | 2 +- src/lib.sh | 18 ++++++++++-------- src/setup.sh | 2 +- updated | 2 +- 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/install.sh b/install.sh index 8758e55..50e1bf8 100644 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/bash -### version: 1.9.1 +### version: 1.9.2 # ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.# # Nightscout Mikr.us setup script # @@ -54,8 +54,8 @@ DISK_LOW_MAIL=5184000 # == 60 days in seconds DISK_CRITICAL_WARNING=104857600 # == 100 MiB DISK_CRITICAL_MAIL=604800 # == 7 days in seconds DOCKER_DOWN_MAIL=604800 # == 7 days in seconds -SCRIPT_VERSION="1.9.1" #auto-update -SCRIPT_BUILD_TIME="2024.10.26" #auto-update +SCRIPT_VERSION="1.9.2" #auto-update +SCRIPT_BUILD_TIME="2025.03.13" #auto-update #======================================= # SETUP @@ -940,11 +940,13 @@ setup_firewall() { } >>"$LOGTO" 2>&1 host=$(hostname) - host=${host:1} - - port1=$((10000 + host)) - port2=$((20000 + host)) - port3=$((30000 + host)) + + # Extract the last 3 digits from the hostname + port_number=$(echo "$host" | grep -oE '[0-9]{3}$') + + port1=$((10000 + port_number)) + port2=$((20000 + port_number)) + port3=$((30000 + port_number)) if ufw allow "$port1" >>"$LOGTO" 2>&1; then msgcheck "Do regul firewalla poprawnie dodano port $port1" @@ -1334,15 +1336,15 @@ instal_now_prompt() { } prompt_mikrus_host() { - if ! [[ "$MIKRUS_HOST" =~ [a-z][0-9]{3} ]]; then + if ! [[ "$MIKRUS_HOST" =~ [a-zA-Z]{1,16}[0-9]{3} ]]; then MIKRUS_HOST=$(hostname) while :; do - if [[ "$MIKRUS_HOST" =~ [a-z][0-9]{3} ]]; then + if [[ "$MIKRUS_HOST" =~ [a-zA-Z]{1,16}[0-9]{3} ]]; then break else MIKRUS_NEW_HOST=$(whiptail --title "Podaj identyfikator serwera" --inputbox "\nNie udało się wykryć identyfikatora serwera,\npodaj go poniżej ręcznie.\n\nIdentyfikator składa się z jednej litery i trzech cyfr\n" --cancel-button "Anuluj" 13 65 3>&1 1>&2 2>&3) exit_on_no_cancel - if [[ "$MIKRUS_NEW_HOST" =~ [a-z][0-9]{3} ]]; then + if [[ "$MIKRUS_NEW_HOST" =~ [a-zA-Z]{1,16}[0-9]{3} ]]; then MIKRUS_HOST=$MIKRUS_NEW_HOST break else diff --git a/package.json b/package.json index 92f6d54..57b7669 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dlvoy/ns-installer-mikrus", - "version": "1.9.1", + "version": "1.9.2", "description": "Nightscout installer for mikr.us VPS", "main": "index.js", "scripts": { diff --git a/src/lib.sh b/src/lib.sh index 3fa7bb2..aae1e13 100644 --- a/src/lib.sh +++ b/src/lib.sh @@ -924,11 +924,13 @@ setup_firewall() { } >>"$LOGTO" 2>&1 host=$(hostname) - host=${host:1} - - port1=$((10000 + host)) - port2=$((20000 + host)) - port3=$((30000 + host)) + + # Extract the last 3 digits from the hostname + port_number=$(echo "$host" | grep -oE '[0-9]{3}$') + + port1=$((10000 + port_number)) + port2=$((20000 + port_number)) + port3=$((30000 + port_number)) if ufw allow "$port1" >>"$LOGTO" 2>&1; then msgcheck "Do regul firewalla poprawnie dodano port $port1" @@ -1318,15 +1320,15 @@ instal_now_prompt() { } prompt_mikrus_host() { - if ! [[ "$MIKRUS_HOST" =~ [a-z][0-9]{3} ]]; then + if ! [[ "$MIKRUS_HOST" =~ [a-zA-Z]{1,16}[0-9]{3} ]]; then MIKRUS_HOST=$(hostname) while :; do - if [[ "$MIKRUS_HOST" =~ [a-z][0-9]{3} ]]; then + if [[ "$MIKRUS_HOST" =~ [a-zA-Z]{1,16}[0-9]{3} ]]; then break else MIKRUS_NEW_HOST=$(whiptail --title "Podaj identyfikator serwera" --inputbox "\nNie udało się wykryć identyfikatora serwera,\npodaj go poniżej ręcznie.\n\nIdentyfikator składa się z jednej litery i trzech cyfr\n" --cancel-button "Anuluj" 13 65 3>&1 1>&2 2>&3) exit_on_no_cancel - if [[ "$MIKRUS_NEW_HOST" =~ [a-z][0-9]{3} ]]; then + if [[ "$MIKRUS_NEW_HOST" =~ [a-zA-Z]{1,16}[0-9]{3} ]]; then MIKRUS_HOST=$MIKRUS_NEW_HOST break else diff --git a/src/setup.sh b/src/setup.sh index 68c8a44..6aae908 100755 --- a/src/setup.sh +++ b/src/setup.sh @@ -1,6 +1,6 @@ #!/bin/bash -### version: 1.9.1 +### version: 1.9.2 # ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.# # Nightscout Mikr.us setup script # diff --git a/updated b/updated index 038a788..9e4218e 100644 --- a/updated +++ b/updated @@ -1 +1 @@ -2024-10-26T08:38:49.153Z \ No newline at end of file +2025-03-13T08:16:45.507Z \ No newline at end of file -- 2.38.5 From 538178d92c8639a9feaf60087b010052aadda636 Mon Sep 17 00:00:00 2001 From: Dominik Dzienia Date: Thu, 13 Mar 2025 11:09:14 +0000 Subject: [PATCH 2/4] Another try with diagnostics --- install.sh | 1 + src/lib.sh | 1 + updated | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 50e1bf8..cb43314 100644 --- a/install.sh +++ b/install.sh @@ -2491,6 +2491,7 @@ send_diagnostics() { retry_diagnostics 100 50 "$curr_time" retry_diagnostics 50 50 "$curr_time" retry_diagnostics 50 20 "$curr_time" + retry_diagnostics 20 10 "$curr_time" ohai "Wysyłanie maila" diff --git a/src/lib.sh b/src/lib.sh index aae1e13..365887e 100644 --- a/src/lib.sh +++ b/src/lib.sh @@ -2475,6 +2475,7 @@ send_diagnostics() { retry_diagnostics 100 50 "$curr_time" retry_diagnostics 50 50 "$curr_time" retry_diagnostics 50 20 "$curr_time" + retry_diagnostics 20 10 "$curr_time" ohai "Wysyłanie maila" diff --git a/updated b/updated index 9e4218e..dde7551 100644 --- a/updated +++ b/updated @@ -1 +1 @@ -2025-03-13T08:16:45.507Z \ No newline at end of file +2025-03-13T11:08:36.905Z \ No newline at end of file -- 2.38.5 From eddbefe91961d3c6b1a1968995ae19adbae32c58 Mon Sep 17 00:00:00 2001 From: Dominik Dzienia Date: Thu, 13 Mar 2025 11:20:05 +0000 Subject: [PATCH 3/4] Added limiting of watchdog logs while sending diagnostics --- install.sh | 5 ++--- src/lib.sh | 5 ++--- updated | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index cb43314..c0d0b8f 100644 --- a/install.sh +++ b/install.sh @@ -2403,7 +2403,7 @@ gather_diagnostics() { echo "$LOG_DIVIDER" echo " Watchdog log" echo "$LOG_DIVIDER" - timeout -k 15 10 cat "$WATCHDOG_LOG_FILE" + timeout -k 15 10 tail -n 200 "$WATCHDOG_LOG_FILE" } >>"$SUPPORT_LOG" fi @@ -2412,7 +2412,7 @@ gather_diagnostics() { echo "$LOG_DIVIDER" echo " Watchdog failures log" echo "$LOG_DIVIDER" - timeout -k 15 10 cat "$WATCHDOG_FAILURES_FILE" + timeout -k 15 10 tail -n 200 "$WATCHDOG_FAILURES_FILE" } >>"$SUPPORT_LOG" fi @@ -2491,7 +2491,6 @@ send_diagnostics() { retry_diagnostics 100 50 "$curr_time" retry_diagnostics 50 50 "$curr_time" retry_diagnostics 50 20 "$curr_time" - retry_diagnostics 20 10 "$curr_time" ohai "Wysyłanie maila" diff --git a/src/lib.sh b/src/lib.sh index 365887e..986d047 100644 --- a/src/lib.sh +++ b/src/lib.sh @@ -2387,7 +2387,7 @@ gather_diagnostics() { echo "$LOG_DIVIDER" echo " Watchdog log" echo "$LOG_DIVIDER" - timeout -k 15 10 cat "$WATCHDOG_LOG_FILE" + timeout -k 15 10 tail -n 200 "$WATCHDOG_LOG_FILE" } >>"$SUPPORT_LOG" fi @@ -2396,7 +2396,7 @@ gather_diagnostics() { echo "$LOG_DIVIDER" echo " Watchdog failures log" echo "$LOG_DIVIDER" - timeout -k 15 10 cat "$WATCHDOG_FAILURES_FILE" + timeout -k 15 10 tail -n 200 "$WATCHDOG_FAILURES_FILE" } >>"$SUPPORT_LOG" fi @@ -2475,7 +2475,6 @@ send_diagnostics() { retry_diagnostics 100 50 "$curr_time" retry_diagnostics 50 50 "$curr_time" retry_diagnostics 50 20 "$curr_time" - retry_diagnostics 20 10 "$curr_time" ohai "Wysyłanie maila" diff --git a/updated b/updated index dde7551..558bc78 100644 --- a/updated +++ b/updated @@ -1 +1 @@ -2025-03-13T11:08:36.905Z \ No newline at end of file +2025-03-13T11:19:37.598Z \ No newline at end of file -- 2.38.5 From c7acde04788d37636acd4dd5ae4305b8cec98d19 Mon Sep 17 00:00:00 2001 From: Dominik Dzienia Date: Thu, 13 Mar 2025 13:20:36 +0000 Subject: [PATCH 4/4] Preparing release 1.9.2 --- CHANGELOG.md | 10 ++++++++++ install.sh | 6 +++--- src/lib.sh | 6 +++--- updated | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43d946c..45d426d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.9.2] - 2025-03-13 + +### Changed + +- Adjusted to new mikr.us host naming strategy + +### Fixed + +- Limited of watchdog logs added for diagnostics + ## [1.9.1] - 2024-10-26 ### Added diff --git a/install.sh b/install.sh index c0d0b8f..dcc522c 100644 --- a/install.sh +++ b/install.sh @@ -939,13 +939,13 @@ setup_firewall() { ufw allow ssh } >>"$LOGTO" 2>&1 - host=$(hostname) + host=$(hostname) # Extract the last 3 digits from the hostname port_number=$(echo "$host" | grep -oE '[0-9]{3}$') - port1=$((10000 + port_number)) - port2=$((20000 + port_number)) + port1=$((10000 + port_number)) + port2=$((20000 + port_number)) port3=$((30000 + port_number)) if ufw allow "$port1" >>"$LOGTO" 2>&1; then diff --git a/src/lib.sh b/src/lib.sh index 986d047..2dbd0b2 100644 --- a/src/lib.sh +++ b/src/lib.sh @@ -923,13 +923,13 @@ setup_firewall() { ufw allow ssh } >>"$LOGTO" 2>&1 - host=$(hostname) + host=$(hostname) # Extract the last 3 digits from the hostname port_number=$(echo "$host" | grep -oE '[0-9]{3}$') - port1=$((10000 + port_number)) - port2=$((20000 + port_number)) + port1=$((10000 + port_number)) + port2=$((20000 + port_number)) port3=$((30000 + port_number)) if ufw allow "$port1" >>"$LOGTO" 2>&1; then diff --git a/updated b/updated index 558bc78..317ea8b 100644 --- a/updated +++ b/updated @@ -1 +1 @@ -2025-03-13T11:19:37.598Z \ No newline at end of file +2025-03-13T13:20:10.412Z \ No newline at end of file -- 2.38.5