-
Notifications
You must be signed in to change notification settings - Fork 8
/
forkaddplotdirsq
71 lines (65 loc) · 2.44 KB
/
forkaddplotdirsq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! /usr/bin/env bash
function print_usage () {
echo "forkaddplotdirs help:"
echo
echo "SYNOPSIS: Runs 'forkname plots add -d directoryname' for each entry in 'ftconfigs/config.forkaddplotdirs'"
echo " forkaddplotdirs now supports fork specific configurations. For example, if you have a different"
echo " list of plot directories for chives, copy your 'config.forkaddplotdirs' to 'config.forkaddplotdirs.chives'"
echo " in the ftconfigs folder, then edit the chives version to list only your chives plot directories."
echo " Restarting the fork(s) with forkstart after running this script is recommended to ensure the new"
echo " directories are loaded immediately."
echo
echo "PARAMETERS:"
echo " forkname | all Required. Runs for the specified fork, or all forks with a -blockchain directory"
echo " and a config.yaml in the fork's hidden directory."
echo " -help | --help Show this information again."
echo
exit 0
}
if [[ $1 != 'all' ]]; then
VALIDATEFORKNAME='Yes'
fi
. ftinit.sh
if [[ $3 != '' ]]; then
echo "forkaddplotdirs: Too many specified parameters."
print_usage
fi
if [[ $1 == 'all' ]]; then
cd $FORKTOOLSBLOCKCHAINDIRS
FORKLIST=$( ls -d1 *-blockchain | sed 's/-blockchain//' )
else
FORKLIST=$1
fi
OLDIFS=$IFS
IFS=$'\n'
for fork in $FORKLIST; do
if [[ $1 != 'all' && $1 != $fork ]]; then
continue
fi
if [[ -f $FORKTOOLSDIR/ftconfigs/config.forkaddplotdirs.$fork ]]; then
. $FORKTOOLSDIR/ftconfigs/config.forkaddplotdirs.$fork
else
. $FORKTOOLSDIR/ftconfigs/config.forkaddplotdirs
fi
CURRENTCONFIG=$FORKTOOLSHIDDENDIRS/.$fork/mainnet/config/config.yaml
if [[ ! -f $CURRENTCONFIG ]]; then
echo "Configuration file for $fork not found. Skipping..."
continue
fi
cd $FORKTOOLSBLOCKCHAINDIRS/$fork-blockchain
. ./activate
for plotdir in $FORKADDPLOTDIRS; do
STRIPPEDCOMMENTS=$(sed 's/#.*//' <<< "$plotdir" | awk '{$1=$1};1' )
if [ -n "$STRIPPEDCOMMENTS" ]; then
BUILDEXPR=$(echo "$fork plots add -d '$STRIPPEDCOMMENTS'")
echo 'forkaddplotdirs running: ' $BUILDEXPR
if [[ ( ! -d "$STRIPPEDCOMMENTS" ) ]]; then
echo -e "\e[1;31m WARNING: \e[0m $STRIPPEDCOMMENTS is not a mounted directory. \e[1;31m :WARNING \e[0m"
fi
echo $(eval $BUILDEXPR)
fi
done
deactivate
done
IFS=$OLDIFS
echo