Script to clear down old microblog entries

Avoids the database growing indefinitely
This commit is contained in:
Bob Mottram 2016-02-04 17:42:17 +00:00
parent 46c07ff82f
commit 677df7c5ee
1 changed files with 9 additions and 0 deletions

View File

@ -8572,6 +8572,15 @@ function install_gnu_social {
fi
echo "GNU Social onion domain:${MICROBLOG_ONION_HOSTNAME}" >> $COMPLETION_FILE
# clear down the database periodically
echo '$n = new Notice();' > /var/www/$MICROBLOG_DOMAIN_NAME/htdocs/clear-database.php
echo "\$n->whereAdd('created < NOW() - INTERVAL 1 YEAR');" >> /var/www/$MICROBLOG_DOMAIN_NAME/htdocs/clear-database.php
echo 'if ($n->find()) { while ($n->fetch()) { $n->deleteAs($n->getProfile()); } }' >> /var/www/$MICROBLOG_DOMAIN_NAME/htdocs/clear-database.php
echo 'exit' >> /var/www/$MICROBLOG_DOMAIN_NAME/htdocs/clear-database.php
echo '#!/bin/bash' > /etc/cron.weekly/clear-microblog-database
echo "cat /var/www/$MICROBLOG_DOMAIN_NAME/htdocs/clear-database.php | php /var/www/$MICROBLOG_DOMAIN_NAME/htdocs/scripts/console.php" >> /etc/cron.weekly/clear-microblog-database
chmod +x /etc/cron.weekly/clear-microblog-database
# some post-install instructions for the user
if ! grep -q $"Microblog administrator" /home/$MY_USERNAME/README; then
echo '' >> /home/$MY_USERNAME/README