-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapollo-launcher
More file actions
executable file
·329 lines (291 loc) · 6.91 KB
/
Copy pathapollo-launcher
File metadata and controls
executable file
·329 lines (291 loc) · 6.91 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#!/bin/bash
# ###########################################################################################################################
#
# apollo-launcher
#
# A wrapper for the apollo-miner binary used for the Apollo BTC stand-alone unit
#
# USAGE:
# * Put this wrapper script in the same folder where the apollo-miner binary is located.
# * Start it with ./apollo-launcher
# * The configuration will be assembled on-the-go and can be saved before starting the miner
# * Use -c command line switch for an existing/prebuilt config file: ./apollo-launcher -c apollo-launcher.cfg
# * If you like my work use the included config file and crunch some shares for me :)
#
#
# PROPS to @jstefanop for creating this great piece of hardware (As credit, his pool settings are used as default values)
#
#
# AUTHOR: Stefan Berger (golden-guy) https://github.com/golden-guy/apollo-launcher
#
# HISTORY:
# * v1.0 - First release
#
# ###########################################################################################################################
###### CONFIG - START ######
# default config file location
CONFIG_FILE=apollo-launcher.cfg
# generate a random worker name from UUID
WORKER=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
# fallback values when data is missing/incomplete
DEFAULT_HOST=us-east.stratum.slushpool.com
DEFAULT_PORT=3333
DEFAULT_USER=jstefanop.$WORKER
DEFAULT_PASSWORD=x
DEFAULT_COM_PORT=/dev/ttyACM0
DEFAULT_AO_MODE=1
# needed for freq selection menu
FREQ_PROMPTED=0
# set on explicit config file via command line
FILE_OPT=0
# sanitize values
MIN_POWER=30
MAX_POWER=95
MIN_FREQ=30
MAX_FREQ=60
###### CONFIG - END ######
check_args()
{
while getopts c: OPT
do
case $OPT in
c) CONFIG_FILE=$OPTARG
FILE_OPT=1
;;
?) exit 1
;;
esac
done
}
check_settings()
{
while [ "x$HOST" == "x" ] ||
[ "x$PORT" == "x" ] ||
[ "x$USER" == "x" ] ||
[ "x$PASSWORD" == "x" ] ||
[ "x$COM_PORT" == "x" ] ||
[ "x$POWER" == "x" ] ||
[ "x$FREQ" == "x" ] ||
[ "x$AO_MODE" == "x" ]
do
echo ""
echo "Settings incomplete! Please try again..."
# invalidate config file if defined
unset CONFIG_FILE
get_settings
done
}
reset_settings()
{
FREQ_PROMPTED=0
SETTINGS=""
}
set_settings()
{
SETTINGS="-host $HOST -port $PORT -user $USER -pswd $PASSWORD -comport $COM_PORT -brd_ocp $POWER -osc $FREQ -ao_mode $AO_MODE"
}
print_settings()
{
echo ""
echo "Current settings:"
echo "HOST=$HOST"
echo "PORT=$PORT"
echo "USER=$USER"
echo "PASSWORD=$PASSWORD"
echo "COM_PORT=$COM_PORT"
echo "AO_MODE=$AO_MODE"
echo "POWER=$POWER"
echo "FREQ=$FREQ"
echo ""
echo "CMD_LINE=$SETTINGS"
echo ""
}
save_settings_to_file()
{
print_settings
read -p "Do you want to save the current configuration? (y|N): "
if [ "$REPLY" == "Y" ] || [ "$REPLY" == "y" ]
then
read -e -i "$CONFIG_FILE" -p "Select file to save: "
if ! [ "x$REPLY" == "x" ]
then
CONFIG_FILE=$REPLY
fi
echo "HOST=$HOST" > $CONFIG_FILE
echo "PORT=$PORT" >> $CONFIG_FILE
echo "USER=$USER" >> $CONFIG_FILE
echo "PASSWORD=$PASSWORD" >> $CONFIG_FILE
echo "COM_PORT=$COM_PORT" >> $CONFIG_FILE
echo "POWER=$POWER" >> $CONFIG_FILE
echo "FREQ=$FREQ" >> $CONFIG_FILE
echo "AO_MODE=$AO_MODE" >> $CONFIG_FILE
fi
}
get_settings_from_file()
{
while IFS='=' read -r KEY VALUE
do
case $KEY in
HOST)
HOST=$VALUE
;;
PORT)
PORT=$VALUE
;;
USER)
USER=$VALUE
;;
PASSWORD)
PASSWORD=$VALUE
;;
COM_PORT)
COM_PORT=$VALUE
;;
AO_MODE)
AO_MODE=$VALUE
;;
POWER)
POWER=$VALUE
;;
FREQ)
FREQ=$VALUE
;;
*)
;;
esac
done < $CONFIG_FILE
}
prompt_for_settings() {
read -e -i "$DEFAULT_HOST" -p "Hostname: "
HOST=$REPLY
read -e -i "$DEFAULT_PORT" -p "Port: "
PORT=$REPLY
read -e -i "$DEFAULT_USER" -p "Username/Wallet address: "
USER=$REPLY
read -e -i "$DEFAULT_PASSWORD" -p "Password: "
PASSWORD=$REPLY
read -e -i "$DEFAULT_COM_PORT" -p "COM Port: "
COM_PORT=$REPLY
read -e -i "$DEFAULT_AO_MODE" -p "AO_MODE: "
AO_MODE=$REPLY
select_power_profile
FREQ_PROMPTED=1
}
get_settings()
{
reset_settings
echo ""
if ! [ -z $CONFIG_FILE ]
then
if [ -f $CONFIG_FILE ]
then
read -e -i "y" -p "Existing configuration file found. Use settings from $CONFIG_FILE? (y|n): "
if [ "$REPLY" == "Y" ] || [ "$REPLY" == "y" ]
then
get_settings_from_file
set_settings
else
prompt_for_settings
fi
fi
else
prompt_for_settings
fi
if [ $FREQ_PROMPTED -eq 0 ]
then
print_settings
read -p "Do you want to change board power and frequency now? (y|N): "
if [ "$REPLY" == "Y" ] || [ "$REPLY" == "y" ]
then
select_power_profile
fi
fi
}
print_warning() {
echo ""
echo "If you are using the FutureBit APU-200 PSU that comes with your unit DO NOT SET the power (using -brd_ocp) higher than 75%. The PSU is limited to 200 watts, and going beyond this will trip or overheat your power supply!"
echo "ONLY set the power higher than 75% if you are using your own PSU that is capable of at least 300 watts per unit, and BOTH PCIE 6 Pin power plugs are plugged into your unit."
echo "I am NOT responsible for damage, nor will warranty devices damaged from running beyond 75% power. Proceed at your own risk!"
echo ""
}
select_power_profile()
{
echo ""
echo "Select power profile:"
echo "1) ECO (-brd_ocp 48 -osc 30)"
echo "2) BALANCED (-brd_ocp 60 -osc 40)"
echo "3) TURBO (-brd_ocp 75 -osc 50)"
echo "4) CUSTOM (ONLY use at your own risk!)"
echo ""
read -p "Make your selection (1-4): "
case $REPLY in
1)
MODE=ECO
POWER=48
FREQ=30
;;
2)
MODE=BALANCED
POWER=60
FREQ=40
;;
3)
MODE=TURBO
POWER=75
FREQ=50
;;
4)
print_warning
MODE=CUSTOM
read -e -i "75" -p "Board Power (30-95): "
POWER=$REPLY
if [ $POWER -lt $MIN_POWER ]
then
echo "Power value too low, setting to $MIN_POWER"
POWER=$MIN_POWER
elif [ $POWER -gt $MAX_POWER ]
then
echo "Power value too high, setting to $MAX_POWER"
POWER=$MAX_POWER
fi
read -e -i "50" -p "Board Freq (30-60): "
FREQ=$REPLY
if [ $FREQ -lt $MIN_FREQ ]
then
echo "Frequency value too low, setting to $MIN_FREQ"
FREQ=$MIN_FREQ
elif [ $FREQ -gt $MAX_FREQ ]
then
echo "Frequency value too high, setting to $MAX_FREQ"
FREQ=$MAX_FREQ
fi
;;
*)
# using ECO mode as default
MODE=ECO
POWER=48
FREQ=30
;;
esac
set_settings
}
start_miner() {
echo ""
read -p "Press Enter key to start the apollo-miner..."
./apollo-miner $SETTINGS
}
check_args $@
# fast-pass for explicit configs
if [ $FILE_OPT -eq 1 ]
then
get_settings_from_file
check_settings
set_settings
else
get_settings
check_settings
set_settings
save_settings_to_file
fi
start_miner
exit 0