From f0434da421b8ef41ec8110dab708a689badc5620 Mon Sep 17 00:00:00 2001 From: Matthew Sevey Date: Mon, 26 Jul 2021 16:03:49 -0400 Subject: [PATCH 1/2] Fix server list and use common NGINX command --- scripts/blocklist-skylink.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/blocklist-skylink.sh b/scripts/blocklist-skylink.sh index 23ab500c..15e7d003 100755 --- a/scripts/blocklist-skylink.sh +++ b/scripts/blocklist-skylink.sh @@ -1,5 +1,10 @@ #! /usr/bin/env bash +# This script is meant to be used when manually adding a skylink to the +# blocklist on all the skynet web portals. The automatic script that is used to +# continuously sync a google sheets list with the blocklist on the web portals +# is /setup-scripts/blocklist-airtable.py + set -e # exit on first error if [ -z "$1" ]; then @@ -32,21 +37,23 @@ fi ######################################################################### # iterate through all servers, block the skylinks and purge it from cache ######################################################################### -declare -a servers=( "eu-ger-1.siasky.net" "eu-ger-2.siasky.net" "eu-ger-3.siasky.net" "eu-ger-4.siasky.net" "eu-ger-5.siasky.net" "eu-ger-6.siasky.net" "eu-ger-7.siasky.net" "eu-ger-8siasky.net" +declare -a servers=( "eu-ger-1.siasky.net" "eu-ger-2.siasky.net" "eu-ger-3.siasky.net" "eu-ger-4.siasky.net" "eu-ger-5.siasky.net" "eu-ger-6.siasky.net" "eu-ger-7.siasky.net" "eu-ger-8.siasky.net" "eu-fin-1.siasky.net" "eu-fin-2.siasky.net" "eu-fin-3.siasky.net" "eu-fin-4.siasky.net" "eu-pol-1.siasky.net" "eu-pol-2.siasky.net" "eu-pol-3.siasky.net" "us-or-1.siasky.net" "us-or-2.siasky.net" "us-pa-1.siasky.net" "us-pa-2.siasky.net" "us-va-1.siasky.net" "us-va-2.siasky.net" "us-va-3.siasky.net" "as-hk-1.siasky.net" - "siasky.xyz" "siasky.dev") + "siasky.xyz" "dev1.siasky.dev" "dev2.siasky.dev" "dev3.siasky.dev") for server in "${servers[@]}"; do for skylink in "${skylinks[@]}"; do echo ".. ⌁ Blocking skylink ${skylink} on ${server}" - - ssh -q -t user@${server} "docker exec sia siac skynet blocklist add $skylink && docker exec nginx curl -s -i -X PURGE http://localhost/$skylink | egrep \"^(OK|HTTP|X-)\"" + cached_files_command="find /data/nginx/cache/ -type f | xargs --no-run-if-empty grep -Elsq '^Skynet-Skylink: ${skylink}'" + ssh -q -t user@${server} "docker exec -it nginx bash -c ${cached_files_command} | xargs -r rm" + echo ".. ⌁ Skylink ${skylink} Blocked on ${server}" + echo "--------------------------------------------" done done From e5fb26ca95fe6fd39bbdf81bc9573725b7abb97c Mon Sep 17 00:00:00 2001 From: Matthew Sevey Date: Tue, 27 Jul 2021 10:33:20 -0400 Subject: [PATCH 2/2] replace --no-run-if-empty with -r MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Karol Wypchło --- scripts/blocklist-skylink.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/blocklist-skylink.sh b/scripts/blocklist-skylink.sh index 15e7d003..80885b14 100755 --- a/scripts/blocklist-skylink.sh +++ b/scripts/blocklist-skylink.sh @@ -50,7 +50,7 @@ do for skylink in "${skylinks[@]}"; do echo ".. ⌁ Blocking skylink ${skylink} on ${server}" - cached_files_command="find /data/nginx/cache/ -type f | xargs --no-run-if-empty grep -Elsq '^Skynet-Skylink: ${skylink}'" + cached_files_command="find /data/nginx/cache/ -type f | xargs -r grep -Elsq '^Skynet-Skylink: ${skylink}'" ssh -q -t user@${server} "docker exec -it nginx bash -c ${cached_files_command} | xargs -r rm" echo ".. ⌁ Skylink ${skylink} Blocked on ${server}" echo "--------------------------------------------"