-
Notifications
You must be signed in to change notification settings - Fork 23
/
9poolswitch
71 lines (61 loc) · 2.89 KB
/
9poolswitch
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
#!/bin/bash
##########################################################################
#################### nvOC 3.2 - Community Release ####################
########## Based on the original nvOC v0019-1.4 by fullzero ##########
##########################################################################
# POOL SWITCH for nvOC v0019 by papampi #
# Changelog: #
# v=0001 : papampi #
# : Initial Release
# v=0002 : LukePicci
# Relocate nvOC to arbitrary install directory
source ${NVOC}/1bash
nvOC_poolswitch_Dev="0002"
nvOC_poolswitch_ver="$nvOC_Ver.$nvOC_poolswitch_Dev"
echo "Pool Switch for nvOC nvOC_Ver"
echo "Version: $nvOC_poolswitch_ver"
WDOG_LOG="${NVOC}/5_watchdoglog"
MINER_LOG="${NVOC}/nvoc_logs/screenlog.0"
WTM_LOG="${NVOC}/nvoc_logs/8_wtmautoswitchlog"
eval 'COIN_POOL=${COIN}_POOL'
eval 'COIN_PORT=${COIN}_PORT'
eval 'COIN_POOL_1=${COIN}_POOL_1'
eval 'COIN_PORT_1=${COIN}_PORT_1'
eval 'COIN_POOL_2=${COIN}_POOL_2'
eval 'COIN_PORT_2=${COIN}_PORT_2'
WTM=0
POOL=1
while ! nc -vzw1 ${!COIN_POOL_1} ${!COIN_PORT_1}
do
source ${NVOC}/1bash
POOL=0
if [[ ${!COIN_POOL} == ${!COIN_POOL_1} ]]; then
echo "Switching Pool to ${!COIN_POOL_2}:${!COIN_PORT_2}" | tee -a $MINER_LOG $WDOG_LOG
sed -i 's/'"$COIN_POOL"'=$'"$COIN_POOL_1"'/'"$COIN_POOL"'=$'"$COIN_POOL_2"'/g' ${NVOC}/1bash
sed -i 's/'"$COIN_PORT"'=$'"$COIN_PORT_1"'/'"$COIN_PORT"'=$'"$COIN_PORT_2"'/g' ${NVOC}/1bash
echo "Restarting miner and watchdog to complete switching" | tee -a $MINER_LOG $WDOG_LOG
if [[ $AUTO_SWITCH == WTM_SWITCHING ]]; then
WTM=1
echo "Pool Switch is turning off WTM Auto Switch to prevent mixing coin data while ${!COIN_POOL_1} is down" | tee -a $WTM_LOG
sed -i 's/AUTO_SWITCH="WTM_SWITCHING"/AUTO_SWITCH="NO"/g' ${NVOC}/1bash
pkill -f 8wtm_auto_switch
fi
pkill -f 5watchdog
pkill -f 3main
fi
echo "Main Pool ${!COIN_POOL_1} not reachable, check again in 5 minutes"
sleep 300
done
if nc -vzw1 ${!COIN_POOL_1} ${!COIN_PORT_1} && [[ $POOL == 0 ]]; then
echo "Main Pool ${!COIN_POOL_1}:${!COIN_PORT_1} is reachable now" | tee -a $MINER_LOG $WDOG_LOG
echo "Switch back to main pool"
sed -i 's/'"$COIN_POOL"'=$'"$COIN_POOL_2"'/'"$COIN_POOL"'=$'"$COIN_POOL_1"'/g' ${NVOC}/1bash
sed -i 's/'"$COIN_PORT"'=$'"$COIN_PORT_2"'/'"$COIN_PORT"'=$'"$COIN_PORT_1"'/g' ${NVOC}/1bash
if [[ $WTM == 1 ]] ; then
echo "Pool Switch is turning back on WTM Auto Switch" | tee -a $WTM_LOG
sed -i 's/AUTO_SWITCH="NO"/AUTO_SWITCH="WTM_SWITCHING"/g' ${NVOC}/1bash
fi
echo "Restarting miner and watchdog to complete switching back to ${!COIN_POOL_1}" | tee -a $MINER_LOG $WDOG_LOG
pkill -f 5wathcdog
pkill -f 3main
fi