Files
daniel c835954f5d Update mastodon.sh
adding required lines for running the script as a cronjob
2026-10-15 05:11:36 +00:00

51 lines
1.7 KiB
Bash

#!/bin/bash
#written by Daniel Wenzlik 2024 - https://danielwenzlik.com
#modified by Daniel Wenzlik 2026 - https://danielwenzlik.com
#Script under the GNU AGPLv3 license.
# making rbenv/Ruby accessible for the user/script
export HOME="/home/mastodon"
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:/usr/local/bin:/usr/bin:/bin"
# initialise rbenv
eval "$("$HOME/.rbenv/bin/rbenv" init - bash)"
#using the correct directory
echo "Navigating to the Mastodon Directory now";
cd /home/mastodon/live/;
export RAILS_ENV=production
#deleting cache files
echo "Clearing cache";
RAILS_ENV=production /home/mastodon/live/bin/tootctl cache clear;
# Prune remote accounts that never interacted with a local user
echo "Prune local accounts";
RAILS_ENV=production /home/mastodon/live/bin/tootctl accounts prune;
# Remove remote statuses that local users never interacted with older than 1 day
echo "Remove remote statuses older than 1 day";
RAILS_ENV=production /home/mastodon/live/bin/tootctl statuses remove --days=1;
# Remove media attachments older than 1 day
echo "Remove media attachments older than 1 day";
RAILS_ENV=production /home/mastodon/live/bin/tootctl media remove --days=1;
# Remove all headers
echo "Remove all headers";
RAILS_ENV=production /home/mastodon/live/bin/tootctl media remove --remove-headers --include-follows --days=0;
# Remove link previews older than 1 day
echo "Remove link previews older than 1 day";
RAILS_ENV=production /home/mastodon/live/bin/tootctl preview_cards remove --days=1;
# Remove files not linked to any post
echo "Remove files not linked to any post";
RAILS_ENV=production /home/mastodon/live/bin/tootctl media remove-orphans;
#finishing script
echo "Done.";
exit 0;