2020-06-01 09:17:44 +00:00
|
|
|
#! /usr/bin/env bash
|
|
|
|
|
|
|
|
set -e # exit on first error
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
2020-11-24 13:51:20 +00:00
|
|
|
echo "Please provide either a skylink or file with skylinks separated by new lines" && exit 1
|
2020-06-01 09:17:44 +00:00
|
|
|
fi
|
|
|
|
|
2020-11-24 11:39:44 +00:00
|
|
|
#########################################################
|
|
|
|
# read either a file containing skylinks separated by new
|
|
|
|
# lines or a single skylink and put them in an array
|
|
|
|
#########################################################
|
|
|
|
skylinks=()
|
|
|
|
if test -f "$1"; then
|
|
|
|
OLDIFS=$IFS
|
|
|
|
IFS=','
|
2020-11-24 14:14:22 +00:00
|
|
|
line_number=1
|
2020-11-24 11:39:44 +00:00
|
|
|
while read line
|
|
|
|
do
|
|
|
|
if [[ $line =~ ([a-zA-Z0-9_-]{46}) ]]; then
|
|
|
|
skylinks+=("$BASH_REMATCH")
|
|
|
|
else
|
2020-11-24 14:14:22 +00:00
|
|
|
echo "Incorrect skylink at line ${line_number}: $line" && exit 1
|
2020-11-24 11:39:44 +00:00
|
|
|
fi
|
2020-11-24 14:14:22 +00:00
|
|
|
let line_number+=1
|
2020-11-24 11:39:44 +00:00
|
|
|
done < $1;
|
|
|
|
IFS=$OLDIFS
|
|
|
|
else
|
|
|
|
skylinks=("$1") # just single skylink passed as input argument
|
|
|
|
fi
|
|
|
|
|
2020-12-03 11:59:50 +00:00
|
|
|
#########################################################################
|
|
|
|
# iterate through all servers, block the skylinks and purge it from cache
|
|
|
|
#########################################################################
|
2020-11-18 15:08:03 +00:00
|
|
|
for server in "germany.siasky.net" "helsinki.siasky.net" "us-west.siasky.net" "us-va-1.siasky.net" "us-pa-1.siasky.net" "us-pa-2.siasky.net" "siasky.xyz";
|
2020-06-01 09:17:44 +00:00
|
|
|
do
|
2020-11-24 11:39:44 +00:00
|
|
|
for skylink in "${skylinks[@]}";
|
|
|
|
do
|
|
|
|
echo ".. ⌁ Blocking skylink ${skylink} on ${server}"
|
|
|
|
|
2020-12-03 11:59:50 +00:00
|
|
|
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-)\""
|
|
|
|
done
|
2020-06-01 09:17:44 +00:00
|
|
|
done
|
|
|
|
|
2020-11-24 11:39:44 +00:00
|
|
|
echo "✓ All done !"
|