Browse Source
modified: ../dragonriders/dokomodo/yaml/config.ini modified: README.md modified: checkfork modified: coinlist deleted: fail2banstatusall deleted: freshubuntu modified: kmdacfirewall new file: statsmaster^2
8 changed files with 301 additions and 143 deletions
@ -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) |
|||
|
|||
blocks=$(komodo-cli -ac_name=${coin[0]} getinfo | jq .blocks) |
|||
longest=$(komodo-cli -ac_name=${coin[0]} getinfo | jq .longestchain) |
|||
|
|||
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" |
|||
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 |
|||
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 |
@ -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 |
@ -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 |
|||
|
@ -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…
Reference in new issue