#!/bin/bash

if [ -z "$1" ]; then DIR=$PWD; else DIR=$1; fi # pwd - for development

S3_PREFIX_FILE="$DIR/envdir/WALE_S3_PREFIX"
if ! [ -r $S3_PREFIX_FILE ]; then
    echo "Can not find $S3_PREFIX_FILE"
    exit 1
fi

# WALE_S3_PREFIX:
# s3://mapsdb/wal-g/maps_test_db_um_social/9.5/

PGVERSION=`cut -f6 -d/ $S3_PREFIX_FILE`

find /var/lib/postgresql/$PGVERSION/main/pg_log/* -ctime +40 -delete
