Simplify expire script

This commit is contained in:
Bob Mottram 2018-01-20 22:27:35 +00:00
parent 9275a6ab84
commit 1197ace0c9
1 changed files with 3 additions and 4 deletions

View File

@ -98,9 +98,8 @@ function expire_pleroma_posts {
echo 'if [[ "$plmonths" == "0" ]]; then' >> $pleroma_expire_posts_script echo 'if [[ "$plmonths" == "0" ]]; then' >> $pleroma_expire_posts_script
echo ' exit 2' >> $pleroma_expire_posts_script echo ' exit 2' >> $pleroma_expire_posts_script
echo 'fi' >> $pleroma_expire_posts_script echo 'fi' >> $pleroma_expire_posts_script
echo -n 'oldate=$(date +%Y-%m-%d --date="' >> $pleroma_expire_posts_script echo 'oldate=$(date +%Y-%m-%d --date="$plmonths months ago")' >> $pleroma_expire_posts_script
echo -n "$PLEROMA_EXPIRE_MONTHS" >> $pleroma_expire_posts_script echo 'cd /etc/postgresql' >> $pleroma_expire_posts_script
echo ' months ago")' >> $pleroma_expire_posts_script
echo "sudo -u postgres psql -d pleroma -c \"DELETE FROM notifications WHERE inserted_at <= '\$oldate 01:01:01'\"" >> $pleroma_expire_posts_script echo "sudo -u postgres psql -d pleroma -c \"DELETE FROM notifications WHERE inserted_at <= '\$oldate 01:01:01'\"" >> $pleroma_expire_posts_script
echo "sudo -u postgres psql -d pleroma -c \"DELETE FROM objects WHERE inserted_at <= '\$oldate 01:01:01'\"" >> $pleroma_expire_posts_script echo "sudo -u postgres psql -d pleroma -c \"DELETE FROM objects WHERE inserted_at <= '\$oldate 01:01:01'\"" >> $pleroma_expire_posts_script
chmod +x $pleroma_expire_posts_script chmod +x $pleroma_expire_posts_script
@ -108,7 +107,7 @@ function expire_pleroma_posts {
pleroma_expire_script=/etc/cron.daily/pleroma-expire pleroma_expire_script=/etc/cron.daily/pleroma-expire
echo '#!/bin/bash' > $pleroma_expire_script echo '#!/bin/bash' > $pleroma_expire_script
echo "find /etc/pleroma/uploads/* -mtime +${expire_days_files} -exec rm -rf {} +" >> $pleroma_expire_script echo "find /etc/pleroma/uploads/* -mtime +${expire_days_files} -exec rm -rf {} +" >> $pleroma_expire_script
echo "$pleroma_expire_posts_script" >> $pleroma_expire_script echo "$pleroma_expire_posts_script 2> /dev/null" >> $pleroma_expire_script
chmod +x $pleroma_expire_script chmod +x $pleroma_expire_script
# remove any old cron job # remove any old cron job