Last active
July 18, 2017 10:33
-
-
Save pointbiz/244014c3961c3ed837fc to your computer and use it in GitHub Desktop.
bitcoin full node setup script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#setup script | |
yum update | |
yum install nano | |
homedir=~/ | |
fbtcinfo=btcinfo.sh | |
echo -e "./bitcoin-cli -datadir=$homedir.bitcoin getinfo | |
echo -n \"device ip: \" | |
ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\\.){3}[0-9]*).*/\2/p' | |
date" > $fbtcinfo | |
chmod 700 $fbtcinfo | |
fbtcstart=btcstart.sh | |
echo -e "#!/bin/bash | |
#start bitcoind | |
#check system date | |
d=$(date +%s) | |
echo \"\$d\" | |
if [ \"\$d\" -lt \"1422748800\" ]; then | |
echo \"system date is incorrect, aborted startup\" >> $homedir./.cron.log | |
exit 0 | |
fi | |
$homedir./bitcoind -datadir=$homedir.bitcoin -daemon | |
exit 0" > $fbtcstart | |
chmod 700 $fbtcstart | |
fbtcstop=btcstop.sh | |
echo -e "#!/bin/bash | |
$homedir./bitcoin-cli -datadir=$homedir.bitcoin stop | |
echo "Do not shut down the device until notified" | |
x=\$(pgrep -f bitcoind) | |
while [ \"\$x\" != \"\" ] | |
do | |
echo -n \".\" | |
sleep 1s | |
x=\$(pgrep -f bitcoind) | |
done | |
echo \"bitcoin has stopped. OK to shutdown\" " > $fbtcstop | |
chmod 700 $fbtcstop | |
fblockstatus=blockstatus.sh | |
echo -e "#!/bin/bash | |
#get current block height from blockchain.info | |
echo \$(date) | |
wget -4 https://blockchain.info/q/getblockcount &> /dev/null | |
netblk=\$(<getblockcount) | |
echo \"Current Block: \$netblk\" | |
#get current block from local bitcoin-cli | |
./bitcoin-cli getblockcount > locblock | |
nodeblk=\$(<locblock) | |
echo \"Local Block: \$nodeblk\" | |
#if bitcoin-cli responds, compare local with network blocks | |
if [ \"\$nodeblk\" == \"\" ]; then | |
echo \"checking recent blocks. please wait\" | |
else | |
diff=\$((netblk-nodeblk)) | |
echo \"\$diff\" \"blocks behind\" | |
rm getblockcount | |
rm locblock | |
fi" > $fblockstatus | |
chmod 700 $fblockstatus | |
fgetonionaddr=getonionaddr.sh | |
echo -e "#get onion address | |
cat /var/lib/tor/bitcoin-service/hostname > $HOME/onionaddr | |
onion=$(<$HOME/onionaddr) | |
echo $onion" > $fgetonionaddr | |
chmod 700 $fgetonionaddr | |
ftorprojectrepo=/etc/yum.repos.d/torproject.repo | |
echo -e "[tor] | |
name=Tor repo | |
enabled=1 | |
baseurl=https://deb.torproject.org/torproject.org/rpm/el/6/$basearch/ | |
gpgcheck=1 | |
gpgkey=https://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc | |
repo_gpgcheck=1" > $ftorprojectrepo | |
#yum install tor | |
#echo "HiddenServiceDir /var/lib/tor/bitcoin-service/" >> /etc/tor/torrc | |
#echo "HiddenServicePort 8333 127.0.0.1:8333" >> /etc/tor/torrc | |
#service tor start | |
wget https://github.com/bitcoinclassic/bitcoinclassic/releases/download/v0.12.0cl1/bitcoin-0.12.0-linux64.tar.gz | |
tar -zxvf bitcoin-0.12.0-linux64.tar.gz | |
cp bitcoin-0.12.0/bin/bitcoind ~/bitcoind | |
cp bitcoin-0.12.0/bin/bitcoin-cli ~/bitcoin-cli | |
mkdir .bitcoin | |
echo " | |
rpcuser=bitcoinrpc | |
rpcpassword=lkjadlkfjasuealksdj3ue823a | |
server=1 | |
listen=1 | |
disablewallet=1 | |
dbcache=1200 | |
maxconnections=50 | |
port=8333 | |
#externalip= | |
#onlynet=Tor | |
#onion=127.0.0.1:9050 | |
#bind=127.0.0.1:8333 | |
#seednode=nkf5e6b7pl4jfd4a.onion | |
#seednode=xqzfakpeuvrobvpj.onion | |
#seednode=tsyvzsqwa2kkf6b2.onion | |
" >> .bitcoin/bitcoin.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment