From 9674513c004d34ef942fee8f96f3f992224cb5a2 Mon Sep 17 00:00:00 2001 From: nicksinger Date: Wed, 7 Aug 2024 12:29:04 +0200 Subject: [PATCH] Add dehydrated cron output filter script This can be used to filter `dehydrated --cron` output to only contain error messages. This is the suggested solution from upstream: https://github.com/dehydrated-io/dehydrated/issues/47#issuecomment-221867853 Can be tested with: ``` echo "# INFO: Using main config file /etc/dehydrated/config Processing openqa.opensuse.org + Checking domain name(s) of existing cert... unchanged. + Checking expire date of existing cert... + Valid till Oct 17 23:00:12 2024 GMT (Longer than 30 days). Skipping renew!" | ./filter-dehydrated-cron-output ``` Related issue: https://progress.opensuse.org/issues/165027 --- filter-dehydrated-cron-output | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 filter-dehydrated-cron-output diff --git a/filter-dehydrated-cron-output b/filter-dehydrated-cron-output new file mode 100755 index 0000000..0be4670 --- /dev/null +++ b/filter-dehydrated-cron-output @@ -0,0 +1,30 @@ +#!/bin/bash +set -euo pipefail +usage() { + cat << EOF +Usage: dehydrated --cron | $0 [OPTIONS] + +Filter dehydrated cron output to only contain error messages as upstream suggested in +https://github.com/dehydrated-io/dehydrated/issues/47#issuecomment-221867853 + +Options: + -h, --help display this help +EOF + exit "$1" +} +main() { + opts=$(getopt -o h -l help -n "$0" -- "$@") || usage 1 + eval set -- "$opts" + while true; do + case "$1" in + -h | --help) usage 0 ;; + --) + shift + break + ;; + *) break ;; + esac + done + grep -v "^# INFO" | perl -0pe "s/Processing (.*)*\n \+ (.*)unchanged.\n \+ Checking .*\.\.\.\n \+ Valid till (.*) \(Longer than .* Skipping renew!//gm" | grep -v "^$" +} +caller 0 > /dev/null || main "$@"