init
This commit is contained in:
parent
92236209d1
commit
e56bea4b0f
4 changed files with 102 additions and 0 deletions
32
cleanup.d/purge_media_cache
Executable file
32
cleanup.d/purge_media_cache
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
token_path="$1"
|
||||
base_url="$2"
|
||||
verbose="true"
|
||||
|
||||
warn() {
|
||||
echo "WARN: $@" >&2
|
||||
}
|
||||
log() {
|
||||
if [[ "$verbose" == "true" ]]; then
|
||||
echo "LOG: $@" >&2
|
||||
fi
|
||||
}
|
||||
invoke_req() {
|
||||
log "invoke curl $@"
|
||||
curl -s --header "@${token_path}" --max-time 600 --connect-timeout 600 $@
|
||||
return $?
|
||||
}
|
||||
|
||||
log "starting media purge - api url: ${base_url}"
|
||||
|
||||
cutoff_ts="$(date -d '-9 months' '+%s')000"
|
||||
|
||||
response="$(invoke_req -X POST --data-raw '{}' "${base_url}v1/purge_media_cache?before_ts=${cutoff_ts}")"
|
||||
rc=$?
|
||||
|
||||
if [[ "$(echo "$response" | jq -r '.deleted')" == "null" ]]; then
|
||||
warn "purge failed: $response"
|
||||
fi
|
||||
|
||||
exit $rc
|
Loading…
Add table
Add a link
Reference in a new issue