Scripts to remove blocked domains from gnusocial/postactiv databases
This commit is contained in:
parent
c6eb3de0d1
commit
22fa505a3e
|
@ -503,6 +503,8 @@ function remove_gnusocial {
|
|||
sed -i '/gnusocial/d' $COMPLETION_FILE
|
||||
remove_backup_database_local gnusocial
|
||||
|
||||
sed -i '/gnusocial-firewall/d' /etc/crontab
|
||||
|
||||
function_check remove_ddns_domain
|
||||
remove_ddns_domain $GNUSOCIAL_DOMAIN_NAME
|
||||
}
|
||||
|
@ -761,6 +763,7 @@ function install_gnusocial_main {
|
|||
${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$GNUSOCIAL_DOMAIN_NAME" -g gnusocial --public no
|
||||
|
||||
${PROJECT_NAME}-pass -u $MY_USERNAME -a gnusocial -p "$GNUSOCIAL_ADMIN_PASSWORD"
|
||||
gnusocial_block_domain_script gnusocial
|
||||
|
||||
set_completion_param "gnusocial domain" "$GNUSOCIAL_DOMAIN_NAME"
|
||||
|
||||
|
|
|
@ -496,6 +496,8 @@ function remove_postactiv {
|
|||
sed -i '/postactiv/d' $COMPLETION_FILE
|
||||
remove_backup_database_local postactiv
|
||||
|
||||
sed -i '/postactiv-firewall/d' /etc/crontab
|
||||
|
||||
function_check remove_ddns_domain
|
||||
remove_ddns_domain $POSTACTIV_DOMAIN_NAME
|
||||
}
|
||||
|
@ -758,6 +760,8 @@ function install_postactiv_main {
|
|||
|
||||
${PROJECT_NAME}-pass -u $MY_USERNAME -a postactiv -p "$POSTACTIV_ADMIN_PASSWORD"
|
||||
|
||||
gnusocial_block_domain_script postactiv
|
||||
|
||||
set_completion_param "postactiv domain" "$POSTACTIV_DOMAIN_NAME"
|
||||
|
||||
install_completed postactiv_main
|
||||
|
|
|
@ -275,6 +275,17 @@ function run_query {
|
|||
mysql -u root --password="$MARIADB_PASSWORD" -e "$database_query" $database_name
|
||||
}
|
||||
|
||||
function run_query_with_output {
|
||||
database_name=$1
|
||||
database_query=$2
|
||||
output=$(mysql -u root --password="$MARIADB_PASSWORD" << EOF
|
||||
use $database_name;
|
||||
$database_query
|
||||
EOF
|
||||
)
|
||||
echo "$output"
|
||||
}
|
||||
|
||||
function drop_database {
|
||||
database_name=$1
|
||||
get_mariadb_password
|
||||
|
|
|
@ -327,6 +327,81 @@ function gnusocial_hourly_script {
|
|||
chmod +x /etc/cron.hourly/${gnusocial_type}-daemons
|
||||
}
|
||||
|
||||
function gnusocial_block_domain_script {
|
||||
database_name=$1
|
||||
|
||||
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 "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
|
||||
echo ' echo $"No domain was specified"' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' exit 1' >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'fi' >> /usr/bin/gnusocial-delete-domain
|
||||
echo '' >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'if [[ "$remove_domain" != *"."* ]]; then' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' echo $"This doesnt look like a domain"' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' exit 2' >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'fi' >> /usr/bin/gnusocial-delete-domain
|
||||
echo '' >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'if [ ${#database_name} -lt 2 ]; then' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' echo $"No database was specified"' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' exit 3' >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'fi' >> /usr/bin/gnusocial-delete-domain
|
||||
echo '' >> /usr/bin/gnusocial-delete-domain
|
||||
echo "database_query=\"select profile.id from profile where profileurl like '%\${remove_domain}%';\"" >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'declare -a ids=$(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 '' >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'ctr=0' >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'for id in $ids' >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'do' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' if [ $ctr -gt 0 ]; then' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' echo "Removing user ID $id on $remove_domain"' >> /usr/bin/gnusocial-delete-domain
|
||||
echo '' >> /usr/bin/gnusocial-delete-domain
|
||||
echo " database_query=\"delete from conversation where uri like \"%\${remove_domain}%';\"" >> /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 ' database_query="delete from reply 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
|
||||
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 ' 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
|
||||
echo ' database_query="delete from profile where 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 ' database_query="delete from user where 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 ' fi' >> /usr/bin/gnusocial-delete-domain
|
||||
echo ' ctr=$((ctr + 1))' >> /usr/bin/gnusocial-delete-domain
|
||||
echo 'done' >> /usr/bin/gnusocial-delete-domain
|
||||
chmod +x /usr/bin/gnusocial-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
|
||||
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 ' /usr/bin/gnusocial-delete-domain "$database_name" "$block"' >> /usr/bin/${database_name}-firewall
|
||||
echo 'done <$FIREWALL_DOMAINS' >> /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 expire_gnusocial_posts {
|
||||
domain_name=$1
|
||||
gnusocial_type=$2
|
||||
|
|
Loading…
Reference in New Issue