Probably don't need the block script on pleroma because remote content isn't locally cached
This commit is contained in:
parent
4ae5bc3346
commit
fc8d850f4a
|
@ -62,127 +62,6 @@ pleroma_variables=(ONION_ONLY
|
|||
MY_EMAIL_ADDRESS
|
||||
MY_USERNAME)
|
||||
|
||||
function pleroma_block_domain_script {
|
||||
database_name='pleroma'
|
||||
pleroma_domain=$PLEROMA_DOMAIN_NAME
|
||||
|
||||
echo '#!/bin/bash' > /usr/bin/pleroma-delete-domain
|
||||
echo '' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'database_name=$1' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'remove_domain=$2' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'domain_name=$3' >> /usr/bin/pleroma-delete-domain
|
||||
echo "POSTGRESQL_PASSWORD=\$(${PROJECT_NAME}-pass -u root -a pleroma)" >> /usr/bin/pleroma-delete-domain
|
||||
echo '' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'if [ ${#remove_domain} -lt 2 ]; then' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' echo $"No domain was specified"' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' exit 1' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'fi' >> /usr/bin/pleroma-delete-domain
|
||||
echo '' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'if [[ "$remove_domain" != *"."* ]]; then' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' echo $"This doesnt look like a domain"' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' exit 2' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'fi' >> /usr/bin/pleroma-delete-domain
|
||||
echo '' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'if [ ${#database_name} -lt 2 ]; then' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' echo $"No database was specified"' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' exit 3' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'fi' >> /usr/bin/pleroma-delete-domain
|
||||
echo '' >> /usr/bin/pleroma-delete-domain
|
||||
echo "database_query=\"select user_id from profile where profileurl like '%\${remove_domain}%';\"" >> /usr/bin/pleroma-delete-domain
|
||||
echo 'declare -a ids=$(mysql -u root --password="$POSTGRESQL_PASSWORD" << EOF' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'use $database_name;' >> /usr/bin/pleroma-delete-domain
|
||||
echo '$database_query' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'EOF' >> /usr/bin/pleroma-delete-domain
|
||||
echo ')' >> /usr/bin/pleroma-delete-domain
|
||||
echo '' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'ctr=0' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'for id in $ids' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'do' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' if [ $ctr -gt 0 ]; then' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' #echo "Removing user ID $id on $remove_domain"' >> /usr/bin/pleroma-delete-domain
|
||||
echo '' >> /usr/bin/pleroma-delete-domain
|
||||
echo " database_query=\"delete from conversation where uri like '%\${remove_domain}%';\"" >> /usr/bin/pleroma-delete-domain
|
||||
echo ' mysql -u root --password="$POSTGRESQL_PASSWORD" -e "$database_query" $database_name' >> /usr/bin/pleroma-delete-domain
|
||||
echo '' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' database_query="delete from reply where profile_id=${id};"' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' mysql -u root --password="$POSTGRESQL_PASSWORD" -e "$database_query" $database_name' >> /usr/bin/pleroma-delete-domain
|
||||
echo '' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' database_query="delete from reply where replied_id=${id};"' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' mysql -u root --password="$POSTGRESQL_PASSWORD" -e "$database_query" $database_name' >> /usr/bin/pleroma-delete-domain
|
||||
echo '' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' if [ $domain_name ]; then' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' database_query="select rendered from notice where profile_id=${id} and rendered like '"'"'%/file/%'"'"';"' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' declare -a stored_files=$(mysql -u root --password="$POSTGRESQL_PASSWORD" << EOF' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'use $database_name;' >> /usr/bin/pleroma-delete-domain
|
||||
echo '$database_query' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'EOF' >> /usr/bin/pleroma-delete-domain
|
||||
echo ')' >> /usr/bin/pleroma-delete-domain
|
||||
echo -n " files_to_delete=\$(echo \"\$stored_files\" | " >> /usr/bin/pleroma-delete-domain
|
||||
echo 'sed -n '"'"'s/.*href="\([^"]*\).*/\1/p'"'"' | awk -F '"'"'file/'"'"' '"'"'{print $2}'"'"')' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' filectr=0' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' for f in $files_to_delete' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' do' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' if [ $filectr -gt 0 ]; then' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' if $(ls /var/www/${domain_name}/htdocs/file/*${f}* 1> /dev/null 2>&1); then' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' rm /var/www/${domain_name}/htdocs/file/*${f}*' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' fi' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' fi' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' filectr=$((filectr + 1))' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' done' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' fi' >> /usr/bin/pleroma-delete-domain
|
||||
echo '' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' database_query="delete from notice where profile_id=${id};"' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' mysql -u root --password="$POSTGRESQL_PASSWORD" -e "$database_query" $database_name' >> /usr/bin/pleroma-delete-domain
|
||||
echo '' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' database_query="delete from profile where id=${id};"' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' mysql -u root --password="$POSTGRESQL_PASSWORD" -e "$database_query" $database_name' >> /usr/bin/pleroma-delete-domain
|
||||
echo '' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' database_query="delete from qvitternotification where to_profile_id=${id} or from_profile_id=${id};"' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' mysql -u root --password="$POSTGRESQL_PASSWORD" -e "$database_query" $database_name' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' fi' >> /usr/bin/pleroma-delete-domain
|
||||
echo ' ctr=$((ctr + 1))' >> /usr/bin/pleroma-delete-domain
|
||||
echo 'done' >> /usr/bin/pleroma-delete-domain
|
||||
chmod +x /usr/bin/pleroma-delete-domain
|
||||
|
||||
echo '#!/bin/bash' > /usr/bin/${database_name}-firewall
|
||||
echo '' >> /usr/bin/${database_name}-firewall
|
||||
echo "PROJECT_NAME=$PROJECT_NAME" >> /usr/bin/${database_name}-firewall
|
||||
|
||||
if [[ $ONION_ONLY == 'no' ]]; then
|
||||
echo "PLEROMA_DOMAIN_NAME=$PLEROMA_DOMAIN_NAME" >> /usr/bin/${database_name}-firewall
|
||||
else
|
||||
echo "PLEROMA_DOMAIN_NAME=$PLEROMA_ONION_HOSTNAME" >> /usr/bin/${database_name}-firewall
|
||||
fi
|
||||
|
||||
echo "database_name=$database_name" >> /usr/bin/${database_name}-firewall
|
||||
echo 'FIREWALL_DOMAINS=$HOME/${PROJECT_NAME}-firewall-domains.cfg' >> /usr/bin/${database_name}-firewall
|
||||
echo '' >> /usr/bin/${database_name}-firewall
|
||||
echo 'while read block; do' >> /usr/bin/${database_name}-firewall
|
||||
echo ' if [[ "$block" != *"@"* ]]; then' >> /usr/bin/${database_name}-firewall
|
||||
echo ' /usr/bin/pleroma-delete-domain "$database_name" "$block" "$PLEROMA_DOMAIN_NAME"' >> /usr/bin/${database_name}-firewall
|
||||
echo ' else' >> /usr/bin/${database_name}-firewall
|
||||
echo ' /usr/bin/pleroma-delete-user "$database_name" "$block" "$PLEROMA_DOMAIN_NAME"' >> /usr/bin/${database_name}-firewall
|
||||
echo ' fi' >> /usr/bin/${database_name}-firewall
|
||||
echo 'done <$FIREWALL_DOMAINS' >> /usr/bin/${database_name}-firewall
|
||||
echo '' >> /usr/bin/${database_name}-firewall
|
||||
echo '# remove any metadata from images uploaded in the last 2 minutes' >> /usr/bin/${database_name}-firewall
|
||||
echo 'if [ -d /var/www/$PLEROMA_DOMAIN_NAME/htdocs ]; then' >> /usr/bin/${database_name}-firewall
|
||||
echo ' cd /var/www/$PLEROMA_DOMAIN_NAME/htdocs' >> /usr/bin/${database_name}-firewall
|
||||
echo ' declare -a recent_image=$(find file ! -name thumb-* -mmin -2 -type f -exec ls -l {} + | awk -F '"'"'file/'"'"' '"'"'{print $2}'"'"')' >> /usr/bin/${database_name}-firewall
|
||||
echo ' for f in ${recent_image[@]}' >> /usr/bin/${database_name}-firewall
|
||||
echo ' do' >> /usr/bin/${database_name}-firewall
|
||||
echo ' if [ ${#f} -gt 1 ]; then' >> /usr/bin/${database_name}-firewall
|
||||
echo ' exiftool -q -all= "file/${f}"' >> /usr/bin/${database_name}-firewall
|
||||
echo ' fi' >> /usr/bin/${database_name}-firewall
|
||||
echo ' done' >> /usr/bin/${database_name}-firewall
|
||||
echo 'fi' >> /usr/bin/${database_name}-firewall
|
||||
chmod +x /usr/bin/${database_name}-firewall
|
||||
|
||||
if ! grep -q "${database_name}-firewall" /etc/crontab; then
|
||||
echo "*/1 * * * * root /usr/bin/${database_name}-firewall" >> /etc/crontab
|
||||
fi
|
||||
}
|
||||
|
||||
function pleroma_recompile {
|
||||
# necessary after parameter changes
|
||||
sudo -u pleroma mix clean
|
||||
|
|
|
@ -120,7 +120,6 @@ function run_query_postgresql_with_output {
|
|||
database_name=$1
|
||||
database_query=$2
|
||||
output=$(sudo -u postgres psql -d $database_name -c << EOF
|
||||
use $database_name;
|
||||
$database_query
|
||||
EOF
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue