#!/bin/bash cd /opt/strfry STRFRY_POLICY_DIR="/opt/strfry-policies" STRFRY_POLICY_TEMPLATE="$STRFRY_POLICY_DIR/strfry-policy.clean" STRFRY_POLICY_TEMPLATE_TMP="/tmp/strfry-policy.ts" STRFRY_POLICY_FILE="$STRFRY_POLICY_DIR/strfry-policy.ts" TMP_FILE="/tmp/data.tmp" TMP_FILE_FINAL="/tmp/data/final.tmp" cp -f $STRFRY_POLICY_TEMPLATE $STRFRY_POLICY_TEMPLATE_TMP WOT=( 33c74427f3b2b73d5e38f3e6c991c122a55d204072356f71da49a0e209fb6940 82341f882b6eabcd2ba7f1ef90aad961cf074af15b9ef44a09f9d2a8fbfbe6a2 04c915daefee38317fa734444acee390a8269fe5810b2241e5e6dd343dfbecc9 ) function gather(){ echo > /tmp/db.txt local array=() for y in "${WOT[@]}"; do echo nak req -k 3 -a $y wss://poster.place/relay nak req -k 3 -a 33c74427f3b2b73d5e38f3e6c991c122a55d204072356f71da49a0e209fb6940 wss://poster.place/relay | jq | grep "\"" | grep -Evi "\"p\"" | grep -Evi 'tags|pubkey|alt|Follow List|content|sig|kind|id|created' | sed 's/"//g' | sed 's/,//g' > $TMP_FILE NPUBS=( $(cat $TMP_FILE) ) for n in "${NPUBS[@]}"; do if [ ${#n} -ge 64 ]; then nak req -k 3 -a $n wss://poster.place/relay | jq | grep "\"" | grep -Evi "\"p\"" | grep -Evi 'tags|pubkey|alt|Follow List|content|sig|kind|id|created' | sed 's/"//g' | sed 's/,//g' >> $TMP_FILE fi done done } function write(){ cd $STRFRY_POLICY_DIR sed -i "s/////g" $STRFRY_POLICY_TEMPLATE_TMP sed -i '/deno/d' $STRFRY_POLICY_TEMPLATE_TMP sed -i '/#!/a \/\/bin/true; exec deno run -A "$0" "$@"' $STRFRY_POLICY_TEMPLATE_TMP cat $TMP_FILE | sort -u > $TMP_FILE_FINAL readarray -t file_contents < $TMP_FILE_FINAL for elem in "${file_contents[@]}"; do IFS=',' read -ra parts <<< "$elem" for part in "${parts[@]}"; do if [ ${#part} -gt 64 ]; then if [[ $part == *:* ]]; then echo "Skipping" else CLEAN=$(echo $part | sed 's/[[:space:]]*$//' | sed "s/'//g" | sed "s/,//g") sed -i "/\[whitelistPolicy, \[/a\'$CLEAN'," $STRFRY_POLICY_TEMPLATE_TMP echo "'$CLEAN'," fi else echo "Skipping" fi done done sed -i "s/\/\/\[whitelistPolicy/\[whitelistPolicy/" $STRFRY_POLICY_TEMPLATE_TMP sed -i "s/\/\/\]/\]/g" $STRFRY_POLICY_TEMPLATE_TMP cp -f $STRFRY_POLICY_TEMPLATE_TMP $STRFRY_POLICY_FILE } if [ "$1" = "gather" ]; then rm -f $TMP_FILE gather elif [ "$1" = "write" ]; then write else gather write fi