forked from AleoNet/snarkOS
-
Notifications
You must be signed in to change notification settings - Fork 25
/
run-miner.sh
executable file
·54 lines (42 loc) · 1000 Bytes
/
run-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
#!/bin/bash
# Have a nice day
# USAGE examples:
# CLI with env vars: MINER_ADDRESS=aleoABCD... ./run-miner.sh
# CLI with prompts for vars: ./run-miner.sh
# if env var MINER_ADDRESS is not set, prompt for it
if [ -z "${MINER_ADDRESS}" ]
then
read -r -p "Enter your miner address: "
MINER_ADDRESS=$REPLY
fi
if [ "${MINER_ADDRESS}" == "" ]
then
MINER_ADDRESS="aleo1d5hg2z3ma00382pngntdp68e74zv54jdxy249qhaujhks9c72yrs33ddah"
fi
COMMAND="cargo run --release -- --miner ${MINER_ADDRESS} --trial --verbosity 2"
for word in $*;
do
COMMAND="${COMMAND} ${word}"
done
function exit_node()
{
echo "Exiting..."
kill $!
exit
}
trap exit_node SIGINT
echo "Running miner node..."
$COMMAND &
while :
do
echo "Checking for updates..."
git stash
rm Cargo.lock
STATUS=$(git pull)
if [ "$STATUS" != "Already up to date." ]; then
echo "Updated code found, rebuilding and relaunching miner"
cargo clean
kill -INT $!; sleep 2; $COMMAND &
fi
sleep 1800;
done