#!/bin/bash # Background: # https://medium.com/@lopp/how-to-run-bitcoin-as-a-tor-hidden-service-on-ubuntu-cff52d543756 # https://bitcoin.stackexchange.com/questions/70069/how-can-i-setup-bitcoin-to-be-anonymous-with-tor # https://github.com/lightningnetwork/lnd/blob/master/docs/configuring_tor.md # load network network=`cat .network` chain="$(${network}-cli getblockchaininfo | jq -r '.chain')" # location of TOR config torrc="/etc/tor/torrc" # check if TOR was already installed and is funtional clear echo "" echo "*** Check if TOR service is functional ***" torRunning=$(curl --connect-timeout 10 --socks5-hostname 127.0.0.1:9050 https://check.torproject.org | grep "Congratulations. This browser is configured to use Tor." -c) if [ ${torRunning} -gt 0 ]; then clear echo "You are all good - TOR is already running." echo "" exit 0 else echo "TOR not running ... proceed with switching to TOR." echo "" fi # ask user if to proceed dialog --title " WARNING " --yesno "At the moment you just can switch TOR on - YOU CANNOT SWITCH BACK. Do you want to proceed?" 8 57 response=$? case $response in 1) exit 1; esac echo "*** Adding Tor Sources to sources.list ***" echo "deb http://deb.torproject.org/torproject.org stretch main" | sudo tee -a /etc/apt/sources.list echo "deb-src http://deb.torproject.org/torproject.org stretch main" | sudo tee -a /etc/apt/sources.list echo "OK" echo "" echo "*** Installing dirmngr ***" sudo apt install dirmngr echo "" ## lopp: gpg --keyserver keys.gnupg.net --recv 886DDD89 echo "*** Fetching GPG key ***" gpg --keyserver keys.gnupg.net --recv A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add - echo "" echo "*** Updating System ***" sudo apt-get update echo "" echo "*** Install Tor ***" sudo apt install tor tor-arm -y echo "" echo "*** Tor Config ***" sudo rm -r -f /mnt/hdd/tor 2>/dev/null sudo mkdir /mnt/hdd/tor sudo mkdir /mnt/hdd/tor/sys sudo mkdir /mnt/hdd/tor/web80 sudo mkdir /mnt/hdd/tor/lnd9735 sudo mkdir /mnt/hdd/tor/lndrpc9735 sudo chmod -R 700 /mnt/hdd/tor sudo chown -R bitcoin:bitcoin /mnt/hdd/tor cat > ./torrc <