Browse Source

Add some scripts

revert-24-test_rpcbind_to_assetname
webworker01 7 years ago
parent
commit
adbd24c707
  1. 19
      webworker01/README.md
  2. 2
      webworker01/acsplit
  3. 30
      webworker01/coinlist
  4. 7
      webworker01/fail2banstatusall
  5. 116
      webworker01/freshubuntu
  6. 4
      webworker01/killthemall
  7. 5
      webworker01/killthemsoftly
  8. 38
      webworker01/kmdacfirewall
  9. 21
      webworker01/networktweaksundo.txt
  10. 2
      webworker01/notary
  11. 3
      webworker01/notarytest
  12. 5
      webworker01/rebuildkomodo
  13. 4
      webworker01/start
  14. 3
      webworker01/startac
  15. 69
      webworker01/stats

19
webworker01/README.md

@ -0,0 +1,19 @@
Scripts I like to keep handy for running my node.
Script Name | Function
----------- | --------
**acsplit** | Create UTXOs as needed although Iguana handles this as long as you didn't hit the base58 lottery
**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)
**killthemall** | Hard kill komodo related processes
**killthemsoftly** | Kill komodo processes nicely
**kmdacfirewall** | UFW settings with commentary
**networktweaksundo.txt** | Reference to my default Ubuntu 16.04 net config "just in case"
**notary** | Start notary process
**notarytest** | Start notary test process
**rebuildkomodo** | Git pull and rebuild komodo on the current branch
**start** | Start chipsd and komodod
**startac** | Start assetchains
**stats** | Fancy cli stats for notary nodes

2
webworker01/acsplit

@ -0,0 +1,2 @@
#!/bin/bash
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\""${1}"\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"10000\",\"sendflag\":1,\"duplicates\":"${2}"}"

30
webworker01/coinlist

@ -0,0 +1,30 @@
coinlist=(
'REVS 1300000'
'SUPERNET 816061'
'DEX 999999'
'PANGEA 999999'
'JUMBLR 999999'
'BET 999999'
'CRYPTO 999999'
'HODL 9999999'
'MSHARK 1400000'
'BOTS 999999'
'MGW 999999'
'COQUI 72000000'
'WLC 210000000'
'KV 1000000'
'CEAL 366666666'
'MESH 1000007'
'MNZ 257142858'
'AXO 200000000'
'ETOMIC 100000000'
'BTCH 20998641'
'VOTE2018 600000000'
'PIZZA 100000000'
'BEER 100000000'
'NINJA 100000000'
'OOT 216000000'
'BNTN 500000000'
'CHAIN 999999'
'PRLPAY 500000000'
)

7
webworker01/fail2banstatusall

@ -0,0 +1,7 @@
#!/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

@ -0,0 +1,116 @@
#!/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

4
webworker01/killthemall

@ -0,0 +1,4 @@
#!/bin/bash
pkill -9 komodod
pkill -9 chipsd
pkill -9 iguana

5
webworker01/killthemsoftly

@ -0,0 +1,5 @@
#!/bin/bash
#komodo-cli stop
pkill -15 komodod
pkill -15 chipsd
pkill -15 iguana

38
webworker01/kmdacfirewall

@ -0,0 +1,38 @@
#!/bin/bash
sudo apt-get install ufw
sudo ufw disable
sudo ufw default deny incoming
sudo ufw allow 22 comment 'SSH port'
sudo ufw allow 7770 comment 'KMD port'
sudo ufw allow 7775 comment 'Iguana port'
sudo ufw allow 8333 comment 'BTC port'
sudo ufw allow 57777 comment 'CHIPS port'
sudo ufw allow 10195 comment 'REVS asset chain port'
sudo ufw allow 11340 comment 'SUPERNET asset chain port'
sudo ufw allow 11889 comment 'DEX asset chain port'
sudo ufw allow 14067 comment 'PANGEA asset chain port'
sudo ufw allow 15105 comment 'JUMBLR asset chain port'
sudo ufw allow 14249 comment 'BET asset chain port'
sudo ufw allow 8515 comment 'CRYPTO asset chain port'
sudo ufw allow 14430 comment 'HODL asset chain port'
#sudo ufw allow 10113 comment 'SHARK asset chain port'
sudo ufw allow 11963 comment 'BOTS asset chain port'
sudo ufw allow 12385 comment 'MGW asset chain port'
sudo ufw allow 8654 comment 'MVP asset chain port'
sudo ufw allow 12166 comment 'WLC asset chain port'
sudo ufw allow 8298 comment 'KV asset chain port'
sudo ufw allow 11115 comment 'CEAL asset chain port'
sudo ufw allow 9454 comment 'MESH asset chain port'
sudo ufw allow 14336 comment 'MNZ asset chain port'
sudo ufw allow 14275 comment 'COQUI'
sudo ufw allow 8845 comment 'MSHARK'
sudo ufw allow 12926 comment 'AXO'
sudo ufw allow 8799 comment 'BTCH'
sudo ufw allow 10270 comment 'ETOMIC'
sudo ufw allow 15487 comment 'VOTE2018'
sudo ufw allow 8426 comment 'NINJA'
sudo ufw allow 8922 comment 'BEER'
sudo ufw allow 11607 comment 'PIZZA'
sudo ufw enable
# check the status again
sudo ufw status

