Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #/bin/bash
- cd ~
- RED='\033[0;31m'
- GREEN='\033[0;32m'
- NC='\033[0m'
- IP4COUNT=$(find /root/.empirecoincwf_* -maxdepth 0 -type d | wc -l)
- DELETED="$(cat /root/bin/deletedempirecoin | wc -l)"
- ALIASES="$(find /root/.empirecoincwf_* -maxdepth 0 -type d | cut -c22-)"
- face="$(lshw -C network | grep "logical name:" | sed -e 's/logical name:/logical name: /g' | awk '{print $3}' | head -n1)"
- if [[ $EUID -ne 0 ]]; then
- echo -e "${RED}$0 must be run as root.${NC}"
- exit 1
- fi
- function configure_systemd() {
- cat << EOF > /etc/systemd/system/empirecoind$ALIAS.service
- [Unit]
- Description=empirecoind$ALIAS service
- After=network.target
- [Service]
- User=root
- Group=root
- Type=forking
- #PIDFile=/root/.empirecoincwf_$ALIAS/empirecoind.pid
- ExecStart=/root/bin/empirecoind_$ALIAS.sh
- ExecStop=/root/bin/empirecoin-cli_$ALIAS.sh stop
- Restart=always
- PrivateTmp=true
- TimeoutStopSec=60s
- TimeoutStartSec=10s
- StartLimitInterval=120s
- StartLimitBurst=5
- [Install]
- WantedBy=multi-user.target
- EOF
- systemctl daemon-reload
- sleep 6
- crontab -l > cron$ALIAS
- echo "@reboot systemctl start empirecoind$ALIAS" >> cron$ALIAS
- crontab cron$ALIAS
- rm cron$ALIAS
- systemctl start empirecoind$ALIAS.service
- }
- IP4=$(curl -s4 api.ipify.org)
- perl -i -ne 'print if ! $a{$_}++' /etc/network/interfaces
- if [ ! -f "/usr/local/bin/empirecoind" ]; then
- DOSETUP="y"
- else
- DOSETUP="n"
- fi
- clear
- echo "1 - Create new nodes"
- echo "2 - Remove an existing node"
- echo "3 - List aliases"
- echo "4 - Check for node errors"
- echo "What would you like to do?"
- read DO
- echo ""
- if [ $DO = "4" ]
- then
- echo $ALIASES > temp1
- cat temp1 | grep -o '[^ |]*' > temp2
- CN="$(cat temp2 | wc -l)"
- rm temp1
- let LOOP=0
- while [ $LOOP -lt $CN ]; do
- LOOP=$((LOOP+1))
- CURRENT="$(sed -n "${LOOP}p" temp2)"
- echo -e "${GREEN}${CURRENT}${NC}:"
- sh /root/bin/empirecoin-cli_${CURRENT}.sh masternode status | grep "message"
- OFFSET="$(sh /root/bin/empirecoin-cli_${CURRENT}.sh getinfo | grep "timeoffset")"
- OFF1=${OFFSET:(-2)}
- OFF=${OFF1:0:1}
- if [ $OFF = "1" ]
- then
- echo "$OFFSET"
- fi
- done
- rm temp2
- fi
- if [ $DO = "3" ]
- then
- echo -e "${GREEN}${ALIASES}${NC}"
- echo ""
- echo "1 - Create new nodes"
- echo "2 - Remove an existing node"
- echo "What would you like to do?"
- read DO
- echo ""
- fi
- if [ $DO = "2" ]
- then
- perl -i -ne 'print if ! $a{$_}++' /etc/monit/monitrc >/dev/null 2>&1
- echo "Input the alias of the node that you want to delete"
- read ALIASD
- echo ""
- echo -e "${GREEN}Deleting ${ALIASD}${NC}. Please wait."
- ## Removing service
- systemctl stop empirecoind$ALIASD >/dev/null 2>&1
- systemctl disable empirecoind$ALIASD >/dev/null 2>&1
- rm /etc/systemd/system/empirecoind${ALIASD}.service >/dev/null 2>&1
- systemctl daemon-reload >/dev/null 2>&1
- systemctl reset-failed >/dev/null 2>&1
- rm /root/.empirecoincwf_$ALIASD -r >/dev/null 2>&1
- sed -i "/${ALIASD}/d" .bashrc
- crontab -l -u root | grep -v empirecoind$ALIASD | crontab -u root - >/dev/null 2>&1
- source .bashrc
- echo "1" >> /root/bin/deletedempirecoin
- echo -e "${ALIASD} Successfully deleted."
- fi
- if [ $DO = "1" ]
- then
- echo "1 - Easy mode"
- echo "2 - Expert mode"
- echo "Please select a option:"
- read EE
- echo ""
- if [ $EE = "1" ]
- then
- MAXC="64"
- fi
- if [ $EE = "2" ]
- then
- echo ""
- echo "Enter max connections value"
- read MAXC
- fi
- if [ $DOSETUP = "y" ]
- then
- ## Installing pre-requisites
- echo -e "Installing ${GREEN}Empire Coin dependencies${NC}. Please wait."
- apt-get update
- apt-get -y upgrade
- apt install software-properties-common -y
- add-apt-repository universe -y
- apt update
- apt install -y zip unzip bc curl nano lshw ufw gawk libdb++-dev git zip automake software-properties-common unzip build-essential libtool autotools-dev autoconf pkg-config libssl-dev libcrypto++-dev libevent-dev libminiupnpc-dev libgmp-dev libboost-all-dev devscripts libsodium-dev libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler libcrypto++-dev libminiupnpc-dev qt5-default gcc-5 g++-5 --auto-remove
- thr="$(nproc)"
- ## Creating swap
- echo -e "${RED}Creating swap. This may take a while.${NC}"
- dd if=/dev/zero of=/var/swap.img bs=2048 count=1M
- chmod 600 /var/swap.img
- mkswap /var/swap.img
- swapon /var/swap.img
- free -m
- echo "/var/swap.img none swap sw 0 0" >> /etc/fstab
- ## Compatibility issues
- export LC_CTYPE=en_US.UTF-8
- export LC_ALL=en_US.UTF-8
- apt update
- apt install libssl1.0-dev -y
- apt install libzmq3-dev -y --auto-remove
- update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 100
- update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 100
- ## Preparing and building
- git clone https://github.com/EmpireCryptoNetwork/emp.git
- cd emp
- chmod +x */*/*
- ./autogen.sh
- ./configure --with-incompatible-bdb --disable-tests --without-gui
- make -j $thr
- make install
- ## Final configs
- ufw allow ssh/tcp
- ufw limit ssh/tcp
- ufw logging on
- echo "y" | ufw enable
- ufw allow 14321
- echo 'export PATH=~/bin:$PATH' > ~/.bash_aliases
- source ~/.bashrc
- echo ""
- cd
- sysctl vm.swappiness=10
- sysctl vm.vfs_cache_pressure=200
- echo 'vm.swappiness=10' | tee -a /etc/sysctl.conf
- echo 'vm.vfs_cache_pressure=200' | tee -a /etc/sysctl.conf
- fi
- gateway1=$(/sbin/route -A inet6 | grep -v ^fe80 | grep -v ^ff00 | grep -w "$face")
- gateway2=${gateway1:0:26}
- gateway3="$(echo -e "${gateway2}" | tr -d '[:space:]')"
- if [[ $gateway3 = *"128"* ]]; then
- gateway=${gateway3::-5}
- fi
- if [[ $gateway3 = *"64"* ]]; then
- gateway=${gateway3::-3}
- fi
- MASK="/64"
- echo -e "empirecoin nodes currently installed: ${GREEN}${IP4COUNT}${NC}, empirecoin nodes previously Deleted: ${GREEN}${DELETED}${NC}"
- echo ""
- if [ $IP4COUNT = "0" ]
- then
- echo -e "${RED}First node must be ipv4.${NC}"
- let COUNTER=0
- PORT=14321
- RPCPORTT=143210
- RPCPORT=$(($RPCPORTT+$COUNTER))
- echo ""
- echo "Enter alias for first node"
- read ALIAS
- CONF_DIR=~/.empirecoincwf_$ALIAS
- echo ""
- echo "Enter masternode private key for node $ALIAS"
- read PRIVKEY
- mkdir ~/.empirecoincwf_$ALIAS
- echo '#!/bin/bash' > ~/bin/empirecoind_$ALIAS.sh
- echo "empirecoind -daemon -conf=$CONF_DIR/empirecoin.conf -datadir=$CONF_DIR "'$*' >> ~/bin/empirecoind_$ALIAS.sh
- echo '#!/bin/bash' > ~/bin/empirecoin-cli_$ALIAS.sh
- echo "empirecoin-cli -conf=$CONF_DIR/empirecoin.conf -datadir=$CONF_DIR "'$*' >> ~/bin/empirecoin-cli_$ALIAS.sh
- chmod 755 ~/bin/empirecoin*.sh
- mkdir -p $CONF_DIR
- echo "rpcuser=user"`shuf -i 100000-10000000 -n 1` >> empirecoin.conf_TEMP
- echo "rpcpassword=pass"`shuf -i 100000-10000000 -n 1` >> empirecoin.conf_TEMP
- echo "rpcallowip=127.0.0.1" >> empirecoin.conf_TEMP
- echo "rpcport=$RPCPORT" >> empirecoin.conf_TEMP
- echo "listen=1" >> empirecoin.conf_TEMP
- echo "server=1" >> empirecoin.conf_TEMP
- echo "daemon=1" >> empirecoin.conf_TEMP
- echo "logtimestamps=1" >> empirecoin.conf_TEMP
- echo "maxconnections=$MAXC" >> empirecoin.conf_TEMP
- echo "masternode=1" >> empirecoin.conf_TEMP
- echo "dbcache=20" >> empirecoin.conf_TEMP
- echo "maxorphantx=5" >> empirecoin.conf_TEMP
- echo "maxmempool=100" >> empirecoin.conf_TEMP
- echo "" >> empirecoin.conf_TEMP
- echo "" >> empirecoin.conf_TEMP
- echo "bind=$IP4:$PORT" >> empirecoin.conf_TEMP
- echo "externalip=$IP4" >> empirecoin.conf_TEMP
- echo "masternodeaddr=$IP4:$PORT" >> empirecoin.conf_TEMP
- echo "masternodeprivkey=$PRIVKEY" >> empirecoin.conf_TEMP
- mv empirecoin.conf_TEMP $CONF_DIR/empirecoin.conf
- echo ""
- echo -e "Your ip is ${GREEN}$IP4:$PORT${NC}"
- echo "alias ${ALIAS}_status=\"empirecoin-cli -datadir=/root/.empirecoincwf_${ALIAS} masternode status\"" >> .bashrc
- echo "alias ${ALIAS}_stop=\"systemctl stop empirecoind$ALIAS\"" >> .bashrc
- echo "alias ${ALIAS}_start=\"systemctl start empirecoind$ALIAS\"" >> .bashrc
- echo "alias ${ALIAS}_config=\"nano /root/.empirecoincwf_${ALIAS}/empirecoin.conf\"" >> .bashrc
- echo "alias ${ALIAS}_getinfo=\"empirecoin-cli -datadir=/root/'.empirecoincwf_${ALIAS} getinfo\"" >> .bashrc
- echo "alias ${ALIAS}_getpeerinfo=\"empirecoin-cli -datadir=/root/.empirecoincwf_${ALIAS} getpeerinfo\"" >> .bashrc
- echo "alias ${ALIAS}_resync=\"/root/bin/empirecoind_${ALIAS}.sh -resync\"" >> .bashrc
- echo "alias ${ALIAS}_reindex=\"/root/bin/empirecoind_${ALIAS}.sh -reindex\"" >> .bashrc
- echo "alias ${ALIAS}_restart=\"systemctl restart empirecoind$ALIAS\"" >> .bashrc
- ## Config Systemctl
- configure_systemd
- fi
- if [ $IP4COUNT != "0" ]
- then
- echo "How many ipv6 nodes do you want to install on this server?"
- read MNCOUNT
- let MNCOUNT=MNCOUNT+1
- let MNCOUNT=MNCOUNT+IP4COUNT
- let MNCOUNT=MNCOUNT+DELETED
- let COUNTER=1
- let COUNTER=COUNTER+IP4COUNT
- let COUNTER=COUNTER+DELETED
- while [ $COUNTER -lt $MNCOUNT ]; do
- PORT=14321
- RPCPORTT=143210
- RPCPORT=$(($RPCPORTT+$COUNTER))
- echo ""
- echo "Enter alias for new node"
- read ALIAS
- CONF_DIR=~/.empirecoincwf_$ALIAS
- echo ""
- echo "Enter masternode private key for node $ALIAS"
- read PRIVKEY
- echo "up /sbin/ip -6 addr add ${gateway}$COUNTER$MASK dev $face # $ALIAS" >> /etc/network/interfaces
- /sbin/ip -6 addr add ${gateway}$COUNTER$MASK dev $face
- mkdir ~/.empirecoincwf_$ALIAS
- unzip Bootstrap.zip -d ~/.empirecoincwf_$ALIAS >/dev/null 2>&1
- echo '#!/bin/bash' > ~/bin/empirecoind_$ALIAS.sh
- echo "empirecoind -daemon -conf=$CONF_DIR/empirecoin.conf -datadir=$CONF_DIR "'$*' >> ~/bin/empirecoind_$ALIAS.sh
- echo '#!/bin/bash' > ~/bin/empirecoin-cli_$ALIAS.sh
- echo "empirecoin-cli -conf=$CONF_DIR/empirecoin.conf -datadir=$CONF_DIR "'$*' >> ~/bin/empirecoin-cli_$ALIAS.sh
- chmod 755 ~/bin/empirecoin*.sh
- mkdir -p $CONF_DIR
- echo "rpcuser=user"`shuf -i 100000-10000000 -n 1` >> empirecoin.conf_TEMP
- echo "rpcpassword=pass"`shuf -i 100000-10000000 -n 1` >> empirecoin.conf_TEMP
- echo "rpcallowip=127.0.0.1" >> empirecoin.conf_TEMP
- echo "rpcport=$RPCPORT" >> empirecoin.conf_TEMP
- echo "listen=1" >> empirecoin.conf_TEMP
- echo "server=1" >> empirecoin.conf_TEMP
- echo "daemon=1" >> empirecoin.conf_TEMP
- echo "logtimestamps=1" >> empirecoin.conf_TEMP
- echo "maxconnections=$MAXC" >> empirecoin.conf_TEMP
- echo "masternode=1" >> empirecoin.conf_TEMP
- echo "dbcache=20" >> empirecoin.conf_TEMP
- echo "maxorphantx=5" >> empirecoin.conf_TEMP
- echo "maxmempool=100" >> empirecoin.conf_TEMP
- echo "bind=[${gateway}$COUNTER]:$PORT" >> empirecoin.conf_TEMP
- echo "externalip=[${gateway}$COUNTER]" >> empirecoin.conf_TEMP
- echo "masternodeaddr=[${gateway}$COUNTER]:$PORT" >> empirecoin.conf_TEMP
- echo "masternodeprivkey=$PRIVKEY" >> empirecoin.conf_TEMP
- mv empirecoin.conf_TEMP $CONF_DIR/empirecoin.conf
- echo ""
- echo -e "Your ip is ${GREEN}[${gateway}$COUNTER]:$PORT${NC}"
- echo "alias ${ALIAS}_status=\"empirecoin-cli -datadir=/root/.empirecoincwf_${ALIAS} masternode status\"" >> .bashrc
- echo "alias ${ALIAS}_stop=\"systemctl stop empirecoind$ALIAS\"" >> .bashrc
- echo "alias ${ALIAS}_start=\"systemctl start empirecoind$ALIAS\"" >> .bashrc
- echo "alias ${ALIAS}_config=\"nano /root/.empirecoincwf_${ALIAS}/empirecoin.conf\"" >> .bashrc
- echo "alias ${ALIAS}_getinfo=\"empirecoin-cli -datadir=/root/.empirecoincwf_${ALIAS} getinfo\"" >> .bashrc
- echo "alias ${ALIAS}_getpeerinfo=\"empirecoin-cli -datadir=/root/.empirecoincwf_${ALIAS} getpeerinfo\"" >> .bashrc
- echo "alias ${ALIAS}_resync=\"/root/bin/empirecoind_${ALIAS}.sh -resync\"" >> .bashrc
- echo "alias ${ALIAS}_reindex=\"/root/bin/empirecoind_${ALIAS}.sh -reindex\"" >> .bashrc
- echo "alias ${ALIAS}_restart=\"systemctl restart empirecoind$ALIAS\"" >> .bashrc
- ## Config Systemctl
- configure_systemd
- COUNTER=$((COUNTER+1))
- done
- fi
- echo ""
- echo "Commands:"
- echo "${ALIAS}_start"
- echo "${ALIAS}_restart"
- echo "${ALIAS}_status"
- echo "${ALIAS}_stop"
- echo "${ALIAS}_config"
- echo "${ALIAS}_getinfo"
- echo "${ALIAS}_getpeerinfo"
- echo "${ALIAS}_resync"
- echo "${ALIAS}_reindex"
- fi
- echo ""
- echo "Made by lobo"
- echo "Bitcoin Address for donations: 1NqYjVMA5DhuLytt33HYgP5qBajeHLYn4d"
- exec bash
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement