Remove gnusocial files associated with blocked domains or users
This commit is contained in:
parent
7b2366891c
commit
f483e4d488
|
@ -368,6 +368,7 @@ function gnusocial_block_user_script {
|
|||
echo '' >> /usr/bin/gnusocial-delete-user
|
||||
echo 'database_name=$1' >> /usr/bin/gnusocial-delete-user
|
||||
echo 'remove_user=$2' >> /usr/bin/gnusocial-delete-user
|
||||
echo 'domain_name=$3' >> /usr/bin/gnusocial-delete-user
|
||||
echo 'MARIADB_PASSWORD=$(freedombone-pass -u root -a mariadb)' >> /usr/bin/gnusocial-delete-user
|
||||
echo '' >> /usr/bin/gnusocial-delete-user
|
||||
echo 'if [ ${#remove_user} -lt 2 ]; then' >> /usr/bin/gnusocial-delete-user
|
||||
|
@ -407,6 +408,27 @@ function gnusocial_block_user_script {
|
|||
echo ' database_query="delete from reply where replied_id=${id};"' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' mysql -u root --password="$MARIADB_PASSWORD" -e "$database_query" $database_name' >> /usr/bin/gnusocial-delete-user
|
||||
echo '' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' if [ $domain_name ]; then' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' database_query="select rendered from notice where profile_id=${id} and rendered like '"'"'%/file/%'"'"';"' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' declare -a stored_files=$(mysql -u root --password="$MARIADB_PASSWORD" << EOF' >> /usr/bin/gnusocial-delete-user
|
||||
echo 'use $database_name;' >> /usr/bin/gnusocial-delete-user
|
||||
echo '$database_query' >> /usr/bin/gnusocial-delete-user
|
||||
echo 'EOF' >> /usr/bin/gnusocial-delete-user
|
||||
echo ')' >> /usr/bin/gnusocial-delete-user
|
||||
echo -n " files_to_delete=\$(echo \"\$stored_files\" | " >> /usr/bin/gnusocial-delete-user
|
||||
echo 'sed -n '"'"'s/.*href="\([^"]*\).*/\1/p'"'"' | awk -F '"'"'file/'"'"' '"'"'{print $2}'"'"')' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' filectr=0' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' for f in $files_to_delete' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' do' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' if [ $filectr -gt 0 ]; then' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' if [ -f /var/www/${domain_name}/htdocs/file/${f} ]; then' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' rm /var/www/${domain_name}/htdocs/file/${f}' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' fi' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' fi' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' filectr=$((filectr + 1))' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' done' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' fi' >> /usr/bin/gnusocial-delete-user
|
||||
echo '' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' database_query="delete from notice where profile_id=${id};"' >> /usr/bin/gnusocial-delete-user
|
||||
echo ' mysql -u root --password="$MARIADB_PASSWORD" -e "$database_query" $database_name' >> /usr/bin/gnusocial-delete-user
|
||||
echo '' >> /usr/bin/gnusocial-delete-user
|
||||
|
@ -423,11 +445,13 @@ function gnusocial_block_user_script {
|
|||
|
||||
function gnusocial_block_domain_script {
|
||||
database_name=$1
|
||||
gnusoc_domain=$2
|
||||
|
||||
echo '#!/bin/bash' > /usr/bin/gnusocial-delete-domain
|
||||
echo '' >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'database_name=$1' >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'remove_domain=$2' >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'domain_name=$3' >> /usr/bin/gnusocial-delete-domain
|
||||
echo "MARIADB_PASSWORD=\$(${PROJECT_NAME}-pass -u root -a mariadb)" >> /usr/bin/gnusocial-delete-domain
|
||||
echo '' >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'if [ ${#remove_domain} -lt 2 ]; then' >> /usr/bin/gnusocial-delete-domain
|
||||
|
@ -467,6 +491,27 @@ function gnusocial_block_domain_script {
|
|||
echo ' database_query="delete from reply where replied_id=${id};"' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' mysql -u root --password="$MARIADB_PASSWORD" -e "$database_query" $database_name' >> /usr/bin/gnusocial-delete-domain
|
||||
echo '' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' if [ $domain_name ]; then' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' database_query="select rendered from notice where profile_id=${id} and rendered like '"'"'%/file/%'"'"';"' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' declare -a stored_files=$(mysql -u root --password="$MARIADB_PASSWORD" << EOF' >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'use $database_name;' >> /usr/bin/gnusocial-delete-domain
|
||||
echo '$database_query' >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'EOF' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ')' >> /usr/bin/gnusocial-delete-domain
|
||||
echo -n " files_to_delete=\$(echo \"\$stored_files\" | " >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'sed -n '"'"'s/.*href="\([^"]*\).*/\1/p'"'"' | awk -F '"'"'file/'"'"' '"'"'{print $2}'"'"')' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' filectr=0' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' for f in $files_to_delete' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' do' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' if [ $filectr -gt 0 ]; then' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' if [ -f /var/www/${domain_name}/htdocs/file/${f} ]; then' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' rm /var/www/${domain_name}/htdocs/file/${f}' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' fi' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' fi' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' filectr=$((filectr + 1))' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' done' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' fi' >> /usr/bin/gnusocial-delete-domain
|
||||
echo '' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' database_query="delete from notice where profile_id=${id};"' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' mysql -u root --password="$MARIADB_PASSWORD" -e "$database_query" $database_name' >> /usr/bin/gnusocial-delete-domain
|
||||
echo '' >> /usr/bin/gnusocial-delete-domain
|
||||
|
@ -483,14 +528,15 @@ function gnusocial_block_domain_script {
|
|||
echo '#!/bin/bash' > /usr/bin/${database_name}-firewall
|
||||
echo '' >> /usr/bin/${database_name}-firewall
|
||||
echo "PROJECT_NAME=$PROJECT_NAME" >> /usr/bin/${database_name}-firewall
|
||||
echo "GNUSOCIAL_DOMAIN_NAME=$gnusoc_domain" >> /usr/bin/${database_name}-firewall
|
||||
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/gnusocial-delete-domain "$database_name" "$block"' >> /usr/bin/${database_name}-firewall
|
||||
echo ' /usr/bin/gnusocial-delete-domain "$database_name" "$block" "$GNUSOCIAL_DOMAIN_NAME"' >> /usr/bin/${database_name}-firewall
|
||||
echo ' else' >> /usr/bin/${database_name}-firewall
|
||||
echo ' /usr/bin/gnusocial-delete-user "$database_name" "$block"' >> /usr/bin/${database_name}-firewall
|
||||
echo ' /usr/bin/gnusocial-delete-user "$database_name" "$block" "$GNUSOCIAL_DOMAIN_NAME"' >> /usr/bin/${database_name}-firewall
|
||||
echo ' fi' >> /usr/bin/${database_name}-firewall
|
||||
echo 'done <$FIREWALL_DOMAINS' >> /usr/bin/${database_name}-firewall
|
||||
chmod +x /usr/bin/${database_name}-firewall
|
||||
|
|
Loading…
Reference in New Issue