#!/bin/bash

day="$(date +%d)"
month="$(date +%m)"

mm3=$((month % 3))
echo $day $month $mm3

cd ~pleroma
bin/pleroma_ctl database prune_objects --keep-threads --keep-non-public --prune-orphaned-activities

#if [ "$day" = 2 ] && [ "$mm3" = 0 ]; then
if [ "$day" = "03" ]; then
 echo vacuum time!
 bin/pleroma_ctl database vacuum full
else
 echo vacuum analyze time!
 bin/pleroma_ctl database vacuum analyze
fi

systemctl restart pleroma
