Simpler pleroma expire script
This commit is contained in:
parent
0fff1bd21b
commit
58de604cb4
|
@ -90,35 +90,16 @@ function expire_pleroma_posts {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo '<?php' > $pleroma_expire_posts_script
|
echo '#!/bin/bash' > $pleroma_expire_posts_script
|
||||||
echo '' >> $pleroma_expire_posts_script
|
echo 'oldate=$(date +%Y-%m-%d --date="3 months ago")' >> $pleroma_expire_posts_script
|
||||||
echo "\$oldate=date((\"Y-m-d\"), strtotime(\"-${expire_months} months\"));" >> $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 '$username="root";' >> $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 "\$password=shell_exec('${PROJECT_NAME}-pass -u root -a postgresql');" >> $pleroma_expire_posts_script
|
|
||||||
echo "\$database=\"pleroma\";" >> $pleroma_expire_posts_script
|
|
||||||
echo '' >> $pleroma_expire_posts_script
|
|
||||||
echo 'if (!$link = pg_connect("host=localhost dbname=pleroma user=$username password=$password")) {' >> $pleroma_expire_posts_script
|
|
||||||
echo ' echo "Could not connect to postgresql";' >> $pleroma_expire_posts_script
|
|
||||||
echo ' exit;' >> $pleroma_expire_posts_script
|
|
||||||
echo '}' >> $pleroma_expire_posts_script
|
|
||||||
echo '' >> $pleroma_expire_posts_script
|
|
||||||
echo "\$notice_query=\"DELETE FROM notifications WHERE inserted_at <= '\$oldate 01:01:01'\";" >> $pleroma_expire_posts_script
|
|
||||||
echo 'pg_exec($link, $notice_query);' >> $pleroma_expire_posts_script
|
|
||||||
echo '$rowaff1=pg_affected_rows($link);' >> $pleroma_expire_posts_script
|
|
||||||
echo '' >> $pleroma_expire_posts_script
|
|
||||||
echo "\$objects_query=\"DELETE FROM objects WHERE inserted_at <= '\$oldate 01:01:01'\";" >> $pleroma_expire_posts_script
|
|
||||||
echo 'pg_exec($link, $objects_query);' >> $pleroma_expire_posts_script
|
|
||||||
echo '$rowaff2=pg_affected_rows($link);' >> $pleroma_expire_posts_script
|
|
||||||
echo 'pg_close($link);' >> $pleroma_expire_posts_script
|
|
||||||
echo '' >> $pleroma_expire_posts_script
|
|
||||||
echo -n "echo \"Expire pleroma posts: " >> $pleroma_expire_posts_script
|
|
||||||
echo '$rowaff1 notifications and $rowaff2 objects deleted from database.\n";' >> $pleroma_expire_posts_script
|
|
||||||
chmod +x $pleroma_expire_posts_script
|
chmod +x $pleroma_expire_posts_script
|
||||||
|
|
||||||
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 "/usr/bin/php $pleroma_expire_posts_script" >> $pleroma_expire_script
|
echo "$pleroma_expire_posts_script" >> $pleroma_expire_script
|
||||||
chmod +x $pleroma_expire_script
|
chmod +x $pleroma_expire_script
|
||||||
|
|
||||||
# remove any old cron job
|
# remove any old cron job
|
||||||
|
@ -797,7 +778,7 @@ function install_pleroma {
|
||||||
ONION_ONLY='no'
|
ONION_ONLY='no'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
apt-get -yq install wget imagemagick php-pgsql
|
apt-get -yq install wget imagemagick
|
||||||
|
|
||||||
# We need elixir 1.4+ here, so the debian repo package won't do
|
# We need elixir 1.4+ here, so the debian repo package won't do
|
||||||
install_elixir
|
install_elixir
|
||||||
|
|
Loading…
Reference in New Issue