From 90f231e59f665a2d3b5547d46bbb6621a780ec95 Mon Sep 17 00:00:00 2001 From: Benoit S Date: Sun, 29 Aug 2021 11:04:02 +0900 Subject: [PATCH 1/5] Missing some default values --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f75084e..40e9539 100644 --- a/README.md +++ b/README.md @@ -44,11 +44,11 @@ and date of expired certificate, default: `1210000`, 2w - `INSTANCE_LAST_CHANCE_TIMEOUT`, integer, timeout in seconds to connect to an instance that was previously not accessible, default: `30` - `MEDIA_REMOVE_DAYS`, integer, how old in days media attachments have to be -before getting removed +before getting removed, default: `7` - `CARDS_REMOVE_DAYS`, integer, how old in days cards previews have to be -before getting removed +before getting removed, default: `15` - `STATUSES_REMOVE_DAYS`, integer, how old in days unreferenced statuses have -to be before getting removed +to be before getting removed, default: `30` Example: From d5c632e74f256da3c2c2ecd15931260a8748ed51 Mon Sep 17 00:00:00 2001 From: Benoit S Date: Thu, 21 Apr 2022 22:15:32 +0900 Subject: [PATCH 2/5] Add test condition when there are no errors Also log unjoinable instances --- tootpaste.sh | 104 +++++++++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 44 deletions(-) diff --git a/tootpaste.sh b/tootpaste.sh index 415f616..42948cc 100644 --- a/tootpaste.sh +++ b/tootpaste.sh @@ -40,52 +40,68 @@ accounts_cull() { # Remove instances that have an expired certificate from more than # TLS_EXPIRED_MAX_SEC - grep 'certificate has expired' "$CULL_LOG" \ - | awk '{print $NF}' \ - | cut -d'/' -f3 \ - | sort -u \ - > "$TLS_EXPIRED_LOG" + if grep -q 'certificate has expired' "$CULL_LOG"; then + grep 'certificate has expired' "$CULL_LOG" \ + | awk '{print $NF}' \ + | cut -d'/' -f3 \ + | sort -u \ + > "$TLS_EXPIRED_LOG" - while read -r instance; do - TLS_EXPIRED_TS=$( - date -d "$( - echo Q \ - | openssl s_client \ - -servername "$instance" \ - -connect "${instance}":443 \ - 2>/dev/null \ - | openssl x509 -noout -dates \ - | grep 'notAfter' \ - | cut -d'=' -f2 - )" +%s - ) - DATE_DIFF=$(($(date +%s) - TLS_EXPIRED_TS)) - if [[ $DATE_DIFF -gt $TLS_EXPIRED_MAX_SEC ]]; then - echo "${instance} has a certificate expired for more than TLS_EXPIRED_MAX_SEC, purging..." - $DRY_RUN \ - && $TOOTCTL domains purge \ - --concurrency "$DB_POOL" \ - --dry-run \ - "$instance" - $DRY_RUN \ - || $TOOTCTL domains purge \ - --concurrency "$DB_POOL" \ - "$instance" - fi - done < "$TLS_EXPIRED_LOG" + while read -r instance; do + TLS_EXPIRED_TS=$( + date -d "$( + echo Q \ + | openssl s_client \ + -servername "$instance" \ + -connect "${instance}":443 \ + 2>/dev/null \ + | openssl x509 -noout -dates \ + | grep 'notAfter' \ + | cut -d'=' -f2 + )" +%s + ) + DATE_DIFF=$(($(date +%s) - TLS_EXPIRED_TS)) + if [[ $DATE_DIFF -gt $TLS_EXPIRED_MAX_SEC ]]; then + echo "${instance} has a certificate expired for more than TLS_EXPIRED_MAX_SEC, purging..." + $DRY_RUN \ + && $TOOTCTL domains purge \ + --concurrency "$DB_POOL" \ + --dry-run \ + "$instance" + $DRY_RUN \ + || $TOOTCTL domains purge \ + --concurrency "$DB_POOL" \ + "$instance" + fi + done < "$TLS_EXPIRED_LOG" + fi - # Log other instances errors, then if they were already in the log, purge - # them - grep \ - -e 'certificate verify failed' \ - -e 'timed out' \ - -e 'sslv3 alert handshake failure' \ - -e 'TooManyRedirectsError' \ - "$CULL_LOG" \ - | awk '{print $NF}' \ - | cut -d'/' -f3 \ - | sort -u \ - > "$OTHER_ERRORS_LOG" + # Log other instances errors, then if they were already in the log, purge them + if grep -q 'https' "$CULL_LOG"; then + grep \ + -e 'certificate verify failed' \ + -e 'timed out' \ + -e 'sslv3 alert handshake failure' \ + -e 'TooManyRedirectsError' \ + -e 'EndlessRedirectError' \ + -e 'HostValidationError' \ + "$CULL_LOG" \ + | awk '{print $NF}' \ + | cut -d'/' -f3 \ + | sort -u \ + > "$OTHER_ERRORS_LOG" + fi + + # Log unjoinable instances, then if they were already in the log, purge them + if grep -q 'not available during the check:' "$CULL_LOG"; then + grep \ + -A 9999 \ + 'not available during the check:' \ + "$CULL_LOG" \ + | tail -n +2 \ + | sed -E 's/\s+//' \ + > "$OTHER_ERRORS_LOG" + fi test -f $PREV_ERRORS_LOG || touch $PREV_ERRORS_LOG while read -r instance; do From a053246f0ec3dbebfbab7e6938f354ed767a9889 Mon Sep 17 00:00:00 2001 From: Benoit S Date: Fri, 22 Apr 2022 17:21:34 +0900 Subject: [PATCH 3/5] Fix #2 silence curl's output --- tootpaste.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tootpaste.sh b/tootpaste.sh index 42948cc..6b76722 100644 --- a/tootpaste.sh +++ b/tootpaste.sh @@ -109,6 +109,7 @@ accounts_cull() { error=false echo "${instance} was already in error last time your ran tootpaste, trying access..." curl \ + --output /dev/null \ --silent \ --show-error \ --max-time "$INSTANCE_LAST_CHANCE_TIMEOUT" \ From dee4adc149837bb9eae14d4708aac3fe5975b144 Mon Sep 17 00:00:00 2001 From: Benoit S Date: Fri, 22 Apr 2022 17:22:02 +0900 Subject: [PATCH 4/5] Add a message when instance can be accessed --- tootpaste.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tootpaste.sh b/tootpaste.sh index 6b76722..1db325f 100644 --- a/tootpaste.sh +++ b/tootpaste.sh @@ -126,6 +126,8 @@ accounts_cull() { || $TOOTCTL domains purge \ --concurrency "$DB_POOL" \ "$instance" + else + echo "${instance} can now be accessed, not purging!" fi fi done < "$OTHER_ERRORS_LOG" From cd1b0f11051c5927603381cb9681720e66db0505 Mon Sep 17 00:00:00 2001 From: Benoit S Date: Fri, 22 Apr 2022 18:32:38 +0900 Subject: [PATCH 5/5] Release 0.2.0 --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f12ccb1..752d25f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed +## [0.2.0] - 2022-04-22 + +### Added + +- Test condition when there are no errors +- Log unjoinable instances +- A message when instance can be accessed + +### Fixed + +- Silence curl's output + ## [0.1.1] - 2021-08-29 ### Added