forked from webworker01/knomp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gencfg.sh
executable file
·85 lines (67 loc) · 2.33 KB
/
gencfg.sh
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
# Put the address to mine to here
walletaddress=
#Change to path of komodo-cli here
komodoexec=~/komodo/src/komodo-cli
# Any coins you would like to skip go here
declare -a skip=("BEER" "PIZZA")
# Stratum port to start with
stratumport=3030
cli="komodo-cli"
coinsdir=./coins
poolconfigdir=./pool_configs
coinstpl=coins.template
pooltpl=poolconfigs.template
ufwenablefile=stratufwenable
ufwdisablefile=stratufwdisable
cointemplate=$(<$coinstpl)
pooltemplate=$(<$pooltpl)
mkdir -p $coinsdir
mkdir -p $poolconfigdir
#clean old up
if [ -f $ufwenablefile ]; then
rm $ufwenablefile
fi
if [ -f $ufwdisablefile ]; then
rm $ufwdisablefile
fi
if [[ -z $1 ]]; then
specificchain=0
else
specificchain=$1
fi
listassetchains () {
if [[ $specificchain = "0" ]]; then
~/komodo/src/listassetchains
else
echo $specificchain
fi
}
listassetchains | while read chain; do
if [[ " ${skip[@]} " =~ " ${chain} " ]]; then
pointless=0
else
echo "[$chain] Generating config files"
getinfo=$(${cli} -ac_name=$chain getinfo 2>/dev/null)
outcome=$(echo $?)
if [[ $outcome != 0 ]]; then
echo "[$chain] Daemon is not running skipped."
continue
fi
string=$(printf '%08x\n' $(echo $getinfo | jq '.magic'))
magic=${string: -8}
magicrev=$(echo ${magic:6:2}${magic:4:2}${magic:2:2}${magic:0:2})
p2pport=$(echo $getinfo | jq '.p2pport')
thisconf=$(<~/.komodo/$chain/$chain.conf)
rpcuser=$(echo $thisconf | grep -Po "rpcuser=(\S*)" | sed 's/rpcuser=//')
rpcpass=$(echo $thisconf | grep -Po "rpcpassword=(\S*)" | sed 's/rpcpassword=//')
rpcport=$(echo $thisconf | grep -Po "rpcport=(\S*)" | sed 's/rpcport=//')
echo "$cointemplate" | sed "s/COINNAMEVAR/$chain/" | sed "s/MAGICREVVAR/$magicrev/" > $coinsdir/$chain.json
echo "$pooltemplate" | sed "s/P2PPORTVAR/$p2pport/" | sed "s/COINNAMEVAR/$chain/" | sed "s/WALLETADDRVAR/$walletaddress/" | sed "s/STRATUMPORTVAR/$stratumport/" | sed "s/RPCPORTVAR/$rpcport/" | sed "s/RPCUSERVAR/$rpcuser/" | sed "s/RPCPASSVAR/$rpcpass/" > $poolconfigdir/$chain.json
echo "sudo ufw allow $stratumport comment 'Stratum $chain'" >> $ufwenablefile
echo "sudo ufw delete allow $stratumport" >> $ufwdisablefile
let "stratumport = $stratumport + 1"
fi
done
chmod +x $ufwenablefile
chmod +x $ufwdisablefile