Skip to content

Instantly share code, notes, and snippets.

@Macht59
Created October 2, 2021 22:24
Show Gist options
  • Select an option

  • Save Macht59/ae0aaddbb25e2e1f3020a70a9c9848c1 to your computer and use it in GitHub Desktop.

Select an option

Save Macht59/ae0aaddbb25e2e1f3020a70a9c9848c1 to your computer and use it in GitHub Desktop.
Removes invalid chia plots
#!/bin/bash
PLOT_DIR=/home/chia
LOG_FILE=/home/chia/debug.log
#DEBUG=1
if [ $DEBUG ]
then
echo "Debug mode enabled"
echo "PLOT_DIR = " $PLOT_DIR
echo "LOG_FILE = " $LOG_FILE
fi
echo "Request harvester for plots"
PLOTS_JSON=$(curl up --insecure --cert ~/.chia/mainnet/config/ssl/harvester/private_harvester.crt --key ~/.chia/mainnet/config/ssl/harvester/private_harvester.key -d '{"":""}' -H "Content-Type: application/json" -X POST https://localhost:8560/get_plots | python3 -m json.tool)
for plot in $(echo "${PLOTS_JSON}" | jq -c ".plots[]"); do
# echo $plot
PPK=$(echo "$plot" | jq -r ".plot_public_key")
echo "Plot public key: " $PPK
if grep -q "$PPK" "$LOG_FILE";
then
echo "Found error lines for plot " $filename
FILE_NAME=$(echo "$plot" | jq -r ".filename")
if ! [ $DEBUG ]
then
echo "Delete " $FILE_NAME
rm $FILE_NAME
else
echo "Would delete " $FILE_NAME
fi
else
echo "Didn't find any errors. Will not do anything for current plot."
fi
echo ""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment