Updating pleroma filtering scripts

This commit is contained in:
Bob Mottram 2018-04-25 15:05:23 +01:00
parent b535fb9b97
commit 5c656e0c16
1 changed files with 21 additions and 0 deletions

View File

@ -108,6 +108,7 @@ function create_pleroma_blocklist {
echo 'users_query="DELETE FROM users WHERE"'; echo 'users_query="DELETE FROM users WHERE"';
echo 'websub_server_subscriptions_query="DELETE FROM websub_server_subscriptions WHERE"'; echo 'websub_server_subscriptions_query="DELETE FROM websub_server_subscriptions WHERE"';
echo 'websub_server_subscriptions_updated='; echo 'websub_server_subscriptions_updated=';
echo 'filter_str=';
echo 'while read blocked; do'; echo 'while read blocked; do';
echo " if [[ \"\$blocked\" == *\".\"* || \"\$blocked\" == *\"@\"* ]]; then"; echo " if [[ \"\$blocked\" == *\".\"* || \"\$blocked\" == *\"@\"* ]]; then";
echo " if [ \${#blocked} -gt 4 ]; then"; echo " if [ \${#blocked} -gt 4 ]; then";
@ -119,6 +120,13 @@ function create_pleroma_blocklist {
echo " users_query=\"\${users_query} nickname ilike '%\${blocked}%'\""; echo " users_query=\"\${users_query} nickname ilike '%\${blocked}%'\"";
echo ' objects_updated=1'; echo ' objects_updated=1';
echo " if [[ \"\$blocked\" != *\"@\"* ]]; then"; echo " if [[ \"\$blocked\" != *\"@\"* ]]; then";
echo ' # Create a filter string for the pleroma configuration';
echo " if [ \"\$filter_str\" ]; then";
echo " filter_str=\"\${filter_str}, \\\"\$blocked\\\"\"";
echo ' else';
echo " filter_str=\"\${blocked}\"";
echo ' fi';
echo '';
echo " if ! grep -q \"127.0.0.1 \$blocked\" /etc/hosts; then"; echo " if ! grep -q \"127.0.0.1 \$blocked\" /etc/hosts; then";
echo " echo \"127.0.0.1 \$blocked\" >> /etc/hosts"; echo " echo \"127.0.0.1 \$blocked\" >> /etc/hosts";
echo ' fi'; echo ' fi';
@ -132,6 +140,19 @@ function create_pleroma_blocklist {
echo ' fi'; echo ' fi';
echo 'done </root/freedombone-firewall-domains.cfg'; echo 'done </root/freedombone-firewall-domains.cfg';
echo ''; echo '';
echo "if [ \"\$filter_str\" ]; then";
echo " if ! grep -q \" \$filter_str \" $pleroma_secret; then";
echo " sed -i \"s|media_removal:.*|media_removal: [ \$filter_str ],|g\" $pleroma_secret";
echo " sed -i \"s|federated_timeline_removal:.*|federated_timeline_removal: [ \$filter_str ],|g\" $pleroma_secret";
echo " sed -i \"s|removal:.*|removal: [ \$filter_str ]|g\" $pleroma_secret";
echo " chown -R pleroma:pleroma $PLEROMA_DIR";
echo ' sudo -u pleroma mix clean';
echo ' sudo -u pleroma mix deps.compile';
echo ' sudo -u pleroma mix compile';
echo ' systemctl restart pleroma';
echo ' fi';
echo 'fi';
echo '';
echo 'cd /etc/postgresql'; echo 'cd /etc/postgresql';
echo "if [ \$objects_updated ]; then"; echo "if [ \$objects_updated ]; then";
echo " sudo -u postgres psql -d pleroma -c \"\$objects_query\""; echo " sudo -u postgres psql -d pleroma -c \"\$objects_query\"";