Browse Source

Merge branch 'KomodoPlatform-master'

master^2
blackjok3r 7 years ago
parent
commit
ebd59da202
  1. 4
      dragonriders/dokomodo/yaml/config.ini
  2. 4
      webworker01/README.md
  3. 82
      webworker01/checkfork
  4. 6
      webworker01/coinlist
  5. 7
      webworker01/fail2banstatusall
  6. 116
      webworker01/freshubuntu
  7. 1
      webworker01/kmdacfirewall
  8. 216
      webworker01/stats

4
dragonriders/dokomodo/yaml/config.ini

@ -34,7 +34,7 @@ write_path_conf = ~/.komodo
# List of assetchains to be started, it does not mean when they ar estarted that they are also notarized!!!
# List is used to create configuration files for assetchains
# to access its data in central registry file
production_coins_assets = REVS, SUPERNET, DEX, PANGEA, JUMBLR, BET, CRYPTO, HODL, MSHARK, BOTS, MGW, COQUI, WLC, KV, CEAL, MESH, MNZ, AXO, ETOMIC, BTCH, VOTE2018, PIZZA, BEER, NINJA, OOT, BNTN, CHAIN, PRLPAY, DSEC
production_coins_assets = REVS, SUPERNET, DEX, PANGEA, JUMBLR, BET, CRYPTO, HODL, MSHARK, BOTS, MGW, COQUI, WLC, KV, CEAL, MESH, MNZ, AXO, ETOMIC, BTCH, VOTE2018, PIZZA, BEER, NINJA, OOT, BNTN, CHAIN, PRLPAY, DSEC, GLXT, EQL, ZILLA, RFOX, SEC
development_coins_assets = PIZZA, BEER
@ -50,7 +50,7 @@ iguana_url = http://%(iguana_host)s:%(iguana_rpc_port)s
# List of chains which will be notarized!!!
# This will be used mostly for iguana methods, this list will be used in loop and key of coin will be used
# to access its data in central registry file
production_coins = KMD, BTC, LTC, CHIPS, REVS, SUPERNET, DEX, PANGEA, JUMBLR, BET, CRYPTO, HODL, MSHARK, BOTS, MGW, COQUI, WLC, KV, CEAL, MESH, MNZ, AXO, ETOMIC, BTCH, VOTE2018, NINJA, OOT, BNTN, CHAIN, PRLPAY, GAME, DSEC
production_coins = KMD, BTC, LTC, CHIPS, REVS, SUPERNET, DEX, PANGEA, JUMBLR, BET, CRYPTO, HODL, MSHARK, BOTS, MGW, COQUI, WLC, KV, CEAL, MESH, MNZ, AXO, ETOMIC, BTCH, VOTE2018, NINJA, OOT, BNTN, CHAIN, PRLPAY, GAME, DSEC, GLXT, EQL, ZILLA, VRSC, RFOX, SEC
development_coins = KMD, PIZZA, BEER

4
webworker01/README.md

@ -6,8 +6,6 @@ Script Name | Function
**checkforks** | Script to quickly check all assetchains for possible forks
**checkmasks** | Check your nodes connectivity to the notary node network
**coinlist** | Handy way to keep coin list in one place for other scripts to use (thanks to a-team)
**fail2banstatusall** | Get stats of fail2ban jails
**freshubuntu** | Run this for initial setup of your server for basic security needs (generalized on purpose so it can be used on any server)
**killemall** | Hard kill komodo related processes
**killthemsoftly** | Kill komodo processes nicely
**kmdacfirewall** | UFW settings with commentary
@ -18,5 +16,7 @@ Script Name | Function
**start** | Start chipsd and komodod
**startac** | Start assetchains
**stats** | Fancy cli stats for notary nodes
**fail2banstatusall** | Moved to https://github.com/webworker01/freshubuntu
**freshubuntu** | Moved to https://github.com/webworker01/freshubuntu
Donate to motivate! :D RNFgPeabWXWeSq2NnYfvdsjuok5Tccd7xM

