Last active
July 30, 2021 20:09
-
-
Save TimoPtr/684bde624c8923177e67964ca924a8de to your computer and use it in GitHub Desktop.
This script is meant to be used to replot chia plot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://github.com/anordal/shellharden/blob/master/how_to_do_things_safely_in_bash.md#how-to-begin-a-bash-script | |
set -e # stop the script if any command has non-zero exit status | |
set -u # throws an error if a variable is not defined | |
set -o pipefail # returns an error if any command fails in a pipe | |
shopt -s nullglob globstar # enables empty glob results and recursive globbing | |
# list of disk where there are plots to replace | |
DISK_ROOT_PATHS=("/media/timo/WD1") | |
# folder in DISK_ROOT_PATHS that contains plots to replace | |
OG_PLOTS_FOLDER="plots" | |
# folder where to put the new plots | |
PORTABLE_PLOTS_FOLDER="portablePlots" | |
# chia_plot config | |
CHIA_PLOT_PATH="/home/timo/Perso/chia-plotter/build/chia_plot" | |
TMP_FOLDER="/media/timo/ST2/tmp/" # tmp folder used by the plotter | |
TMP2_FOLDER="/mnt/ram/" # should be ram disk | |
DESTINATION_FOLDER="/media/timo/ST2/buffer/" # folder where to put the final plots before moving them | |
FARMER_KEY="" # -f | |
CONTRACT="" # -c | |
THREAD_MULTIPLIER=4 # -r | |
THREAD_MULTIPLIER2=2 # -K | |
BUCKET_1_2=512 # -u | |
BUCKET_3_4=128 # -v | |
function plot() { | |
"${CHIA_PLOT_PATH}" \ | |
-f "${FARMER_KEY}" \ | |
-c "${CONTRACT}" \ | |
-t "${TMP_FOLDER}" \ | |
-2 "${TMP2_FOLDER}" \ | |
-d "${DESTINATION_FOLDER}" \ | |
-r "${THREAD_MULTIPLIER}" \ | |
-K "${THREAD_MULTIPLIER2}" \ | |
-u "${BUCKET_1_2}" \ | |
-v "${BUCKET_3_4}" | |
} | |
for index in "${!DISK_ROOT_PATHS[@]}"; do | |
DISK_ROOT_PATH="${DISK_ROOT_PATHS[index]}" | |
OG_PLOTS_FOLDER_PATH="${DISK_ROOT_PATH}/${OG_PLOTS_FOLDER}/" | |
PORTABLE_PLOTS_FOLDER_PATH="${DISK_ROOT_PATH}/${PORTABLE_PLOTS_FOLDER}/" | |
echo "Re plots k32 from $OG_PLOTS_FOLDER_PATH to $PORTABLE_PLOTS_FOLDER_PATH using nft" | |
find "${OG_PLOTS_FOLDER_PATH}" -name '*k32*' | while read -r og_plot; do | |
echo "plot in $DESTINATION_FOLDER" | |
plot | |
echo "remove $og_plot" | |
rm "$og_plot" | |
echo "move generated plot to ${PORTABLE_PLOTS_FOLDER_PATH}" | |
rsync --remove-source-files --progress --preallocate "${DESTINATION_FOLDER}"* "${PORTABLE_PLOTS_FOLDER_PATH}" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I made it a bit different. I can run the same script from multiple sources to replot on different NFS shares like this;
It would be nice also, after the script is done, to check how many disk space there is and to plot the additional free disk space.