-
Notifications
You must be signed in to change notification settings - Fork 27
/
moneriote.sh.old
executable file
·125 lines (86 loc) · 2.87 KB
/
moneriote.sh.old
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
#!/bin/bash
#Gingeropolous Open node checker
# This is the directory where files are written to.
# If you run as a cronjob, you have to use the full path
DIR=/home/monero/files_moneriote
# This is the path for your monerod binary.
monerod=monerod
daemon=107.172.25.35
DOMAIN=node.moneroworld.com
html_dir=/var/www/mine.moneroworld.com/public_html/pages/
# This is the ip of your local daemon. If you're not running an open node, 127.0.0.1 is fine.
# if you want to check or pull a DNS entry
#Where your going to dump the file that will be published
echo $monerod
echo $daemon
###
mkdir $DIR
cp *.html $DIR
cd $DIR
echo `date` "The script started" >> moneriote.log
rm open_nodes.txt
rm nodes.html
cp nodes_base.html nodes.html
### Begin header of random thinger
cp base.html node_script.html
### Check Existing DNS entries for any to remove
### Kind of stupid right now because I can't update a DNS entry
export IPs=`dig $DOMAIN | grep $DOMAIN | grep -v ';' | awk '{ print $5 }'`;
export arr=($IPs)
# declare -a opennodes
# declare -a closednodes
for i in "${arr[@]}"
do
:
if nc -z -w 4 $i 18081
then
echo "$i is up"
opennodes+=($i)
else
echo "$i is down"
closednodes+=($i)
fi
done
echo ${opennodes[@]}
echo "Number of nodes: "${#white_a[@]} >> moneriote.log
echo "##############"
echo "Check network white nodes for domains to add"
white=$($monerod --rpc-bind-ip $daemon print_pl | grep white | awk '{print $3}' | cut -f 1 -d ":")
white_a=($white)
white_a+=($opennodes)
echo ${white_a[@]}
echo "################"
echo ${#white_a[@]}
echo "#############"
echo "Starting loop"
ctr=0
for i in "${white_a[@]}"
do
:
echo "Checking ip: "$i
l_hit="$(curl -X POST http://$daemon:18081/getheight -H 'Content-Type: application/json' | grep height | cut -f 2 -d : | cut -f 1 -d ,)"
r_hit="$(curl -m 0.5 -X POST http://$i:18081/getheight -H 'Content-Type: application/json' | grep height | cut -f 2 -d : | cut -f 1 -d ,)"
echo "Local Height: "$l_hit
echo "Remote Height: "$r_hit
mini=$(( $l_hit-10 ))
echo "minimum is " $mini
maxi=$(( $l_hit+10 ))
echo "max is " $maxi
if [[ "$r_hit" == "$l_hit" ]] || [[ "$r_hit" > "$mini" && "$r_hit" < "$maxi" ]]
then
echo "################################# Daemon $i is good"
### Time to write these good ips to a file of some sort!
### Apparently javascript needs some weird format in order to randomize, so I'll make two outputs
echo $i >> open_nodes.txt
echo "myarray[$ctr]= \"$i\";" >> node_script.html
let ctr=ctr+1
else
echo "$i is closed"
fi
done
cat bottom.html >> node_script.html
cat node_script.html >> nodes.html
echo `date` "The script finished" >> moneriote.log
sudo cp nodes.html $html_dir/
# http://stackoverflow.com/questions/16753876/javascript-button-to-pick-random-item-from-array
# http://www.javascriptkit.com/javatutors/randomorder.shtml