This commit is contained in:
Christian Rotzoll 2019-06-12 23:40:56 +02:00
parent b171355a86
commit 5b52b54d31
2 changed files with 45 additions and 56 deletions

View File

@ -117,6 +117,15 @@ else
echo "Provisioning TESTNET - keep default" >> ${logFile}
fi
# TOR
if [ "${runBehindTor}" = "on" ]; then
echo "Provisioning TOR - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup TOR (takes time)'/g" ${infoFile}
sudo /home/admin/config.scripts/internet.tor.sh on >> ${logFile} 2>&1
else
echo "Provisioning TOR - keep default" >> ${logFile}
fi
# AUTO PILOT
if [ "${autoPilot}" = "on" ]; then
echo "Provisioning AUTO PILOT - run config script" >> ${logFile}
@ -154,15 +163,6 @@ else
echo "Provisioning RTL - keep default" >> ${logFile}
fi
# TOR
if [ "${runBehindTor}" = "on" ]; then
echo "Provisioning TOR - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup TOR (takes time)'/g" ${infoFile}
sudo /home/admin/config.scripts/internet.tor.sh on >> ${logFile} 2>&1
else
echo "Provisioning TOR - keep default" >> ${logFile}
fi
# CUSTOM PORT
echo "Provisioning LND Port" >> ${logFile}
if [ ${#lndPort} -eq 0 ]; then

View File

@ -92,7 +92,7 @@ fi
sudo mkdir /etc/tor 2>/dev/null
torrc="/etc/tor/torrc"
# stop services
# stop services (if running)
echo "making sure services are not running"
sudo systemctl stop lnd 2>/dev/null
sudo systemctl stop ${network}d 2>/dev/null
@ -197,47 +197,45 @@ EOF
echo "NYX already installed"
fi
echo ""
echo "*** Activating TOR system service ***"
echo "ReadWriteDirectories=-/mnt/hdd/tor" | sudo tee -a /lib/systemd/system/tor@default.service
sudo systemctl daemon-reload
sudo systemctl enable tor@default
echo ""
echo "*** Changing ${network} Config ***"
networkIsTor=$(sudo cat /home/bitcoin/.${network}/${network}.conf | grep 'onlynet=onion' -c)
if [ ${networkIsTor} -eq 0 ]; then
echo "Only Connect thru TOR"
sudo chmod 777 /home/bitcoin/.${network}/${network}.conf
echo "onlynet=onion" >> /home/bitcoin/.${network}/${network}.conf
if [ "${network}" = "bitcoin" ]; then
echo "Adding some bitcoin onion nodes to connect to"
echo "addnode=fno4aakpl6sg6y47.onion" >> /home/bitcoin/.${network}/${network}.conf
echo "addnode=toguvy5upyuctudx.onion" >> /home/bitcoin/.${network}/${network}.conf
echo "addnode=ndndword5lpb7eex.onion" >> /home/bitcoin/.${network}/${network}.conf
echo "addnode=6m2iqgnqjxh7ulyk.onion" >> /home/bitcoin/.${network}/${network}.conf
echo "addnode=5tuxetn7tar3q5kp.onion" >> /home/bitcoin/.${network}/${network}.conf
fi
sudo chmod 444 /home/bitcoin/.${network}/${network}.conf
sudo cp /home/bitcoin/.${network}/${network}.conf /home/admin/.${network}/${network}.conf
sudo chown admin:admin /home/admin/.${network}/${network}.conf
else
echo "Chain network already configured for TOR"
fi
else
echo "TOR package/service is installed and was prepared earlier .. just activating again"
fi
echo "*** Enable TOR service ***"
sudo systemctl daemon-reload
sudo systemctl enable tor@default
echo ""
# ACTIVATE TOR SERVICE
echo "*** Enable TOR Service ***"
sudo systemctl daemon-reload
sudo systemctl enable tor@default
echo ""
# ACTIVATE BITCOIN OVER TOR
echo "*** Changing ${network} Config ***"
networkIsTor=$(sudo cat /home/bitcoin/.${network}/${network}.conf | grep 'onlynet=onion' -c)
if [ ${networkIsTor} -eq 0 ]; then
# clean all previous added nodes
sudo sed -i "s/^addnode=.*//g" /home/bitcoin/.${network}/${network}.conf
echo "Addding TOR config ..."
sudo chmod 777 /home/bitcoin/.${network}/${network}.conf
echo "onlynet=onion" >> /home/bitcoin/.${network}/${network}.conf
if [ "${network}" = "bitcoin" ]; then
# adding some bitcoin onion nodes to connect to to make connection easier
echo "addnode=fno4aakpl6sg6y47.onion" >> /home/bitcoin/.${network}/${network}.conf
echo "addnode=toguvy5upyuctudx.onion" >> /home/bitcoin/.${network}/${network}.conf
echo "addnode=ndndword5lpb7eex.onion" >> /home/bitcoin/.${network}/${network}.conf
echo "addnode=6m2iqgnqjxh7ulyk.onion" >> /home/bitcoin/.${network}/${network}.conf
echo "addnode=5tuxetn7tar3q5kp.onion" >> /home/bitcoin/.${network}/${network}.conf
fi
sudo chmod 444 /home/bitcoin/.${network}/${network}.conf
sudo cp /home/bitcoin/.${network}/${network}.conf /home/admin/.${network}/${network}.conf
sudo chown admin:admin /home/admin/.${network}/${network}.conf
else
echo "Chain network already configured for TOR"
fi
# ACTIVATE LND OVER TOR
@ -271,17 +269,8 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo ""
echo "*** Changing ${network} Config ***"
sudo chmod 777 /home/bitcoin/.${network}/${network}.conf
startLineNumber=$(cat /home/bitcoin/.${network}/${network}.conf | grep -n 'onlynet=onion' | sed 's/^\([0-9]\+\):.*$/\1/')
startLineNumber=$(($startLineNumber-1))
if [ ${startLineNumber} -gt 0 ]; then
sed -n '1,${startLineNumber}p' /home/bitcoin/.${network}/${network}.conf > /home/bitcoin/.${network}/${network}.conf
else
echo "FAIL: Was not able to remove TOR config vrom bitcoin.conf "
sleep 10
fi
# sudo cat /home/bitcoin/.${network}/${network}.conf | grep -Ev 'onlynet=onion|.onion' | sudo tee /home/bitcoin/.${network}/${network}.conf
sudo chmod 444 /home/bitcoin/.${network}/${network}.conf
sudo sed -i "s/^onlynet=.*//g" /home/bitcoin/.${network}/${network}.conf
sudo sed -i "s/^addnode=.*//g" /home/bitcoin/.${network}/${network}.conf
sudo cp /home/bitcoin/.${network}/${network}.conf /home/admin/.${network}/${network}.conf
sudo chown admin:admin /home/admin/.${network}/${network}.conf
echo ""