Skip to content

Commit

Permalink
Add dehydrated cron output filter script
Browse files Browse the repository at this point in the history
This can be used to filter `dehydrated --cron` output to only contain
error messages. This is the suggested solution from upstream:
dehydrated-io/dehydrated#47 (comment)

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
  • Loading branch information
nicksinger committed Aug 7, 2024
1 parent a8daa4e commit 9674513
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions filter-dehydrated-cron-output
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit 9674513

Please sign in to comment.