File: healthcheck.sh

package info (click to toggle)
golang-github-maxmind-geoipupdate 6.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 376 kB
  • sloc: sh: 99; makefile: 57; perl: 51
file content (18 lines) | stat: -rwxr-xr-x 683 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

set -e

# 2 minutes are added to the update frequency threshold to make room for slower starts.
cutoff_duration=$(($GEOIPUPDATE_FREQUENCY * 60 * 60 + 120))
current_time=$(date +%s)
cutoff_date=$(($current_time - $cutoff_duration))

log_file="/tmp/geoipupdate/.healthcheck"
editions=$(cat "$log_file" | jq -r '.[] | select(.checked_at > '$cutoff_date') | .edition_id')
checked_editions=$(echo "$editions" | wc -l)
desired_editions=$(echo "$GEOIPUPDATE_EDITION_IDS" | awk -F' ' '{print NF}')

if [ "$checked_editions" != "$desired_editions" ]; then
  echo "healtcheck editions number $checked_editions is less than the desired editions number $desired_editions"
  exit 1
fi