21
webworker01/networktweaksundo.txt

@ -0,0 +1,21 @@
#https://github.com/KomodoPlatform/KomodoPlatform/wiki/BarterDEX-Network-Optimisations-&-Handle-BarterDEX-on-Very-FAST-Computer
#https://wwwx.cs.unc.edu/~sparkst/howto/network_tuning.php#Steps
#https://wiki.mikejung.biz/Sysctl_tweaks
net.core.rmem_max = 212992
net.core.wmem_max = 212992
net.core.netdev_max_backlog = 1000
net.core.somaxconn = 128
net.ipv4.tcp_rmem = 4096 87380 6291456
net.ipv4.tcp_wmem = 4096 16384 4194304
net.ipv4.tcp_no_metrics_save = 0
net.ipv4.tcp_tw_reuse = 0
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 2048
net.ipv4.tcp_fin_timeout = 60
net.ipv4.tcp_keepalive_time = 7200
net.ipv4.tcp_keepalive_intvl = 75
net.ipv4.tcp_synack_retries = 5
net.ipv4.tcp_syn_retries = 6
net.ipv4.tcp_max_tw_buckets = 262144
net.ipv4.ip_local_port_range = 32768 60999

2
webworker01/notary

@ -0,0 +1,2 @@
cd ~/SuperNET/iguana
git checkout beta && git pull && ./m_notary && cd ~/komodo/src && ./dpowassets

3
webworker01/notarytest

@ -0,0 +1,3 @@
cd ~/SuperNET/iguana
./m_notary_testnet

5
webworker01/rebuildkomodo

@ -0,0 +1,5 @@
#!/bin/bash
cd ~/komodo
git pull --rebase
make clean
./zcutil/build.sh -j$(nproc)

4
webworker01/start

@ -0,0 +1,4 @@
#!/bin/bash
chipsd &
cd komodo
./src/komodod -gen -genproclimit=2 -notary -pubkey="02b207a2be16f205184664c88c8dc842f128a79a3a6c03741e5506cb480cb48268" &

3
webworker01/startac

@ -0,0 +1,3 @@
#!/bin/bash
cd komodo/src
./assetchains

69
webworker01/stats

@ -0,0 +1,69 @@
#!/bin/bash
IFS=
source coinlist
#Change to sleepytime=false if you don't want it to loop
sleepytime=600
utxoamt=0.00010000
ntrzdamt=-0.00083600
format="%-8s %7s %6s %7s %12s\n"
outputstats ()
{
count=0
now=$(date +"%Y-%m-%d %T%z")
printf "\n\n%-8s %7s %6s %7s %12s\n" "-ASSET-" "-NTRZd-" "-UTXO-" "-BLOX-" "-BALANCE-";
printf "%-8s %7s %6s %7s %12s\n" "BTC" \
"$(bitcoin-cli listtransactions "" 77777 | grep -- $ntrzdamt | wc -l)" \
"$(bitcoin-cli listunspent | grep $utxoamt | wc -l)" \
"$(bitcoin-cli getblockchaininfo | awk ' /\"blocks\"/ {printf $2}' | sed 's/,//')" \
"$(bitcoin-cli getbalance)"
kmdinfo=$(komodo-cli getinfo)
printf "$format" "KMD" \
"$(komodo-cli listtransactions "" 77777 | grep -- $ntrzdamt | wc -l)" \
"$(komodo-cli listunspent | grep $utxoamt | wc -l)" \
"$(echo $kmdinfo | awk ' /\"blocks\"/ {printf $2}' | sed 's/,//')" \
"$(echo $kmdinfo | awk ' /\"balance\"/ {printf $2}' | sed 's/,//')" \
chipsinfo=$(chips-cli getinfo)
printf "$format" "CHIPS" \
"$(chips-cli listtransactions "" 77777 | grep -- $ntrzdamt | wc -l)" \
"$(chips-cli listunspent | grep $utxoamt | wc -l)" \
"$(echo $chipsinfo | awk ' /\"blocks\"/ {printf $2}' | sed 's/,//')" \
"$(echo $chipsinfo | awk ' /\"balance\"/ {printf $2}' | sed 's/,//')" \
while [ "x${coinlist[count]}" != "x" ]
do
all=${coinlist[count]}
name=${all%% *}
#if [ "$name" != "" ]
if [ "$name" != "" ] && [ "$name" != "VOTE2018" ]
then
info=$(komodo-cli -ac_name=$name getinfo)
txinfo=$(komodo-cli -ac_name=$name listtransactions "" 77777)
printf "$format" "$name" \
"$(echo $txinfo | grep -- $ntrzdamt | wc -l)" \
"$(komodo-cli -ac_name=$name listunspent | grep $utxoamt | wc -l)" \
"$(echo $info | awk ' /\"blocks\"/ {printf $2}' | sed 's/,//')" \
"$(echo $info | awk ' /\"balance\"/ {printf $2}' | sed 's/,//')"
fi
count=$(( $count +1 ))
done
printf "$now";
}
if [ "$sleepytime" != "false" ]
then
while true
do
outputstats
sleep $sleepytime
done
else
outputstats
echo
fi
#can also grep RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA instead of checking for -0.00418000 if it proves unreliable
Loading…
Cancel
Save