This repository has been archived by the owner on Nov 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 156
/
build_miner.sh
executable file
·150 lines (139 loc) · 4.62 KB
/
build_miner.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
#####################################################################
# Minera builder script to build and update miner software binaries
#
# For usage just run the build_miner.sh without any argument
#
# Thanks to @brettvitaz https://github.com/brettvitaz
#####################################################################
set -u
set -e
LINK_ONLY=0
BUILD_OK=0
MINERA_PATH="/var/www/minera"
BINARY_PATH="$MINERA_PATH/minera-bin"
SOURCE_PATH="$BINARY_PATH/src"
CPUMINER_REPO="https://github.com/siklon/cpuminer-gc3355"
CPUMINER_PATH="$SOURCE_PATH/cpuminer-gc3355"
CPUMINER_CONFIG="CFLAGS=-O3"
CPUMINER_BINARY="minerd"
CPUMINER_MINERA_BINARY="minerd"
BFGMINER_REPO="https://github.com/luke-jr/bfgminer.git"
BFGMINER_PATH="$SOURCE_PATH/bfgminer"
BFGMINER_CONFIG="--enable-scrypt --enable-broad-udevrules --without-system-libbase58"
BFGMINER_BINARY="bfgminer"
BFGMINER_MINERA_BINARY="bfgminer"
CGMINER_DMAXL_REPO="https://github.com/dmaxl/cgminer.git"
CGMINER_DMAXL_PATH="$SOURCE_PATH/cgminer-dmaxl-zeus"
CGMINER_DMAXL_CONFIG="--enable-scrypt --enable-gridseed --enable-zeus"
CGMINER_DMAXL_BINARY="cgminer"
CGMINER_DMAXL_MINERA_BINARY="cgminer-dmaxl-zeus"
CGMINER_REPO="https://github.com/ckolivas/cgminer.git"
CGMINER_PATH="$SOURCE_PATH/cgminer"
CGMINER_CONFIG="--enable-avalon2 --enable-bflsc --enable-bitforce --enable-bitfury --enable-drillbit --enable-hashfast --enable-icarus --enable-klondike --enable-modminer"
CGMINER_BINARY="cgminer"
CGMINER_MINERA_BINARY="cgminer"
CCMINER_REPO="https://github.com/tpruvot/ccminer.git"
CCMINER_PATH="$SOURCE_PATH/ccminer"
CCMINER_CONFIG=""
CCMINER_BINARY="ccminer"
CCMINER_MINERA_BINARY="ccminer"
function buildMiner {
if [[ $LINK_ONLY -eq 0 ]]; then
if [[ -d "$BUILD_PATH/.git" ]]; then
cd $BUILD_PATH
echo "Pulling repo $BUILD_REPO"
git fetch --all
git reset --hard
git pull
else
echo "Cloning repo $BUILD_REPO into $BUILD_PATH"
git clone $BUILD_REPO $BUILD_PATH
cd $BUILD_PATH
fi
./autogen.sh
echo "Running ./configure $BUILD_CONFIG"
./configure ${BUILD_CONFIG}
make
sudo make install
sudo ldconfig
fi
if [[ -e "$BUILD_PATH/$BUILD_BINARY" ]]; then
echo "Removing old binary $BINARY_PATH/$MINERA_BINARY"
rm $BINARY_PATH/$MINERA_BINARY
echo "Copying new binary $BUILD_PATH/$BUILD_BINARY -> $BINARY_PATH/$MINERA_BINARY"
cp $BUILD_PATH/$BUILD_BINARY $BINARY_PATH/$MINERA_BINARY
else
echo "Failed to copy miner binary. File $BUILD_PATH/$BUILD_BINARY does not exist."
fi
}
ARGS="${@/%all/cpuminer bfgminer cgminer-dmaxl cgminer}"
if [[ -d "$SOURCE_PATH" ]]; then
for OPT in $ARGS; do
echo "$OPT"
if [[ $OPT = "-l" ]]; then
LINK_ONLY=1
elif [[ $OPT = "all" ]]; then
ARGS="cpuminer bfgminer cgminer-dmaxl cgminer"
elif [[ $OPT = "cpuminer" ]]; then
BUILD_REPO=$CPUMINER_REPO
BUILD_PATH=$CPUMINER_PATH
BUILD_CONFIG=$CPUMINER_CONFIG
BUILD_BINARY=$CPUMINER_BINARY
MINERA_BINARY=$CPUMINER_MINERA_BINARY
BUILD_OK=1
elif [[ $OPT = "bfgminer" ]]; then
BUILD_REPO=$BFGMINER_REPO
BUILD_PATH=$BFGMINER_PATH
BUILD_CONFIG=$BFGMINER_CONFIG
BUILD_BINARY=$BFGMINER_BINARY
MINERA_BINARY=$BFGMINER_MINERA_BINARY
BUILD_OK=1
elif [[ $OPT = "cgminer-dmaxl" ]]; then
BUILD_REPO=$CGMINER_DMAXL_REPO
BUILD_PATH=$CGMINER_DMAXL_PATH
BUILD_CONFIG=$CGMINER_DMAXL_CONFIG
BUILD_BINARY=$CGMINER_DMAXL_BINARY
MINERA_BINARY=$CGMINER_DMAXL_MINERA_BINARY
BUILD_OK=1
elif [[ $OPT = "cgminer" ]]; then
BUILD_REPO=$CGMINER_REPO
BUILD_PATH=$CGMINER_PATH
BUILD_CONFIG=$CGMINER_CONFIG
BUILD_BINARY=$CGMINER_BINARY
MINERA_BINARY=$CGMINER_MINERA_BINARY
BUILD_OK=1
elif [[ $OPT = "ccminer" ]]; then
echo "WARNING! You have to manually install CUDA libraries before you can build Ccminer"
BUILD_REPO=$CCMINER_REPO
BUILD_PATH=$CCMINER_PATH
BUILD_CONFIG=$CCMINER_CONFIG
BUILD_BINARY=$CCMINER_BINARY
MINERA_BINARY=$CCMINER_MINERA_BINARY
BUILD_OK=1
else
echo "Option not recognized = $OPT"
BUILD_OK=0
fi
if [[ $BUILD_OK -eq 1 ]]; then
buildMiner
fi
done
if [[ $BUILD_OK -eq 0 ]]; then
echo "Usage: build_miner.sh [OPTION] [MINER NAME(S)]..."
echo ""
echo "Arguments:"
echo " -l Link binaries only (do not build)"
echo ""
echo "Miner Names:"
echo " cgminer cgminer official"
echo " cpuminer cpuminer GC3355 fork"
echo " bfgminer bfgminer official"
echo " cgminer-dmaxl cgminer dmaxl fork (gridseed and zeus support)"
echo " ccminer ccminer official"
echo " all build all the above"
echo ""
fi
else
echo "Minera source folder does not exist. Please install Minera prior to building the miners."
fi