82
webworker01/checkfork

@ -1,42 +1,100 @@
#!/bin/bash
#You can modify this list of ACs to exclude or comment out the line to show all
ignoreacs=('VOTE2018' 'BEER' 'PIZZA')
#how far ahead or behind before being marked as a fork
variance=3
source coinlist
forked=false
remotecheck=$(curl -Ssf https://komodostats.com/api/notary/summary.json)
remotecheck2=$(curl -Ssf https://dexstats.info/api/explorerstatus.php)
format="%-8s %8s %8s %8s %8s\n"
redformat="\033[0;31m$format\033[0m"
printf "$format" "-ASSET-" "-BLOCKS-" "-LONG-" "-RMT1-" "-RMT2-"
#KMD
blocks=$(komodo-cli getinfo | jq .blocks)
longest=$(komodo-cli getinfo | jq .longestchain)
remoteblocks=$(echo $remotecheck | jq '.[] | select(.ac_name=="KMD") | .blocks')
remoteblocks2=$(echo $remotecheck2 | jq '.status[] | select(.chain=="KMD") | .height | tonumber')
diff1=$((blocks-remoteblocks))
diff2=$((blocks-remoteblocks2))
thisformat=$format
if ((blocks < longest)); then
forked=true
printf "\033[0;31mKMD - Possible fork!\033[0m Blocks $blocks < LongestChain $longest\n"
else
echo "KMD - Blocks $blocks = LongestChain $longest"
thisformat=$redformat
fi
if (( diff1 < variance * -1 )) || (( diff1 > variance )); then
forked=true
thisformat=$redformat
fi
if (( diff2 < variance * -1 )) || (( diff2 > variance )); then
forked=true
thisformat=$redformat
fi
printf "$thisformat" "KMD" "$blocks" "$longest" "$remoteblocks" "$remoteblocks2"
#CHIPS
blocks=$(chips-cli getinfo | jq .blocks)
longest=$(chips-cli getinfo | jq .headers)
remoteblocks=$(echo $remotecheck | jq '.[] | select(.ac_name=="CHIPS") | .blocks')
diff1=$((blocks-remoteblocks))
thisformat=$format
if ((blocks < longest)); then
forked=true
printf "\033[0;31mCHIPS - Possible fork!\033[0m Blocks $blocks < Headers $longest\n"
else
echo "CHIPS - Blocks $blocks = Headers $longest"
thisformat=$redformat
fi
if (( diff1 < variance * -1 )) || (( diff1 > variance )); then
forked=true
thisformat=$redformat
fi
printf "$thisformat" "CHIPS" "$blocks" "$longest" "$remoteblocks"
#GAME
blocks=$(gamecredits-cli getinfo | jq .blocks)
remoteblocks=$(echo $remotecheck | jq '.[] | select(.ac_name=="GAME") | .blocks')
diff1=$((blocks-remoteblocks))
thisformat=$format
if (( diff1 < variance * -1 )) || (( diff1 > variance )); then
forked=true
thisformat=$redformat
fi
printf "$thisformat" "GAME" "$blocks" " " "$remoteblocks"
for coins in "${coinlist[@]}"; do
coin=($coins)
if [[ ! ${ignoreacs[*]} =~ ${coin[0]} ]]; then
blocks=$(komodo-cli -ac_name=${coin[0]} getinfo | jq .blocks)
longest=$(komodo-cli -ac_name=${coin[0]} getinfo | jq .longestchain)
remoteblocks=$(echo $remotecheck | jq --arg acname ${coin[0]} '.[] | select(.ac_name==$acname) | .blocks')
remoteblocks2=$(echo $remotecheck2 | jq --arg acname ${coin[0]} '.status[] | select(.chain==$acname) | .height | tonumber')
diff1=$((blocks-remoteblocks))
diff2=$((blocks-remoteblocks2))
thisformat=$format
if ((blocks < longest)); then
forked=true
printf "\033[0;31m${coin[0]} - Possible fork!\033[0m Blocks $blocks < LongestChain $longest\n"
else
echo "${coin[0]} - Blocks $blocks = LongestChain $longest"
thisformat=$redformat
fi
if (( diff1 < variance * -1 )) || (( diff1 > variance )); then
forked=true
thisformat=$redformat
fi
if (( diff2 < variance * -1 )) || (( diff2 > variance )); then
forked=true
thisformat=$redformat
fi
printf "$thisformat" "${coin[0]}" "$blocks" "$longest" "$remoteblocks" "$remoteblocks2"
fi
done
if [ "$forked" = false ]; then
printf "\033[0;32mAll coins are fine\033[0m\n"
else
printf "\033[0;31mPossible fork!\033[0m\n"
fi

6
webworker01/coinlist

@ -19,6 +19,7 @@ coinlist=(
'AXO 200000000'
'ETOMIC 100000000'
'BTCH 20998641'
'VOTE2018 600000000'
'PIZZA 100000000'
'BEER 100000000'
'NINJA 100000000'
@ -27,4 +28,9 @@ coinlist=(
'CHAIN 999999'
'PRLPAY 500000000'
'DSEC 7000000'
'GLXT 100000000'
'EQL 500000000'
'ZILLA 11000000'
'RFOX 1000000000'
'VRSC 0'
)

7
webworker01/fail2banstatusall

@ -1,7 +0,0 @@
#!/bin/bash
JAILS=`sudo fail2ban-client status | grep "Jail list" | sed -E 's/^[^:]+:[ \t]+//' | sed 's/,//g'`
for JAIL in $JAILS
do
sudo fail2ban-client status $JAIL
done

116
webworker01/freshubuntu

@ -1,116 +0,0 @@
#!/bin/bash
if [ "$EUID" -ne 0 ]
then
echo -e "\e[41mPlease use sudo or run as root...\e[0m"
exit
fi
read -p "Configure timezone & locale? (y/n) " -n 1 DOLOCALE
echo
if [[ $DOLOCALE =~ ^[Yy]$ ]]
then
dpkg-reconfigure tzdata
dpkg-reconfigure locales
fi
read -p "Upgrade packages? (y/n) " -n 1 DOUPGRADES
echo
if [[ $DOUPGRADES =~ ^[Yy]$ ]]
then
apt-get update && apt-get -y dist-upgrade
fi
read -p "Install extra tools? (y/n) " -n 1 DOEXTRAS
echo
if [[ $DOEXTRAS =~ ^[Yy]$ ]]
then
apt -y install fail2ban ufw git curl bash-completion htop jq
fi
read -p "Update hostname? (y/n) " -n 1 DOHOSTNAME
echo
if [[ $DOHOSTNAME =~ ^[Yy]$ ]]
then
read -p "Enter hostname: " NEWHOSTNAME
echo "$NEWHOSTNAME" > /etc/hostname
sed -i "1i127.0.0.1 ${NEWHOSTNAME}" /etc/hosts
fi
read -p "Disable IPV6? (y/n) " -n 1 DOIPV6
echo
if [[ $DOIPV6 =~ ^[Yy]$ ]]
then
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" >> /etc/sysctl.conf
sysctl -p
fi
read -p "Configure UFW? (This will only allow incoming port 22) (y/n) " -n 1 DOUFW
echo
if [[ $DOUFW =~ ^[Yy]$ ]]
then
ufw default deny incoming
ufw default allow outgoing
ufw allow 22 comment 'SSH'
ufw enable
systemctl enable ufw
ufw status
fi
read -p "Add non-root sudo user? (y/n) " -n 1 DONONROOT
echo
if [[ $DONONROOT =~ ^[Yy]$ ]]
then
read -p "Enter user name: " NEWUSERNAME
echo
useradd -m $NEWUSERNAME
adduser $NEWUSERNAME sudo
passwd $NEWUSERNAME
sudo chsh $NEWUSERNAME -s /bin/bash
grep -q "^[#]*force_color_prompt=" /home/$NEWUSERNAME/.bashrc && sed -i "/^[#]*force_color_prompt=/c\force_color_prompt=yes" /home/$NEWUSERNAME/.bashrc
source /home/$NEWUSERNAME/.bashrc
read -p "Please enter the public key (and label if desired) for $NEWUSERNAME (not recommended: enter to skip): " NEWUSERPUBKEY
if [[ ! -z "$NEWUSERPUBKEY" ]]
then
mkdir -p /home/$NEWUSERNAME/.ssh/
echo "ssh-rsa $NEWUSERPUBKEY" >> /home/$NEWUSERNAME/.ssh/authorized_keys
chmod -R 700 /home/$NEWUSERNAME/.ssh/
chown -R $NEWUSERNAME:$NEWUSERNAME /home/$NEWUSERNAME/.ssh/
read -p "Copy key to root user? " -n 1 DOROOTKEY
if [[ $DOROOTKEY =~ ^[Yy]$ ]]
then
mkdir -p /root/.ssh
cp /home/$NEWUSERNAME/.ssh/authorized_keys /root/.ssh/
chown -R root:root /root/.ssh/
chmod -R 700 /root/.ssh/
fi
fi
read -p "Please login with the SSH key on the new user now to verify connectivity. Have you completed this? (y/n) " -n 1 TESTEDCONNECTIVITY
echo
if [[ $TESTEDCONNECTIVITY =~ ^[Yy]$ ]]
then
read -p "Disable root login? " -n 1 DOROOTDISABLE
echo
if [[ $DOROOTDISABLE =~ ^[Yy]$ ]]
then
grep -q "^[#]*PermitRootLogin" /etc/ssh/sshd_config && sed -i "/^[#]*PermitRootLogin/c\PermitRootLogin no" /etc/ssh/sshd_config || echo "PermitRootLogin no" >> /etc/ssh/sshd_config
fi
grep -q "^[#]*PubkeyAuthentication" /etc/ssh/sshd_config && sed -i "/^[#]*PubkeyAuthentication/c\PubkeyAuthentication yes" /etc/ssh/sshd_config || echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config
grep -q "^[#]*ChallengeResponseAuthentication" /etc/ssh/sshd_config && sed -i "/^[#]*ChallengeResponseAuthentication/c\ChallengeResponseAuthentication no" /etc/ssh/sshd_config || echo "ChallengeResponseAuthentication no" >> /etc/ssh/sshd_config
grep -q "^[#]*PasswordAuthentication" /etc/ssh/sshd_config && sed -i "/^[#]*PasswordAuthentication/c\PasswordAuthentication no" /etc/ssh/sshd_config || echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
systemctl restart sshd.service
else
echo -e "\e[41mSorry, it won't be safe to do the final steps here then... take care.\e[0m"
fi
fi

1
webworker01/kmdacfirewall

@ -38,6 +38,7 @@ sudo ufw allow 14357 comment 'BNTN'
sudo ufw allow 15586 comment 'CHAIN'
sudo ufw allow 9678 comment 'PRLPAY'
sudo ufw allow 40002 comment 'GAME'
sudo ufw allow 11556 comment 'DSEC'
sudo ufw allow 15722 comment 'GLXT'
sudo ufw allow 10305 comment 'EQL'
sudo ufw enable

216
webworker01/stats

@ -0,0 +1,216 @@
#!/bin/bash
#Stats script for Komodo Notary Nodes
#
#Requires jq v1.5+ and bitcoin-cli, komodo-cli, chips-cli and gamecredits-cli installed (e.g. symlinked to /usr/local/bin)
#==Options - Only Change These==
#Seconds in display loop, change to false if you don't want it to loop
sleepytime=600
#How many transactions back to scan for notarizations
txscanamount=77777
#You can modify this list of ACs to exclude or comment out the line to show all
ignoreacs=('VOTE2018' 'BEER' 'PIZZA')
#git checking - path and remote branch
declare -A repos=(
[KMD]='$HOME/komodo origin/dev'
[SUPERNET]='$HOME/SuperNET origin/dev'
[CHIPS]='$HOME/chips3 origin/dev'
[GAME]='/home/gamecredits/GameCredits origin/master'
)
#==End Options==
timeSince () {
local currentimestamp=$(date +%s)
local timecompare=$1
if [ ! -z $timecompare ] && [[ $timecompare != "null" ]]
then
local t=$((currentimestamp-timecompare))
local d=$((t/60/60/24))
local h=$((t/60/60%24))
local m=$((t/60%60))
local s=$((t%60))
if [[ $d > 0 ]]; then
echo -n "${d}d"
fi
if [[ $h > 0 ]]; then
echo -n "${h}h"
fi
if [[ $d = 0 && $m > 0 ]]; then
echo -n "${m}m"
fi
if [[ $d = 0 && $h = 0 && $m = 0 ]]; then
echo -n "${s}s"
fi
fi
}
checkRepo () {
if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then
return
fi
prevdir=${PWD}
eval cd "$2"
color_red=$'\033[0;31m'
color_reset=$'\033[0m'
git remote update > /dev/null 2>&1
localrev=$(git rev-parse HEAD)
remoterev=$(git rev-parse $3)
cd $prevdir
if [ $localrev != $remoterev ]; then
printf "$color_red[U]$color_reset"
fi
case $1 in
KMD)
printf " "
;;
CHIPS)
printf " "
;;
GAME)
printf " "
;;
esac
}
#Do not change below for any reason!
#The BTC and KMD address here must remain the same. Do not need to enter yours!
source coinlist
utxoamt=0.00010000
ntrzdamt=-0.00083600
btcntrzaddr=1P3rU1Nk1pmc2BiWC8dEy9bZa1ZbMp5jfg
kmdntrzaddr=RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA
#Only count KMD->BTC after this timestamp (block 814000)
timefilter=1525032458
#Second time filter for assetchains (SuperNET commit 07515fb)
timefilter2=1525513998
format="%-11s %6s %6s %7s %.12s %6s %6s %6s"
othercoins=(
'CHIPS chips-cli'
'GAME gamecredits-cli'
)
outputstats ()
{
count=0
totalntrzd=0
now=$(date +"%H:%M")
printf "\n\n"
printf "%-11s %6s %6s %7s %12s %6s %6s %6s\n" "-ASSET-" "-NOTR-" "-UTXO-" "-BLOX-" "-BALANCE-" "-LAST-" "-CNCT-";
btctxinfo=$(bitcoin-cli listtransactions "" $txscanamount)
btclastntrztime=$(echo $btctxinfo | jq -r --arg address "$btcntrzaddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
btcntrzd=$(echo $btctxinfo | jq --arg address "$btcntrzaddr" --arg timefilter $timefilter '[.[] | select(.time>=($timefilter|tonumber) and .address==$address and .category=="send")] | length')
totalntrzd=$(( $totalntrzd + $btcntrzd ))
printf "$format\n" "BTC" \
"$btcntrzd" \
"$(bitcoin-cli listunspent | jq --arg amt "$utxoamt" '[.[] | select(.amount==($amt|tonumber))] | length')" \
"$(bitcoin-cli getblockchaininfo | jq .blocks)" \
"$(printf "%12.8f" $(bitcoin-cli getbalance))" \
"$(timeSince $btclastntrztime)" \
"$(bitcoin-cli getnetworkinfo | jq .connections)"
kmdinfo=$(komodo-cli getinfo)
kmdtxinfo=$(komodo-cli listtransactions "" $txscanamount)
kmdlastntrztime=$(echo $kmdtxinfo | jq -r --arg address "$kmdntrzaddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
repo=(${repos[KMD]})
printf "$format\n" "KMD$(checkRepo KMD ${repo[0]} ${repo[1]})" \
" " \
"$(komodo-cli listunspent | jq --arg amt "$utxoamt" '[.[] | select(.amount==($amt|tonumber))] | length')" \
"$(echo $kmdinfo | jq .blocks)" \
"$(printf "%12.8f" $(echo $kmdinfo | jq .balance))" \
"$(timeSince $kmdlastntrztime)" \
"$(echo $kmdinfo | jq .connections)" \
"$(echo $kmdtxinfo | jq '[.[] | select(.generated==true)] | length') mined"
for coins in "${othercoins[@]}"; do
coin=($coins)
if [[ ${coin[0]} == "GAME" ]]; then
coinsutxoamount=0.00100000
coinsntraddr=Gftmt8hgzgNu6f1o85HMPuwTVBMSV2TYSt
else
coinsutxoamount=$utxoamt
coinsntraddr=$kmdntrzaddr
fi
coinsinfo=$(${coin[1]} getinfo)
coinstxinfo=$(${coin[1]} listtransactions "" $txscanamount)
coinslastntrztime=$(echo $coinstxinfo | jq -r --arg address "$coinsntraddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
coinsntrzd=$(echo $coinstxinfo | jq --arg address "$coinsntraddr" --arg timefilter $timefilter2 '[.[] | select(.time>=($timefilter|tonumber) and .address==$address and .category=="send")] | length')
totalntrzd=$(( $totalntrzd + $coinsntrzd ))
repo=(${repos[${coin[0]}]})
printf "$format\n" "${coin[0]}$(checkRepo ${coin[0]} ${repo[0]} ${repo[1]})" \
"$coinsntrzd" \
"$(${coin[1]} listunspent | jq --arg amt "$coinsutxoamount" '[.[] | select(.amount==($amt|tonumber))] | length')" \
"$(echo $coinsinfo | jq .blocks)" \
"$(printf "%12.8f" $(echo $coinsinfo | jq -r '. | (.balance|tostring)'))" \
"$(timeSince $coinslastntrztime)" \
"$(echo $coinsinfo | jq .connections)"
done
lastcoin=(${coinlist[-1]})
secondlast=(${coinlist[-2]})
for coins in "${coinlist[@]}"; do
coin=($coins)
if [[ ! ${ignoreacs[*]} =~ ${coin[0]} ]]; then
info=$(komodo-cli -ac_name=${coin[0]} getinfo)
mininginfo=$(komodo-cli -ac_name=${coin[0]} getmininginfo)
txinfo=$(komodo-cli -ac_name=${coin[0]} listtransactions "" $txscanamount)
lastntrztime=$(echo $txinfo | jq -r --arg address "$kmdntrzaddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
acntrzd=$(echo $txinfo | jq --arg address "$kmdntrzaddr" --arg timefilter $timefilter2 '[.[] | select(.time>=($timefilter|tonumber) and .address==$address and .category=="send")] | length')
totalntrzd=$(( $totalntrzd + $acntrzd ))
repo=(${repos[${coin[0]}]})
laststring=""
if [[ ${coin[0]} == ${lastcoin[0]} ]]; then
laststring="@ $now"
fi
if [[ ${coin[0]} == ${secondlast[0]} ]]; then
laststring="All:$totalntrzd"
fi
printf "$format" "${coin[0]}$(checkRepo ${coin[0]} ${repo[0]} ${repo[1]})" \
"$acntrzd" \
"$(komodo-cli -ac_name=${coin[0]} listunspent | jq --arg amt "$utxoamt" '[.[] | select(.amount==($amt|tonumber))] | length')" \
"$(echo $info | jq .blocks)" \
"$(printf "%12.8f" $(echo $info | jq .balance))" \
"$(timeSince $lastntrztime)" \
"$(echo $info | jq .connections)" \
"$laststring"
if [[ ${coin[0]} != ${lastcoin[0]} ]]; then
echo
fi
fi
done
}
if [ "$sleepytime" != "false" ]; then
while true; do
outputstats
sleep $sleepytime
done
else
outputstats
echo
fi
Loading…
Cancel
Save