diff --git a/README.md b/README.md index 3a9d02c..b658a20 100644 --- a/README.md +++ b/README.md @@ -77,10 +77,9 @@ If `MF_DEBUG` is set to `1`, `miniflux-filter` will print extra output to stdou | RC | Description | | --- | ------------------------------- | -| 1 | `$MF_FILTERLIST_FILE` not found | +| 1 | `$MF_FILTERLIST` not set | | 2 | `$MF_AUTH_TOKEN` not set | | 3 | `$MF_API_URL` not set | -| 4 | `$MF_FILTERLIST_FILE` is a dir | | 5 | `jq` is not installed | | 6 | `curl` is not installed | | 7 | could not connect to `miniflux` | diff --git a/filter.sh b/filter.sh index c8f585b..636287d 100755 --- a/filter.sh +++ b/filter.sh @@ -5,8 +5,6 @@ if [[ $MF_DEBUG -eq 1 ]]; then printf "miniflux-filter - git.mgrote.net/mg/miniflux-filter\n" fi -### datei mit filter ausdruecken -MF_FILTERLIST_FILE="${MF_FILTERLIST_FILE:=/data/filter.txt}" ### wartezeit zwischen durchlaeufen MF_SLEEP="${MF_SLEEP:=30}" ### MF_DEBUG output @@ -84,17 +82,11 @@ function check_vars { echo [ERROR] '"$MF_API_URL"' not set. exit 3 fi - # prüfe ob filter-datei ein ordner ist - # kann bei einem falschen bind-mount passieren - if [[ -d "$MF_FILTERLIST_FILE" ]]; then - # shellcheck disable=SC2102 - echo [ERROR] "$MF_FILTERLIST_FILE" is a directory! - exit 4 - fi # pruefe ob filter-datei NICHT existiert - if [[ ! -e "$MF_FILTERLIST_FILE" ]]; then + if [[ -z "${MF_FILTERLIST}" ]]; then + # shellcheck disable=SC2016 # shellcheck disable=SC2102 - echo [ERROR] "$MF_FILTERLIST_FILE" not readable! + echo [ERROR] '"$MF_FILTERLIST"' not set. exit 1 fi } @@ -142,11 +134,10 @@ function check_api_connectivity { function debug_output { if [[ $MF_DEBUG -eq 1 ]]; then echo ----------------------------------------------------- - echo [DEBUG] Filterlist-File: "$MF_FILTERLIST_FILE" echo [DEBUG] Sleep-Intervall: "$MF_SLEEP" echo [DEBUG] Auth-Token: "$MF_AUTH_TOKEN" echo [DEBUG] MF-Url: "$MF_API_URL" - echo [DEBUG] Anzahl Filter: "$(wc -l < "$MF_FILTERLIST_FILE")" + echo [DEBUG] Anzahl Filter: "$(wc -l < "$MF_FILTERLIST")" echo ----------------------------------------------------- fi } @@ -165,7 +156,7 @@ function get_unread_entries { } function filter_entries { echo "[INFO] Filtering entries..." - # fuer jede Zeile in $MF_FILTERLIST_FILE + # fuer jede Zeile in $MF_FILTERLIST while read -r line; do if [[ $MF_DEBUG -eq 1 ]]; then echo "[DEBUG] set search values" @@ -194,7 +185,7 @@ function filter_entries { marked_entries+=" $(echo "$unread_entries" | jq --arg url "$url" --arg suchbegriff "$suchbegriff" '.entries[] | select(.feed.site_url | ascii_downcase | contains($url)) | select(.content | ascii_downcase | contains($suchbegriff)) | .id' )" fi fi - done < "$MF_FILTERLIST_FILE" + done < "$MF_FILTERLIST" } function mark_as_read { # https://stackoverflow.com/questions/3869072/test-for-non-zero-length-string-in-bash-n-var-or-var