@ -0,0 +1,363 @@ |
|||||
|
#!/bin/bash |
||||
|
######################################################################### |
||||
|
# Build your SD card image based on: |
||||
|
# RASPBIAN STRETCH WITH DESKTOP (2018-06-27) |
||||
|
# https://www.raspberrypi.org/downloads/raspbian/ |
||||
|
# SHA256: 8636ab9fdd8f58a8ec7dde33b83747696d31711d17ef68267dbbcd6cfb968c24 |
||||
|
########################################################################## |
||||
|
# setup fresh SD card with image above - login per SSH and run this script: |
||||
|
########################################################################## |
||||
|
|
||||
|
echo "" |
||||
|
echo "***************************************" |
||||
|
echo "* RASPIBLITZ SD CARD IMAGE SETUP v0.9 *" |
||||
|
echo "***************************************" |
||||
|
echo "" |
||||
|
|
||||
|
echo "" |
||||
|
echo "*** RASPI CONFIG ***" |
||||
|
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#raspi-config |
||||
|
|
||||
|
# set new default passwort for pi and root user |
||||
|
echo "root:raspiblitz" | sudo chpasswd |
||||
|
echo "pi:raspiblitz" | sudo chpasswd |
||||
|
|
||||
|
# set Raspi to boot up automatically with user pi (for the LCD) |
||||
|
# https://www.raspberrypi.org/forums/viewtopic.php?t=21632 |
||||
|
sudo raspi-config nonint do_boot_behaviour B2 |
||||
|
sudo bash -c "echo '[Service]' >> /etc/systemd/system/getty@tty1.service.d/autologin.conf" |
||||
|
sudo bash -c "echo 'ExecStart=' >> /etc/systemd/system/getty@tty1.service.d/autologin.conf" |
||||
|
sudo bash -c "echo 'ExecStart=-/sbin/agetty --autologin pi --noclear %I 38400 linux' >> /etc/systemd/system/getty@tty1.service.d/autologin.conf" |
||||
|
|
||||
|
# do memory split (16MB) |
||||
|
sudo raspi-config nonint do_memory_split 16 |
||||
|
|
||||
|
# set to wait until network is available on boot (0 seems to yes) |
||||
|
sudo raspi-config nonint do_boot_wait 0 |
||||
|
|
||||
|
# autodetect and set your timezone |
||||
|
pip install -U tzupdate |
||||
|
sleep 2 |
||||
|
sudo tzupdate |
||||
|
|
||||
|
echo "" |
||||
|
echo "*** SOFTWARE UPDATE ***" |
||||
|
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#software-update |
||||
|
|
||||
|
# installs like on RaspiBolt |
||||
|
sudo apt-get update |
||||
|
sudo apt-get upgrade -f -y --allow-change-held-packages |
||||
|
sudo apt-get install -y htop git curl bash-completion jq dphys-swapfile |
||||
|
|
||||
|
# extra: remove some big packages not needed |
||||
|
sudo apt-get remove -y --purge libreoffice* |
||||
|
sudo apt-get clean |
||||
|
sudo apt-get -y autoremove |
||||
|
|
||||
|
echo "" |
||||
|
echo "*** ADDING MAIN USER admin ***" |
||||
|
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#adding-main-user-admin |
||||
|
# using the default password 'raspiblitz' |
||||
|
|
||||
|
sudo adduser --disabled-password --gecos "" admin |
||||
|
echo "admin:raspiblitz" | sudo chpasswd |
||||
|
sudo adduser admin sudo |
||||
|
sudo chsh admin -s /bin/bash |
||||
|
|
||||
|
# configure sudo for usage without password entry |
||||
|
echo '%sudo ALL=(ALL) NOPASSWD:ALL' | sudo EDITOR='tee -a' visudo |
||||
|
|
||||
|
echo "*** ADDING SERVICE USER bitcoin" |
||||
|
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#adding-the-service-user-bitcoin |
||||
|
|
||||
|
# create user and set default password for user |
||||
|
sudo adduser --disabled-password --gecos "" bitcoin |
||||
|
echo "bitcoin:raspiblitz" | sudo chpasswd |
||||
|
|
||||
|
echo "" |
||||
|
echo "*** SWAP FILE ***" |
||||
|
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#moving-the-swap-file |
||||
|
# but just deactivating and deleting old (will be created alter when user adds HDD) |
||||
|
|
||||
|
sudo dphys-swapfile swapoff |
||||
|
sudo dphys-swapfile uninstall |
||||
|
|
||||
|
echo "" |
||||
|
echo "*** HARDENING ***" |
||||
|
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#hardening-your-pi |
||||
|
|
||||
|
# fail2ban (no config required) |
||||
|
sudo apt-get install -y fail2ban |
||||
|
|
||||
|
echo "" |
||||
|
echo "*** INCREASE OPEN FILE LIMIT ***" |
||||
|
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#increase-your-open-files-limit |
||||
|
|
||||
|
sudo sed --in-place -i "56s/.*/* soft nofile 128000/" /etc/security/limits.conf |
||||
|
sudo bash -c "echo '* hard nofile 128000' >> /etc/security/limits.conf" |
||||
|
sudo bash -c "echo 'root soft nofile 128000' >> /etc/security/limits.conf" |
||||
|
sudo bash -c "echo 'root hard nofile 128000' >> /etc/security/limits.conf" |
||||
|
sudo bash -c "echo '# End of file' >> /etc/security/limits.conf" |
||||
|
|
||||
|
sudo sed --in-place -i "23s/.*/session required pam_limits.so/" /etc/pam.d/common-session |
||||
|
|
||||
|
sudo sed --in-place -i "25s/.*/session required pam_limits.so/" /etc/pam.d/common-session-noninteractive |
||||
|
sudo bash -c "echo '# end of pam-auth-update config' >> /etc/pam.d/common-session-noninteractive" |
||||
|
|
||||
|
echo "" |
||||
|
echo "*** BITCOIN ***" |
||||
|
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_30_bitcoin.md#installation |
||||
|
|
||||
|
# set version (change if update is available) |
||||
|
bitcoinVersion="0.16.2" |
||||
|
laanwjPGP="01EA5486DE18A882D4C2684590C8019E36C2E964" |
||||
|
|
||||
|
# prepare directories |
||||
|
sudo -u admin mkdir /home/admin/download |
||||
|
cd /home/admin/download |
||||
|
|
||||
|
# download resources |
||||
|
sudo -u admin wget https://bitcoin.org/bin/bitcoin-core-${bitcoinVersion}/bitcoin-${bitcoinVersion}-arm-linux-gnueabihf.tar.gz |
||||
|
if [ ! -f "./bitcoin-${bitcoinVersion}-arm-linux-gnueabihf.tar.gz" ] |
||||
|
then |
||||
|
echo "!!! FAIL !!! Download BITCOIN BINARY not success." |
||||
|
exit 1 |
||||
|
fi |
||||
|
sudo -u admin wget https://bitcoin.org/bin/bitcoin-core-${bitcoinVersion}/SHA256SUMS.asc |
||||
|
if [ ! -f "./SHA256SUMS.asc" ] |
||||
|
then |
||||
|
echo "!!! FAIL !!! Download SHA256SUMS.asc not success." |
||||
|
exit 1 |
||||
|
fi |
||||
|
sudo -u admin wget https://bitcoin.org/laanwj-releases.asc |
||||
|
if [ ! -f "./laanwj-releases.asc" ] |
||||
|
then |
||||
|
echo "!!! FAIL !!! Download laanwj-releases.asc not success." |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# test checksum |
||||
|
checksum=$(sha256sum --check SHA256SUMS.asc --ignore-missing 2>/dev/null | grep '.tar.gz: OK' -c) |
||||
|
if [ ${checksum} -lt 1 ]; then |
||||
|
echo "" |
||||
|
echo "!!! BUILD FAILED --> Bitcoin download checksum not OK" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# check gpg finger print |
||||
|
fingerprint=$(gpg ./laanwj-releases.asc 2>/dev/null | grep "${laanwjPGP}" -c) |
||||
|
if [ ${fingerprint} -lt 1 ]; then |
||||
|
echo "" |
||||
|
echo "!!! BUILD FAILED --> Bitcoin download PGP author not OK" |
||||
|
exit 1 |
||||
|
fi |
||||
|
gpg --import ./laanwj-releases.asc |
||||
|
verifyResult=$(gpg --verify SHA256SUMS.asc 2>&1) |
||||
|
goodSignature=$(echo ${verifyResult} | grep 'Good signature' -c) |
||||
|
echo "goodSignature(${goodSignature})" |
||||
|
correctKey=$(echo ${verifyResult} | grep "using RSA key ${laanwjPGP: -16}" -c) |
||||
|
echo "correctKey(${correctKey})" |
||||
|
if [ ${correctKey} -lt 1 ] || [ ${goodSignature} -lt 1 ]; then |
||||
|
echo "" |
||||
|
echo "!!! BUILD FAILED --> LND PGP Verify not OK / signatute(${goodSignature}) verify(${correctKey})" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# install |
||||
|
sudo -u admin tar -xvf bitcoin-${bitcoinVersion}-arm-linux-gnueabihf.tar.gz |
||||
|
sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-${bitcoinVersion}/bin/* |
||||
|
sleep 3 |
||||
|
installed=$(sudo -u admin bitcoind --version | grep "${bitcoinVersion}" -c) |
||||
|
if [ ${installed} -lt 1 ]; then |
||||
|
echo "" |
||||
|
echo "!!! BUILD FAILED --> Was not able to install bitcoind version(${bitcoinVersion})" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
echo "" |
||||
|
echo "*** LITECOIN ***" |
||||
|
# based on https://medium.com/@jason.hcwong/litecoin-lightning-with-raspberry-pi-3-c3b931a82347 |
||||
|
|
||||
|
# set version (change if update is available) |
||||
|
litecoinVersion="0.16.0" |
||||
|
cd /home/admin/download |
||||
|
sudo -u admin wget https://download.litecoin.org/litecoin-${litecoinVersion}/linux/litecoin-${litecoinVersion}-arm-linux-gnueabihf.tar.gz |
||||
|
sudo -u admin tar -xvf litecoin-${litecoinVersion}-arm-linux-gnueabihf.tar.gz |
||||
|
sudo install -m 0755 -o root -g root -t /usr/local/bin litecoin-${litecoinVersion}/bin/* |
||||
|
installed=$(sudo -u admin litecoind --version | grep "${litecoinVersion}" -c) |
||||
|
if [ ${installed} -lt 1 ]; then |
||||
|
echo "" |
||||
|
echo "!!! BUILD FAILED --> Was not able to install litecoind version(${litecoinVersion})" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
echo "" |
||||
|
echo "*** LND ***" |
||||
|
|
||||
|
## based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_40_lnd.md#lightning-lnd |
||||
|
#lndVersion="0.5-beta-rc1" |
||||
|
#olaoluwaPGP="65317176B6857F98834EDBE8964EA263DD637C21" |
||||
|
# |
||||
|
# get LND resources |
||||
|
#cd /home/admin/download |
||||
|
#sudo -u admin wget https://github.com/lightningnetwork/lnd/releases/download/v${lndVersion}/lnd-linux-arm-v${lndVersion}.tar.gz |
||||
|
#sudo -u admin wget https://github.com/lightningnetwork/lnd/releases/download/v${lndVersion}/manifest-v${lndVersion}.txt |
||||
|
#sudo -u admin wget https://github.com/lightningnetwork/lnd/releases/download/v${lndVersion}/manifest-v${lndVersion}.txt.sig |
||||
|
#sudo -u admin wget https://keybase.io/roasbeef/pgp_keys.asc |
||||
|
## test checksum |
||||
|
#checksum=$(sha256sum --check manifest-v${lndVersion}.txt --ignore-missing 2>/dev/null | grep '.tar.gz: OK' -c) |
||||
|
#if [ ${checksum} -lt 1 ]; then |
||||
|
# echo "" |
||||
|
# echo "!!! BUILD FAILED --> LND download checksum not OK" |
||||
|
# exit 1 |
||||
|
#fi |
||||
|
## check gpg finger print |
||||
|
#fingerprint=$(gpg ./pgp_keys.asc 2>/dev/null | grep "${olaoluwaPGP}" -c) |
||||
|
#if [ ${fingerprint} -lt 1 ]; then |
||||
|
# echo "" |
||||
|
# echo "!!! BUILD FAILED --> LND download author PGP not OK" |
||||
|
# exit 1 |
||||
|
#fi |
||||
|
#gpg --import ./pgp_keys.asc |
||||
|
#sleep 2 |
||||
|
#verifyResult=$(gpg --verify manifest-v${lndVersion}.txt.sig manifest-v${lndVersion}.txt 2>&1) |
||||
|
#goodSignature=$(echo ${verifyResult} | grep 'Good signature' -c) |
||||
|
#echo "goodSignature(${goodSignature})" |
||||
|
#correctKey=$(echo ${verifyResult} | grep "using RSA key ${olaoluwaPGP: -16}" -c) |
||||
|
#echo "correctKey(${correctKey})" |
||||
|
#if [ ${correctKey} -lt 1 ] || [ ${goodSignature} -lt 1 ]; then |
||||
|
# echo "" |
||||
|
# echo "!!! BUILD FAILED --> LND PGP Verify not OK / signatute(${goodSignature}) verify(${correctKey})" |
||||
|
# exit 1 |
||||
|
#fi |
||||
|
## install |
||||
|
#sudo -u admin tar -xzf lnd-linux-arm-v${lndVersion}.tar.gz |
||||
|
#sudo install -m 0755 -o root -g root -t /usr/local/bin lnd-linux-arm-v${lndVersion}/* |
||||
|
#sleep 3 |
||||
|
#installed=$(sudo -u admin lnd --version | grep "${lndVersion}" -c) |
||||
|
#if [ ${installed} -lt 1 ]; then |
||||
|
# echo "" |
||||
|
# echo "!!! BUILD FAILED --> Was not able to install LND version(${lndVersion})" |
||||
|
# exit 1 |
||||
|
#fi |
||||
|
|
||||
|
##### Build from Source |
||||
|
# To quickly catch up get latest patches if needed |
||||
|
repo="github.com/lightningnetwork/lnd" |
||||
|
commit="a1f549754b61c1ba84466f0226997687127f7fc0" |
||||
|
# BUILDING LND FROM SOURCE |
||||
|
echo "*** Installing Go ***" |
||||
|
wget https://storage.googleapis.com/golang/go1.10.linux-armv6l.tar.gz |
||||
|
if [ ! -f "./go1.10.linux-armv6l.tar.gz" ] |
||||
|
then |
||||
|
echo "!!! FAIL !!! Download not success." |
||||
|
exit 1 |
||||
|
fi |
||||
|
sudo tar -C /usr/local -xzf go1.10.linux-armv6l.tar.gz |
||||
|
sudo rm *.gz |
||||
|
sudo mkdir /usr/local/gocode |
||||
|
sudo chmod 777 /usr/local/gocode |
||||
|
export GOROOT=/usr/local/go |
||||
|
export PATH=$PATH:$GOROOT/bin |
||||
|
export GOPATH=/usr/local/gocode |
||||
|
export PATH=$PATH:$GOPATH/bin |
||||
|
echo "*** Build LND from Source ***" |
||||
|
go get -d $repo |
||||
|
# make sure to always have the same code (commit) to build |
||||
|
# TODO: To update lnd -> change to latest commit |
||||
|
cd $GOPATH/src/$repo |
||||
|
sudo git checkout $commit |
||||
|
make && make install |
||||
|
sudo chmod 555 /usr/local/gocode/bin/lncli |
||||
|
sudo chmod 555 /usr/local/gocode/bin/lnd |
||||
|
sudo bash -c "echo 'export PATH=$PATH:/usr/local/gocode/bin/' >> /home/admin/.bashrc" |
||||
|
sudo bash -c "echo 'export PATH=$PATH:/usr/local/gocode/bin/' >> /home/pi/.bashrc" |
||||
|
sudo bash -c "echo 'export PATH=$PATH:/usr/local/gocode/bin/' >> /home/bitcoin/.bashrc" |
||||
|
lndVersionCheck=$(lncli --version) |
||||
|
echo "LND VERSION: ${lndVersionCheck}" |
||||
|
if [ ${#lndVersionCheck} -eq 0 ]; then |
||||
|
echo "FAIL - Something went wrong with building LND from source." |
||||
|
echo "Sometimes it may just be a connection issue. Reset to fresh Rasbian and try again?" |
||||
|
exit 1 |
||||
|
fi |
||||
|
echo "" |
||||
|
echo "** Link to /usr/local/bin ***" |
||||
|
sudo ln -s /usr/local/gocode/bin/lncli /usr/local/bin/lncli |
||||
|
sudo ln -s /usr/local/gocode/bin/lnd /usr/local/bin/lnd |
||||
|
|
||||
|
echo "" |
||||
|
echo "*** RASPIBLITZ EXTRAS ***" |
||||
|
|
||||
|
# for setup schell scripts |
||||
|
sudo apt-get -y install dialog bc |
||||
|
|
||||
|
# enable copy of blockchain from 2nd HDD formatted with exFAT |
||||
|
sudo apt-get -y install exfat-fuse |
||||
|
|
||||
|
# for blockchain torrent download |
||||
|
sudo apt-get -y install transmission-cli |
||||
|
|
||||
|
# for background downloading |
||||
|
sudo apt-get -y install screen |
||||
|
|
||||
|
# optimization for torrent download |
||||
|
sudo bash -c "echo 'net.core.rmem_max = 4194304' >> /etc/sysctl.conf" |
||||
|
sudo bash -c "echo 'net.core.wmem_max = 1048576' >> /etc/sysctl.conf" |
||||
|
|
||||
|
# *** SHELL SCRIPTS AND ASSETS |
||||
|
|
||||
|
# move files from gitclone |
||||
|
cd /home/admin/ |
||||
|
sudo -u admin git clone https://github.com/rootzoll/raspiblitz.git |
||||
|
sudo -u admin cp /home/admin/raspiblitz/home.admin/*.sh /home/admin |
||||
|
sudo -u admin chmod +x *.sh |
||||
|
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/assets /home/admin/ |
||||
|
|
||||
|
# bash aoutstart for admin |
||||
|
sudo bash -c "echo '# automatically start main menu for admin' >> /home/admin/.bashrc" |
||||
|
sudo bash -c "echo './00mainMenu.sh' >> /home/admin/.bashrc" |
||||
|
|
||||
|
# bash aoutstart for pi |
||||
|
# run as exec to dont allow easy physical access by keyboard |
||||
|
# see https://github.com/rootzoll/raspiblitz/issues/54 |
||||
|
sudo bash -c 'echo "# automatic start the LCD info loop" >> /home/pi/.bashrc' |
||||
|
sudo bash -c 'echo "SCRIPT=/home/admin/00infoLCD.sh" >> /home/pi/.bashrc' |
||||
|
sudo bash -c 'echo "# replace shell with script => logout when exiting script" >> /home/pi/.bashrc' |
||||
|
sudo bash -c 'echo "exec \$SCRIPT" >> /home/pi/.bashrc' |
||||
|
|
||||
|
# create /home/pi/setup.sh - which will get executed after reboot by autologin pi user |
||||
|
cat > /home/pi/setup.sh <<EOF |
||||
|
|
||||
|
# make LCD screen rotation correct |
||||
|
sudo sed --in-place -i "57s/.*/dtoverlay=tft35a:rotate=270/" /boot/config.txt |
||||
|
|
||||
|
EOF |
||||
|
sudo chmod +x /home/pi/setup.sh |
||||
|
|
||||
|
# *** RASPIBLITZ IMAGE READY *** |
||||
|
echo "" |
||||
|
echo "**********************************************" |
||||
|
echo "ALMOST READY" |
||||
|
echo "**********************************************" |
||||
|
echo "" |
||||
|
echo "Your SD Card Image for RaspiBlitz is almost ready." |
||||
|
echo "Last step is to install LCD drivers. This will reboot your Pi when done." |
||||
|
echo "" |
||||
|
echo "Maybe take the chance and look thru the output above if you can spot any errror." |
||||
|
echo "" |
||||
|
echo "After final reboot - your SD Card Image is ready." |
||||
|
echo "Press ENTER to install LCD and reboot ..." |
||||
|
read key |
||||
|
|
||||
|
# give Raspi a default hostname (optional) |
||||
|
sudo raspi-config nonint do_hostname "RaspiBlitz" |
||||
|
|
||||
|
# *** RASPIBLITZ / LCD (at last - because makes a reboot) *** |
||||
|
# based on https://www.elegoo.com/tutorial/Elegoo%203.5%20inch%20Touch%20Screen%20User%20Manual%20V1.00.2017.10.09.zip |
||||
|
cd /home/admin/ |
||||
|
sudo apt-mark hold raspberrypi-bootloader |
||||
|
git clone https://github.com/goodtft/LCD-show.git |
||||
|
sudo chmod -R 755 LCD-show |
||||
|
sudo chown -R admin:admin LCD-show |
||||
|
cd LCD-show/ |
||||
|
sudo ./LCD35-show |
@ -1,90 +1,174 @@ |
|||||
#!/bin/sh |
#!/bin/bash |
||||
|
echo "" |
||||
|
|
||||
# name of torrentfile = name of directory in torrent |
# *** BITCOIN *** |
||||
torrent="raspiblitz-hdd-2018-07-16" |
bitcoinList="" # url to list with other sources |
||||
# size of a valid download (run on seed directory 'du -s ./[TORRENTDIRECTORY]') |
bitcoinUrl="ftp://anonymous:anonymous@91.83.237.185:21/raspiblitz-bitcoin-2018-07-16" |
||||
torrentsize=462470200 |
bitcoinSize=231000000 # 231235816-tolerance |
||||
|
|
||||
echo "" |
# *** LITECOIN *** |
||||
echo "*** Checking HDD ***" |
litecoinList="" # url to list with other sources |
||||
mountOK=$(df | grep -c /mnt/hdd) |
litecoinUrl="ftp://anonymous:anonymous@ftp.rotzoll.de/pub/raspiblitz-litecoin-2018-07-29" |
||||
if [ ${mountOK} -eq 1 ]; then |
litecoinSize=19180000 # 19184960-tolerance |
||||
# HDD is mounted |
|
||||
if [ -d "/mnt/hdd/bitcoin" ]; then |
# load network |
||||
# HDD has already content |
network=`cat .network` |
||||
echo "It seems that HDD has already content. Try to continue with ./finishHDD.sh" |
|
||||
else |
# settings based on network |
||||
# HDD is empty - download HDD content |
list=$bitcoinList |
||||
echo "OK - HDD is ready." |
url=$bitcoinUrl |
||||
echo "" |
size=$bitcoinSize |
||||
|
if [ "$network" = "litecoin" ]; then |
||||
downloading=1 |
list=$litecoinList |
||||
retry=0 |
url=$litecoinUrl |
||||
while [ $downloading -eq 1 ] |
size=$litecoinSize |
||||
do |
fi |
||||
echo "*** Downloading HDD ***" |
|
||||
tmpfile=$(mktemp) |
# screen background monitoring settings |
||||
chmod a+x $tmpfile |
name="Download" |
||||
echo "killall transmission-cli" > $tmpfile |
targetDir="/mnt/hdd/download/" |
||||
sudo transmission-cli ./assets/$torrent.torrent -D -et -w /mnt/hdd -f $tmpfile |
targetSize=$size |
||||
|
maxTimeoutLoops=100000 |
||||
|
command="sudo wget -c -r -P ${targetDir} -q --show-progress ${url}" |
||||
|
|
||||
|
# starting session if needed |
||||
|
echo "checking if ${name} has a running screen session" |
||||
|
screen -wipe 1>/dev/null |
||||
|
isRunning=$( screen -S ${name} -ls | grep "${name}" -c ) |
||||
|
echo "isRunning(${isRunning})" |
||||
|
if [ ${isRunning} -eq 0 ]; then |
||||
|
echo "Starting screen session" |
||||
|
sudo mkdir ${targetDir} 2>/dev/null |
||||
|
screen -S ${name} -dm ${command} |
||||
|
else |
||||
|
echo "Continue screen session" |
||||
|
fi |
||||
|
sleep 3 |
||||
|
|
||||
|
# monitor session |
||||
|
screenDump="... started ..." |
||||
|
actualSize=0 |
||||
|
timeout=1 |
||||
|
timeoutInfo="-" |
||||
|
while : |
||||
|
do |
||||
|
|
||||
|
# check if session is still running |
||||
|
screen -wipe 1>/dev/null |
||||
|
isRunning=$( screen -S ${name} -ls | grep "${name}" -c ) |
||||
|
if [ ${isRunning} -eq 0 ]; then |
||||
|
timeout=0 |
||||
|
echo "OK - session finished" |
||||
|
break |
||||
|
fi |
||||
|
|
||||
|
# calculate progress and write it to file for LCD to read |
||||
|
freshSize=$( du -s ${targetDir} | head -n1 | awk '{print $1;}' ) |
||||
|
if [ ${#actualSize} -eq 0 ]; then |
||||
|
freshSize=0 |
||||
|
fi |
||||
|
progress=$(echo "scale=2; $freshSize*100/$targetSize" | bc) |
||||
|
echo $progress > '.${name}.progress' |
||||
|
|
||||
|
# detect if since last loop any progress occured |
||||
|
if [ ${actualSize} -eq ${freshSize} ]; then |
||||
|
timeoutInfo="${timeout}/${maxTimeoutLoops}" |
||||
|
timeout=$(( $timeout + 1 )) |
||||
|
else |
||||
|
timeout=1 |
||||
|
timeoutInfo="no timeout detected" |
||||
|
fi |
||||
|
actualSize=$freshSize |
||||
|
|
||||
|
# detect if mx timeout loop limit is reached |
||||
|
if [ ${timeout} -gt ${maxTimeoutLoops} ]; then |
||||
|
echo "FAIL - download hit timeout" |
||||
|
break |
||||
|
fi |
||||
|
|
||||
|
# display info screen |
||||
|
clear |
||||
|
echo "****************************************************" |
||||
|
echo "Monitoring Screen Session: ${name}" |
||||
|
echo "Progress: ${progress}% (${actualSize} of ${targetSize})" |
||||
|
echo "Timeout: ${timeoutInfo}" |
||||
|
echo "If needed press key x to stop ${name}" |
||||
|
echo "NOTICE: This can take multiple hours or days !!" |
||||
|
echo "Its OK to close terminal now and SSH back in later." |
||||
|
echo "****************************************************" |
||||
|
screen -S ${name} -X hardcopy .${name}.out |
||||
|
newScreenDump=$(cat .Download.out | grep . | tail -8) |
||||
|
if [ ${#newScreenDump} -gt 0 ]; then |
||||
|
screenDump=$newScreenDump |
||||
|
fi |
||||
|
echo "$screenDump" |
||||
|
|
||||
|
# wait 2 seconds for key input |
||||
|
read -n 1 -t 2 keyPressed |
||||
|
|
||||
|
# check if user wants to abort session |
||||
|
if [ "${keyPressed}" = "x" ]; then |
||||
echo "" |
echo "" |
||||
echo "*** Checking Download ***" |
echo "Aborting ${name}" |
||||
echo "wait a moment" |
break |
||||
sleep 5 |
|
||||
downloadsize=$(sudo du -s /mnt/hdd/$torrent/ | awk '{print $1}' | tr -dc '0-9') |
|
||||
if [ ${#downloadsize} -eq 0 ]; then |
|
||||
downloadsize=0 |
|
||||
fi |
|
||||
# add some tolerance for checking |
|
||||
torrentsize="$(($torrentsize-1024000))" |
|
||||
echo "download size is(${downloadsize})" |
|
||||
if [ ${downloadsize} -lt ${torrentsize} ]; then |
|
||||
echo "" |
|
||||
echo "FAIL - download is not ${torrentsize}" |
|
||||
retry=$(($retry+1)) |
|
||||
if [ ${retry} -gt 2 ]; then |
|
||||
echo "All Retry FAILED" |
|
||||
downloading=0 |
|
||||
else |
|
||||
echo "--> RETRY(${retry}) in 10 secs" |
|
||||
sleep 10 |
|
||||
echo "" |
|
||||
fi |
|
||||
else |
|
||||
echo "OK - Download is complete" |
|
||||
downloading=0 |
|
||||
fi |
|
||||
done |
|
||||
if [ ${downloadsize} -lt ${torrentsize} ]; then |
|
||||
sleep 3 |
|
||||
dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want to clean all download data before you continue?" 6 57 |
|
||||
response=$? |
|
||||
case $response in |
|
||||
0) sudo rm -rf /mnt/hdd/$torrent ; sudo rm -rf /root/.config/transmission ;; |
|
||||
esac |
|
||||
# |
|
||||
./00mainMenu.sh |
|
||||
exit 1; |
|
||||
fi |
fi |
||||
echo "" |
|
||||
|
|
||||
echo "*** Moving Files ***" |
done |
||||
echo "moving files ..." |
|
||||
sudo mv /mnt/hdd/$torrent /mnt/hdd/bitcoin |
|
||||
echo "" |
|
||||
|
|
||||
# set SetupState |
# clean up |
||||
echo "50" > /home/admin/.setup |
rm -f .${name}.out |
||||
|
rm -f .${name}.progress |
||||
echo "*** Next Step ***" |
|
||||
echo "You can now use this HDD as a source to copy the Blockchain during the setup of another RaspiBlitz." |
|
||||
sleep 4 |
|
||||
|
|
||||
# continue setup |
# quit session if still running |
||||
./60finishHDD.sh |
if [ ${isRunning} -eq 1 ]; then |
||||
|
# get the PID of screen session |
||||
|
sessionPID=$(screen -ls | grep "${name}" | cut -d "." -f1 | xargs) |
||||
|
echo "killing screen session PID(${sessionPID})" |
||||
|
# kill all child processes of screen sceesion |
||||
|
pkill -P ${sessionPID} |
||||
|
echo "proccesses klilled" |
||||
|
sleep 3 |
||||
|
# tell the screen session to quit and wait a bit |
||||
|
screen -S ${name} -X quit 1>/dev/null |
||||
|
sleep 3 |
||||
|
echo "cleaning screen" |
||||
|
screen -wipe 1>/dev/null |
||||
|
sleep 3 |
||||
|
fi |
||||
|
|
||||
fi |
# the path wget will download to |
||||
else |
targetPath=$(echo ${url} | cut -d '@' -f2) |
||||
# HDD is not available yet |
echo "path to downloaded data is ${targetPath}" |
||||
echo "*** Mount HDD on /mnt/hdd first ***" |
|
||||
|
# calculate progress and write it to file for LCD to read |
||||
|
finalSize=$( du -s ${targetDir} 2>/dev/null | head -n1 | awk '{print $1;}' ) |
||||
|
if [ ${#finalSize} -eq 0 ]; then |
||||
|
finalSize=0 |
||||
fi |
fi |
||||
|
echo "final size is ${finalSize} of targeted size ${targetSize}" |
||||
|
|
||||
|
# check result |
||||
|
if [ ${finalSize} -lt ${targetSize} ]; then |
||||
|
|
||||
|
# Download failed |
||||
|
sleep 3 |
||||
|
echo -ne '\007' |
||||
|
dialog --title " WARNING " --yesno "The download failed or is not complete. Maybe try again (later). Do you want keep already downloaded data for next try?" 8 57 |
||||
|
response=$? |
||||
|
case $response in |
||||
|
1) sudo rm -rf ${targetDir} ;; |
||||
|
esac |
||||
|
./00mainMenu.sh |
||||
|
exit 1; |
||||
|
|
||||
|
else |
||||
|
|
||||
|
# Download worked |
||||
|
echo "*** Moving Files ***" |
||||
|
sudo mv ${targetDir}${targetPath} /mnt/hdd/${network} |
||||
|
echo "OK" |
||||
|
|
||||
|
# continue setup |
||||
|
./60finishHDD.sh |
||||
|
|
||||
|
fi |
@ -0,0 +1,68 @@ |
|||||
|
#!/bin/sh |
||||
|
|
||||
|
# *** BITCOIN Torrent *** |
||||
|
bitcoinTorrent="raspiblitz-bitcoin-2018-07-16" |
||||
|
bitcoinTorrentsize=231230512 |
||||
|
|
||||
|
# *** LITECOIN Torrent *** |
||||
|
litecoinTorrent="raspiblitz-litecoin-2018-07-29" |
||||
|
litecoinTorrentsize=10240000 |
||||
|
|
||||
|
# load network |
||||
|
network=`cat .network` |
||||
|
|
||||
|
# settings based on network |
||||
|
torrent=$bitcoinTorrent |
||||
|
torrentsize=$bitcoinTorrentsize |
||||
|
if [ "$network" = "litecoin" ]; then |
||||
|
torrent=$litecoinTorrent |
||||
|
torrentsize=$litecoinTorrentsize |
||||
|
fi |
||||
|
echo "" |
||||
|
echo "torrentFile: ${torrent}" |
||||
|
|
||||
|
echo "" |
||||
|
echo "*** Downloading TORRENT ***" |
||||
|
echo "IN CASE DOWNLOAD DOES NOT START OR TOO SLOW:" |
||||
|
echo "CTRL+z start ./10setupBlitz.sh choose other option" |
||||
|
echo "***************************" |
||||
|
echo "" |
||||
|
tmpfile=$(mktemp) |
||||
|
chmod a+x $tmpfile |
||||
|
echo "killall transmission-cli" > $tmpfile |
||||
|
sudo transmission-cli ./assets/$torrent.torrent -D -et -w /mnt/hdd -f $tmpfile |
||||
|
echo "OK - Download closed" |
||||
|
echo "" |
||||
|
|
||||
|
echo "*** Checking TORRENT ***" |
||||
|
echo "wait a moment" |
||||
|
sleep 5 |
||||
|
downloadsize=$(sudo du -s /mnt/hdd/$torrent/ | awk '{print $1}' | tr -dc '0-9') |
||||
|
if [ ${#downloadsize} -eq 0 ]; then |
||||
|
downloadsize=0 |
||||
|
fi |
||||
|
# add some tolerance for checking |
||||
|
size="$(($size-1024000))" |
||||
|
echo "download size is(${downloadsize}) needs to be minimum(${size})" |
||||
|
if [ ${downloadsize} -lt ${size} ]; then |
||||
|
sleep 3 |
||||
|
echo -ne '\007' |
||||
|
dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want keep already downloaded data?" 6 57 |
||||
|
response=$? |
||||
|
case $response in |
||||
|
1) sudo rm -rf /mnt/hdd/$torrent ; sudo rm -rf /root/.config/transmission ;; |
||||
|
esac |
||||
|
./00mainMenu.sh |
||||
|
exit 1; |
||||
|
fi |
||||
|
|
||||
|
echo "*** Moving Files ***" |
||||
|
echo "moving files ..." |
||||
|
sudo mv /mnt/hdd/$torrent /mnt/hdd/${network} |
||||
|
echo "" |
||||
|
|
||||
|
# set SetupState |
||||
|
echo "50" > /home/admin/.setup |
||||
|
|
||||
|
# continue setup |
||||
|
./60finishHDD.sh |
@ -1,20 +1,66 @@ |
|||||
|
# load network |
||||
|
network=`sudo cat /home/admin/.network` |
||||
|
|
||||
|
# load name of Blitz |
||||
|
name=`sudo cat /home/admin/.hostname` |
||||
|
|
||||
|
### USER PI AUTOSTART (LCD Display) |
||||
|
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') |
||||
|
|
||||
# parse the actual scanned height progress from LND logs |
# parse the actual scanned height progress from LND logs |
||||
item=0 |
item=0 |
||||
chain="$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain')" |
blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo) |
||||
gotData=$(sudo tail -n 100 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep -c height) |
chain="$(echo "${blockchaininfo}" | jq -r '.chain')" |
||||
if [ ${gotData} -gt 0 ]; then |
|
||||
item=$(sudo tail -n 100 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep height | tail -n1 | awk '{print $9} {print $10} {print $11} {print $12}' | tr -dc '0-9') |
## TRY to get the actual progress height of scanning |
||||
|
|
||||
|
# 1) First try the "Rescanned through block" - it seems to happen if it restarts |
||||
|
item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Rescanned through block" | tail -n1 | cut -d ']' -f2 | cut -d '(' -f2 | tr -dc '0-9') |
||||
|
|
||||
|
# 2) Second try the "Caught up to height" - thats the usual on first scan start |
||||
|
if [ ${#item} -eq 0 ]; then |
||||
|
item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Caught up to height" | tail -n1 | cut -d ']' -f2 | tr -dc '0-9') |
||||
|
fi |
||||
|
|
||||
|
# TODO next fallback try later here if necessary |
||||
|
if [ ${#item} -eq 0 ]; then |
||||
|
item="?" |
||||
fi |
fi |
||||
|
|
||||
# get total number of blocks |
# get total number of blocks |
||||
total=$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.blocks') |
total=$(echo "${blockchaininfo}" | jq -r '.blocks') |
||||
|
# put scanstate |
||||
|
scanstate="${item}/${total}" |
||||
|
|
||||
# calculate progress in percent |
# get blockchain sync progress |
||||
percent=$(awk "BEGIN { pc=100*${item}/${total}; i=int(pc); print (pc-i<0.5)?i:i+1 }") |
progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')" |
||||
if [ ${percent} -e 100 ]; then |
|
||||
# normally if 100% gets calculated, item parsed the wrong height |
# check if blockchain is still syncing |
||||
percent=0 |
heigh=6 |
||||
|
width=44 |
||||
|
isInitialChainSync=$(echo "${blockchaininfo}" | grep 'initialblockdownload' | grep "true" -c) |
||||
|
isWaitingBlockchain=$( sudo -u bitcoin tail -n 2 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Waiting for chain backend to finish sync" -c ) |
||||
|
if [ ${isWaitingBlockchain} -gt 0 ]; then |
||||
|
isInitialChainSync=1 |
||||
|
fi |
||||
|
if [ ${isInitialChainSync} -gt 0 ]; then |
||||
|
heigh=7 |
||||
|
infoStr=" Waiting for final Blockchain Sync\n Progress: ${progress}\n Please wait - this can take some time.\n ssh admin@${localip}\n Password A" |
||||
|
if [ "$USER" = "admin" ]; then |
||||
|
heigh=6 |
||||
|
width=53 |
||||
|
infoStr=$(echo " Waiting for final Blockchain Sync\n Progress: ${progress}\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.") |
||||
|
fi |
||||
|
else |
||||
|
heigh=7 |
||||
|
infoStr=$(echo " Lightning Rescanning Blockchain\n Progress: ${scanstate}\n Please wait - this can take some time\n ssh admin@${localip}\n Password A") |
||||
|
if [ "$USER" = "admin" ]; then |
||||
|
heigh=6 |
||||
|
width=53 |
||||
|
infoStr=$(echo " Lightning Rescanning Blockchain\n Progress: ${scanstate}\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.") |
||||
|
fi |
||||
fi |
fi |
||||
|
|
||||
# display progress to user |
# display progress to user |
||||
dialog --backtitle "RaspiBlitz" --infobox " Lightning Rescanning Blockchain $percent%\nplease wait - this can take some time" 4 42 |
sleep 3 |
||||
|
dialog --title " ${network} / ${chain} " --backtitle "RaspiBlitz (${name})" --infobox "${infoStr}" ${heigh} ${width} |
@ -0,0 +1,125 @@ |
|||||
|
#!/usr/bin/env bash |
||||
|
# based on pull request from vnnkl |
||||
|
|
||||
|
# load network |
||||
|
network=`cat .network` |
||||
|
|
||||
|
echo "" |
||||
|
echo "*** Switch between Testnet/Mainnet ***" |
||||
|
|
||||
|
# allow only on bitcoin network |
||||
|
if [ "${network}" = "bitcoin" ]; then |
||||
|
echo "Bitcoin network can be switched between testnet/mainnet ..." |
||||
|
else |
||||
|
echo "FAIL - Only Bitcoin Network can be switched between man/tast at the moment." |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
NETWORK_CONFIG="/home/bitcoin/.${network}/${network}.conf" |
||||
|
NETWORK_TEMPLATE="/home/admin/assets/${network}.conf" |
||||
|
LND_CONFIG="/home/bitcoin/.lnd/lnd.conf" |
||||
|
LND_TEMPLATE="/home/admin/assets/lnd.${network}.conf" |
||||
|
echo "NETWORK_CONFIG(${NETWORK_CONFIG})" |
||||
|
echo "LND_CONFIG(${LND_CONFIG})" |
||||
|
echo "NETWORK_TEMPLATE(${NETWORK_TEMPLATE})" |
||||
|
echo "LND_TEMPLATE(${LND_TEMPLATE})" |
||||
|
|
||||
|
# function to detect main/testnet |
||||
|
function isMainnet(){ |
||||
|
grep "^#testnet=1$" -q $NETWORK_CONFIG && return 1 |
||||
|
return 0 |
||||
|
} |
||||
|
|
||||
|
function switchToMainnet { |
||||
|
echo "switching to mainnet" |
||||
|
sed -i "s/^testnet=1/#testnet=1/g" $NETWORK_CONFIG |
||||
|
sed -i "s/^testnet=1/#testnet=1/g" $NETWORK_TEMPLATE |
||||
|
sed -i "s/^#mainnet=1/mainnet=1/g" $NETWORK_CONFIG |
||||
|
sed -i "s/^#mainnet=1/mainnet=1/g" $NETWORK_TEMPLATE |
||||
|
sed -i "s/^${network}.testnet=1/#${network}.testnet=1/g" $LND_CONFIG |
||||
|
sed -i "s/^#${network}.mainnet=1/${network}.mainnet=1/g" $LND_CONFIG |
||||
|
sed -i "s/^${network}.testnet=1/#${network}.testnet=1/g" $LND_TEMPLATE |
||||
|
sed -i "s/^#${network}.mainnet=1/${network}.mainnet=1/g" $LND_TEMPLATE |
||||
|
echo "OK switched to mainnet" |
||||
|
} |
||||
|
|
||||
|
function switchToTestnet { |
||||
|
echo "switching to testnet" |
||||
|
sed -i "s/^#testnet=1/testnet=1/g" $NETWORK_CONFIG |
||||
|
sed -i "s/^#testnet=1/testnet=1/g" $NETWORK_TEMPLATE |
||||
|
sed -i "s/^mainnet=1/#mainnet=1/g" $NETWORK_CONFIG |
||||
|
sed -i "s/^mainnet=1/#mainnet=1/g" $NETWORK_TEMPLATE |
||||
|
sed -i "s/^#${network}.testnet=1/${network}.testnet=1/g" $LND_CONFIG |
||||
|
sed -i "s/^${network}.mainnet=1/#${network}.mainnet=1/g" $LND_CONFIG |
||||
|
sed -i "s/^#${network}.testnet=1/${network}.testnet=1/g" $LND_TEMPLATE |
||||
|
sed -i "s/^${network}.mainnet=1/#${network}.mainnet=1/g" $LND_TEMPLATE |
||||
|
echo "OK switched to testnet" |
||||
|
} |
||||
|
|
||||
|
# LND Service |
||||
|
lndInstalled=$(systemctl status lnd.service | grep loaded -c) |
||||
|
if [ ${lndInstalled} -gt 0 ]; then |
||||
|
|
||||
|
echo "check for open channels" |
||||
|
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} listchannels 2>/dev/null | grep chan_id -c) |
||||
|
if [ ${openChannels} -gt 0 ]; then |
||||
|
echo "" |
||||
|
echo "!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "FAIL - You have still open channels and could loose funds !! - close those first with 'lncli --chain=${network} closeallchannels' or main menu option." |
||||
|
echo "!!!!!!!!!!!!!!!!!!!" |
||||
|
exit 1 |
||||
|
else |
||||
|
echo "no open channels found" |
||||
|
fi |
||||
|
|
||||
|
echo "stopping lnd client" |
||||
|
systemctl stop lnd |
||||
|
sleep 4 |
||||
|
|
||||
|
else |
||||
|
echo "LND not running" |
||||
|
fi |
||||
|
|
||||
|
# NETWORK Service |
||||
|
networkInstalled=$(systemctl status ${network}d.service | grep loaded -c) |
||||
|
if [ ${networkInstalled} -gt 0 ]; then |
||||
|
echo "stopping bitcoind client" |
||||
|
systemctl stop bitcoind |
||||
|
sleep 4 |
||||
|
else |
||||
|
echo "Network ${network} not running" |
||||
|
fi |
||||
|
|
||||
|
# TURN THE SWITCH |
||||
|
isMainnet |
||||
|
if [ $? -eq 1 ]; then |
||||
|
echo "switching from mainnet to testnet" |
||||
|
switchToTestnet |
||||
|
else |
||||
|
echo "switching from testnet to mainnet" |
||||
|
switchToMainnet |
||||
|
fi |
||||
|
|
||||
|
echo "copying over config to admin user" |
||||
|
cp $NETWORK_CONFIG /home/admin/.${network}/ |
||||
|
chown admin:admin /home/admin/.${network}/${network}.conf |
||||
|
cp $LND_CONFIG /home/admin/.lnd/ |
||||
|
chown admin:admin /home/admin/.lnd/lnd.conf |
||||
|
|
||||
|
# restarting network |
||||
|
if [ ${networkInstalled} -gt 0 ]; then |
||||
|
|
||||
|
# start network |
||||
|
systemctl start bitcoind |
||||
|
echo "started ${network}d back up, giving it a 120 SECONDS to prepare" |
||||
|
sleep 120 |
||||
|
|
||||
|
# set setup info again |
||||
|
echo "60" > /home/admin/.setup |
||||
|
|
||||
|
# run again the complete LND init procedure |
||||
|
./70initLND.sh |
||||
|
|
||||
|
else |
||||
|
echo "No starting of network, because it was not running before" |
||||
|
fi |
@ -0,0 +1,219 @@ |
|||||
|
#!/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 <<EOF |
||||
|
### See 'man tor', or https://www.torproject.org/docs/tor-manual.html |
||||
|
|
||||
|
DataDirectory /mnt/hdd/tor/sys |
||||
|
PidFile /mnt/hdd/tor/sys/tor.pid |
||||
|
|
||||
|
SafeLogging 0 |
||||
|
Log notice stdout |
||||
|
Log notice file /mnt/hdd/tor/notice.log |
||||
|
Log info file /mnt/hdd/tor/info.log |
||||
|
|
||||
|
RunAsDaemon 1 |
||||
|
User bitcoin |
||||
|
PortForwarding 1 |
||||
|
ControlPort 9051 |
||||
|
SocksPort 9050 |
||||
|
|
||||
|
CookieAuthFile /mnt/hdd/tor/sys/control_auth_cookie |
||||
|
CookieAuthentication 1 |
||||
|
CookieAuthFileGroupReadable 1 |
||||
|
|
||||
|
# Hidden Service v2 for WEB ADMIN INTERFACE |
||||
|
HiddenServiceDir /mnt/hdd/tor/web80/ |
||||
|
HiddenServicePort 80 127.0.0.1:80 |
||||
|
|
||||
|
# Hidden Service v2 for LND RPC |
||||
|
HiddenServiceDir /mnt/hdd/tor/lndrpc10009/ |
||||
|
HiddenServicePort 80 127.0.0.1:10009 |
||||
|
|
||||
|
# Hidden Service v3 for LND incomming connections (just in case) |
||||
|
# https://trac.torproject.org/projects/tor/wiki/doc/NextGenOnions#Howtosetupyourownprop224service |
||||
|
HiddenServiceDir /mnt/hdd/tor/lnd9735 |
||||
|
HiddenServiceVersion 3 |
||||
|
HiddenServicePort 9735 127.0.0.1:9735 |
||||
|
|
||||
|
# NOTE: bitcoind get tor service automatically - see /mnt/hdd/bitcoin for onion key |
||||
|
EOF |
||||
|
sudo rm $torrc |
||||
|
sudo mv ./torrc $torrc |
||||
|
sudo chmod 644 $torrc |
||||
|
sudo chown -R bitcoin:bitcoin /var/run/tor/ |
||||
|
echo "" |
||||
|
|
||||
|
# NYX - Tor monitor tool |
||||
|
# https://nyx.torproject.org/#home |
||||
|
echo "*** Installing NYX - TOR monitoring Tool ***" |
||||
|
nyxInstalled=$(sudo pip list 2>/dev/null | grep 'nyx' -c) |
||||
|
if [ ${nyxInstalled} -eq 0 ]; then |
||||
|
sudo pip install nyx |
||||
|
else |
||||
|
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 restart tor@default |
||||
|
echo "" |
||||
|
|
||||
|
echo "*** Waiting for TOR to boostrap ***" |
||||
|
torIsBootstrapped=0 |
||||
|
while [ ${torIsBootstrapped} -eq 0 ] |
||||
|
do |
||||
|
echo "--- Checking 1 ---" |
||||
|
date +%s |
||||
|
sudo cat /mnt/hdd/tor/notice.log 2>/dev/null | grep "Bootstrapped" | tail -n 10 |
||||
|
torIsBootstrapped=$(sudo cat /mnt/hdd/tor/notice.log 2>/dev/null | grep "Bootstrapped 100" -c) |
||||
|
echo "torIsBootstrapped(${torIsBootstrapped})" |
||||
|
echo "If this takes too long --> CTRL+c, reboot and check manually" |
||||
|
sleep 5 |
||||
|
done |
||||
|
echo "OK - Tor Bootstrap is ready" |
||||
|
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" |
||||
|
echo "onlynet=onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf |
||||
|
|
||||
|
if [ "${network}" = "bitcoin" ]; then |
||||
|
echo "Adding some bitcoin onion nodes to connect to" |
||||
|
echo "addnode=fno4aakpl6sg6y47.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf |
||||
|
echo "addnode=toguvy5upyuctudx.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf |
||||
|
echo "addnode=ndndword5lpb7eex.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf |
||||
|
echo "addnode=6m2iqgnqjxh7ulyk.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf |
||||
|
echo "addnode=5tuxetn7tar3q5kp.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf |
||||
|
fi |
||||
|
|
||||
|
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 |
||||
|
|
||||
|
echo "*** ${network} re-init - Waiting for Onion Address ***" |
||||
|
# restarting bitcoind to start with tor and generare onion.address |
||||
|
echo "restarting ${network}d ..." |
||||
|
sudo systemctl restart ${network}d |
||||
|
sleep 8 |
||||
|
onionAddress="" |
||||
|
while [ ${#onionAddress} -eq 0 ] |
||||
|
do |
||||
|
echo "--- Checking 2 ---" |
||||
|
date +%s |
||||
|
testNetAdd="" |
||||
|
if [ "${chain}" = "test" ];then |
||||
|
testNetAdd="/testnet3" |
||||
|
fi |
||||
|
sudo cat /mnt/hdd/${network}${testNetAdd}/debug.log 2>/dev/null | grep "tor" | tail -n 10 |
||||
|
onionAddress=$(sudo -u bitcoin ${network}-cli getnetworkinfo | grep '"address"' | cut -d '"' -f4) |
||||
|
echo "Can take up to 20min - if this takes longer --> CTRL+c, reboot and check manually" |
||||
|
sleep 5 |
||||
|
done |
||||
|
onionPort=$(sudo -u bitcoin ${network}-cli getnetworkinfo | grep '"port"' | tr -dc '0-9') |
||||
|
echo "Your Chain Network Onion Address is: ${onionAddress}:${onionPort}" |
||||
|
echo "" |
||||
|
|
||||
|
echo "*** Setting your Onion Address ***" |
||||
|
onionLND=$(sudo cat /mnt/hdd/tor/lnd9735/hostname) |
||||
|
echo "Your Lightning Tor Onion Address is: ${onionLND}:9735" |
||||
|
echo "" |
||||
|
|
||||
|
# ACTIVATE LND OVER TOR |
||||
|
echo "*** Putting LND behind TOR ***" |
||||
|
echo "Disable LND again" |
||||
|
sudo systemctl disable lnd |
||||
|
echo "Writing Public Onion Address to /run/publicip (just in case for TotHiddenServiceV3)" |
||||
|
echo "PUBLICIP=${onionLND}" | sudo tee /run/publicip |
||||
|
echo "Configure and Changing to lnd.tor.service" |
||||
|
sed -i "5s/.*/Wants=${network}d.service/" ./assets/lnd.tor.service |
||||
|
sed -i "6s/.*/After=${network}d.service/" ./assets/lnd.tor.service |
||||
|
sudo cp /home/admin/assets/lnd.tor.service /etc/systemd/system/lnd.service |
||||
|
sudo chmod +x /etc/systemd/system/lnd.service |
||||
|
echo "Enable LND again" |
||||
|
sudo systemctl enable lnd |
||||
|
echo "OK" |
||||
|
echo "" |
||||
|
|
||||
|
echo "*** Finshing Setup / REBOOT ***" |
||||
|
echo "OK - all should be set" |
||||
|
echo "" |
||||
|
echo "PRESS ENTER ... to REBOOT" |
||||
|
read key |
||||
|
|
||||
|
sudo shutdown -r now |
||||
|
exit 0 |
@ -0,0 +1,57 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# load network |
||||
|
network=`cat .network` |
||||
|
|
||||
|
# location of TOR config |
||||
|
torrc="/etc/tor/torrc" |
||||
|
|
||||
|
echo "*** Stopping all Services ***" |
||||
|
sudo systemctl stop lnd |
||||
|
sudo systemctl stop ${network}d |
||||
|
sudo systemctl stop tor@default |
||||
|
echo "" |
||||
|
|
||||
|
echo "*** Disable TOR service ***" |
||||
|
sudo systemctl disable tor@default |
||||
|
echo "" |
||||
|
|
||||
|
echo "*** Changing ${network} Config ***" |
||||
|
sudo cat /home/bitcoin/.${network}/${network}.conf | grep -Ev 'onlynet=onion|.onion' | sudo tee /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 "*** Removing TOR from LND ***" |
||||
|
sudo systemctl disable lnd |
||||
|
sed -i "5s/.*/Wants=${network}d.service/" ./assets/lnd.service |
||||
|
sed -i "6s/.*/After=${network}d.service/" ./assets/lnd.service |
||||
|
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service |
||||
|
sudo chmod +x /etc/systemd/system/lnd.service |
||||
|
sudo systemctl enable lnd |
||||
|
echo "OK" |
||||
|
echo "" |
||||
|
|
||||
|
echo "*** Remove Tor ***" |
||||
|
sudo apt remove tor tor-arm -y |
||||
|
echo "" |
||||
|
|
||||
|
echo "*** Remove dirmngr ***" |
||||
|
sudo apt remove dirmngr -y |
||||
|
echo "" |
||||
|
|
||||
|
echo "*** Remove NYX ***" |
||||
|
sudo pip uninstall nyx -y |
||||
|
echo "" |
||||
|
|
||||
|
echo "*** Remove TOR Files/Config ***" |
||||
|
sudo rm -r -f /mnt/hdd/tor |
||||
|
echo "" |
||||
|
|
||||
|
echo "*** Finshing Setup / REBOOT ***" |
||||
|
echo "OK - all should be set" |
||||
|
echo "" |
||||
|
echo "PRESS ENTER ... to REBOOT" |
||||
|
read key |
||||
|
|
||||
|
sudo shutdown -r now |
||||
|
exit 0 |
@ -0,0 +1,52 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# load network |
||||
|
network=`cat .network` |
||||
|
|
||||
|
# get chain |
||||
|
chain="test" |
||||
|
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c) |
||||
|
if [ ${isMainChain} -gt 0 ];then |
||||
|
chain="main" |
||||
|
fi |
||||
|
|
||||
|
# make sure qrcode-encoder in installed |
||||
|
clear |
||||
|
echo "*** Setup ***" |
||||
|
sudo apt-get install qrencode -y |
||||
|
|
||||
|
# get local IP |
||||
|
myip=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p') |
||||
|
|
||||
|
clear |
||||
|
echo "******************************" |
||||
|
echo "Connect Shango Mobile Wallet" |
||||
|
echo "******************************" |
||||
|
echo "" |
||||
|
echo "GETTING THE APP" |
||||
|
echo "At the moment this app is in closed beta testing and the source code has not been published yet." |
||||
|
echo "Go to http://www.shangoapp.com/insider sign up with your email (confirmation can take time)" |
||||
|
echo "iOS: Read https://developer.apple.com/testflight/testers/" |
||||
|
echo "Android: https://play.google.com/apps/testing/com.shango (from device, after confirmation email)" |
||||
|
echo "" |
||||
|
echo "*** STEP 1 ***" |
||||
|
echo "Once you have the app is running make sure you are on the same local network (WLAN same as LAN)." |
||||
|
echo "Then go to --> 'Connect to your LND Server'" |
||||
|
echo "There you see three 3 form fields to fill out. Skip those and go right to the buttons below." |
||||
|
echo "" |
||||
|
echo "Click on the 'Scan OR' button" |
||||
|
echo "Make the this terminal as big as possible - fullscreen would be best." |
||||
|
echo "Then PRESS ENTER here in the terminal to generare the QR code and scan it with the app." |
||||
|
read key |
||||
|
|
||||
|
clear |
||||
|
echo "*** STEP 2 : SCAN MACAROON (make whole QR code fill camera) ***" |
||||
|
echo -e "${myip}:10009,\n$(xxd -p -c2000 ./.lnd/data/chain/bitcoin/mainnet/admin.macaroon)," > qr.txt && cat ./.lnd/tls.cert >>qr.txt && qrencode -t ANSIUTF8 < qr.txt |
||||
|
echo "(To shrink QR code: OSX->CMD- / LINUX-> CTRL-) Press ENTER when finished." |
||||
|
read key |
||||
|
|
||||
|
clear |
||||
|
echo "Now press 'Connect' within the Shango Wallet." |
||||
|
echo "If its not working - check issues on GitHub:" |
||||
|
echo "https://github.com/neogeno/shango-lightning-wallet/issues" |
||||
|
echo "" |
@ -1,20 +1,26 @@ |
|||||
#!/bin/sh |
#!/bin/sh |
||||
|
|
||||
|
# load network |
||||
|
network=`cat .network` |
||||
|
|
||||
echo "" |
echo "" |
||||
echo "****************************************************************************" |
echo "****************************************************************************" |
||||
echo "Unlock LND Wallet --> lncli unlock" |
echo "Unlock LND Wallet --> lncli --chain=${network} unlock" |
||||
echo "****************************************************************************" |
echo "****************************************************************************" |
||||
echo "HELP: Enter your PASSWORD C" |
echo "HELP: Enter your PASSWORD C" |
||||
echo "****************************************************************************" |
echo "****************************************************************************" |
||||
chain="$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain')" |
|
||||
while : |
while : |
||||
do |
do |
||||
lncli unlock |
chain="$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')" |
||||
|
sudo -u bitcoin /usr/local/bin/lncli --chain=${network} unlock |
||||
sleep 4 |
sleep 4 |
||||
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep -c unlock) |
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock) |
||||
if [ ${locked} -eq 0 ]; then |
if [ ${locked} -eq 0 ]; then |
||||
break |
break |
||||
fi |
fi |
||||
|
|
||||
echo "" |
echo "" |
||||
|
echo "network(${network}) chain(${chain})" |
||||
|
sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log |
||||
echo "Wallet still locked - please try again or Cancel with CTRL+C" |
echo "Wallet still locked - please try again or Cancel with CTRL+C" |
||||
done |
done |
||||
|
@ -0,0 +1,77 @@ |
|||||
|
#!/bin/bash |
||||
|
_temp="./download/dialog.$$" |
||||
|
_error="./.error.out" |
||||
|
|
||||
|
# load network and chain info |
||||
|
network=`cat .network` |
||||
|
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') |
||||
|
|
||||
|
# get available amount in on-chain wallet |
||||
|
maxAmount=$(lncli --chain=${network} walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4) |
||||
|
|
||||
|
# TODO: pre-check if channels are open or are still in closing |
||||
|
# and let user know not all funds are available yet (just info Dialoge) |
||||
|
|
||||
|
# TODO: pre-check user hast more than 0 sat in on-chain wallet to send |
||||
|
|
||||
|
# let user enter the amount |
||||
|
l1="Enter the amount of funds you want to send/remove:" |
||||
|
l2="You have max available: ${maxAmount} sat" |
||||
|
l3="If you enter nothing, all funds available will be send." |
||||
|
dialog --title "Remove Funds from RaspiBlitz" \ |
||||
|
--inputbox "$l1\n$l2\n$l3" 10 60 2>$_temp |
||||
|
amount=$(cat $_temp | xargs) |
||||
|
shred $_temp |
||||
|
if [ ${#amount} -eq 0 ]; then |
||||
|
amount=${maxAmount} |
||||
|
fi |
||||
|
|
||||
|
# TODO: check if amount is in valid range |
||||
|
|
||||
|
# let user enter the address |
||||
|
l1="Enter the on-chain address to send funds to:" |
||||
|
l2="You will send: ${amount} sat to that address" |
||||
|
dialog --title "Where to send funds?" \ |
||||
|
--inputbox "$l1\n$l2" 8 65 2>$_temp |
||||
|
address=$(cat $_temp | xargs) |
||||
|
shred $_temp |
||||
|
if [ ${#address} -eq 0 ]; then |
||||
|
echo "FAIL - not a valid address (${address})" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# TODO: check address is valid for network and chain |
||||
|
|
||||
|
# TODO: check if fees are getting done right so that transaction will get processed |
||||
|
|
||||
|
command="lncli --chain=${network} --conf_target 3 sendcoins ${address} ${amount}" |
||||
|
|
||||
|
clear |
||||
|
echo "******************************" |
||||
|
echo "Send on-chain Funds" |
||||
|
echo "******************************" |
||||
|
echo "" |
||||
|
echo "COMMAND LINE: " |
||||
|
echo $command |
||||
|
echo "" |
||||
|
echo "RESULT:" |
||||
|
|
||||
|
# execute command |
||||
|
if [ ${#command} -gt 0 ]; then |
||||
|
result=$($command) |
||||
|
fi |
||||
|
|
||||
|
# on no result |
||||
|
if [ ${#result} -eq 0 ]; then |
||||
|
echo "Sorry something went wrong - thats unusual." |
||||
|
echo "" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# when result is available |
||||
|
echo "$result" |
||||
|
|
||||
|
# TODO: check if all cashed out (0 funds + 0 channels) -> let user knwo its safe to update/reset RaspiBlitz |
||||
|
|
||||
|
echo "OK. That worked :)" |
||||
|
echo "" |
@ -0,0 +1,36 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# load network and chain info |
||||
|
network=`cat .network` |
||||
|
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') |
||||
|
|
||||
|
command="lncli --chain=${network} --force closeallchannels " |
||||
|
|
||||
|
clear |
||||
|
echo "***********************************" |
||||
|
echo "Closing All Channels (EXPERIMENTAL)" |
||||
|
echo "***********************************" |
||||
|
echo "" |
||||
|
echo "COMMAND LINE: " |
||||
|
echo $command |
||||
|
echo "" |
||||
|
echo "RESULT:" |
||||
|
|
||||
|
# PRECHECK) check if chain is in sync |
||||
|
chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c) |
||||
|
if [ ${chainInSync} -eq 0 ]; then |
||||
|
command="" |
||||
|
result="FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync " |
||||
|
fi |
||||
|
|
||||
|
# execute command |
||||
|
if [ ${#command} -gt 0 ]; then |
||||
|
${command} |
||||
|
fi |
||||
|
|
||||
|
echo "" |
||||
|
echo "OK - wait a 5 seconds" |
||||
|
sleep 5 |
||||
|
|
||||
|
echo "Your Open Channel List (to check):" |
||||
|
lnchannels |
@ -0,0 +1,122 @@ |
|||||
|
#!/bin/sh |
||||
|
_temp="./download/dialog.$$" |
||||
|
_error="./.error.out" |
||||
|
|
||||
|
# load network and chain info |
||||
|
network=`cat .network` |
||||
|
chain=$(sudo -bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') |
||||
|
|
||||
|
# set ntwork map info |
||||
|
networkMap="https://lnmainnet.gaben.win" |
||||
|
if [ "$network" = "litecoin" ]; then |
||||
|
networkMap="https://lnexplorer.hcwong.me" |
||||
|
fi |
||||
|
if [ "$chain" = "test" ]; then |
||||
|
networkMap="https://explorer.acinq.co" |
||||
|
fi |
||||
|
|
||||
|
# let user enter a <pubkey>@host |
||||
|
l1="Enter the node pubkey address with host information:" |
||||
|
l2="example -----> 024ddf33[...]1f5f9f3@91.65.1.38:9735" |
||||
|
l3="network map -> ${networkMap}" |
||||
|
dialog --title "Open a Connection to a Peer" \ |
||||
|
--backtitle "Lightning ( ${network} | ${chain} )" \ |
||||
|
--inputbox "$l1\n$l2\n$l3" 10 60 2>$_temp |
||||
|
_input=$(cat $_temp | xargs ) |
||||
|
shred $_temp |
||||
|
if [ ${#_input} -eq 0 ]; then |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# build command |
||||
|
command="lncli --chain=${network} connect ${_input}" |
||||
|
|
||||
|
# info output |
||||
|
clear |
||||
|
echo "******************************" |
||||
|
echo "Connect to A Lightning Node" |
||||
|
echo "******************************" |
||||
|
echo "" |
||||
|
echo "COMMAND LINE: " |
||||
|
echo $command |
||||
|
echo "" |
||||
|
echo "RESULT (might have to wait for timeout):" |
||||
|
|
||||
|
win=1 |
||||
|
info="" |
||||
|
|
||||
|
# check if input is available |
||||
|
if [ ${#_input} -lt 10 ]; then |
||||
|
win=0 |
||||
|
info="node pubkey@host info is too short" |
||||
|
else |
||||
|
gotAt=$(echo $_input | grep '@' -c) |
||||
|
if [ ${gotAt} -eq 0 ]; then |
||||
|
win=0 |
||||
|
info="format is not pubkey@host - @ is missing" |
||||
|
fi |
||||
|
fi |
||||
|
|
||||
|
# execute command |
||||
|
sleep 2 |
||||
|
result="$info" |
||||
|
if [ ${win} -eq 1 ]; then |
||||
|
result=$($command 2>$_error) |
||||
|
fi |
||||
|
|
||||
|
# on no result |
||||
|
if [ ${#result} -eq 0 ]; then |
||||
|
|
||||
|
# basic error |
||||
|
win=0 |
||||
|
info="No return value. Error not known." |
||||
|
|
||||
|
# try to get error output |
||||
|
result=`cat ${_error}` |
||||
|
echo "$result" |
||||
|
|
||||
|
# basic cli error |
||||
|
cliError=$(echo "${result}" | grep "[lncli]" -c ) |
||||
|
if [ ${cliError} -gt 0 ]; then |
||||
|
info="Its possible that LND daemon is not running, not configured correct or not connected to the lncli." |
||||
|
fi |
||||
|
|
||||
|
else |
||||
|
|
||||
|
# when result is available |
||||
|
echo "$result" |
||||
|
|
||||
|
# check if the node is now in peer list |
||||
|
pubkey=$(echo $_input | cut -d '@' -f1) |
||||
|
isPeer=$(lncli --chain=${network} listpeers 2>/dev/null| grep "${pubkey}" -c) |
||||
|
if [ ${isPeer} -eq 0 ]; then |
||||
|
|
||||
|
# basic error message |
||||
|
win=0 |
||||
|
info="Was not able to establish connection to node." |
||||
|
|
||||
|
# TODO: try to find out more details from cli output |
||||
|
|
||||
|
else |
||||
|
info="Perfect - a connection to that node got established :)" |
||||
|
fi |
||||
|
|
||||
|
fi |
||||
|
|
||||
|
# output info |
||||
|
echo "" |
||||
|
if [ ${win} -eq 1 ]; then |
||||
|
echo "******************************" |
||||
|
echo "WIN" |
||||
|
echo "******************************" |
||||
|
echo "${info}" |
||||
|
echo "" |
||||
|
echo "Whats next? --> Open a channel with that node." |
||||
|
else |
||||
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "FAIL" |
||||
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "${info}" |
||||
|
fi |
||||
|
|
||||
|
echo "" |
@ -0,0 +1,91 @@ |
|||||
|
#!/bin/bash |
||||
|
_temp="./download/dialog.$$" |
||||
|
_error="./.error.out" |
||||
|
|
||||
|
# load network and chain info |
||||
|
network=`cat .network` |
||||
|
chain=$(sudo -bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') |
||||
|
|
||||
|
echo "" |
||||
|
echo "*** Precheck ***" |
||||
|
|
||||
|
# check if chain is in sync |
||||
|
chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c) |
||||
|
if [ ${chainInSync} -eq 0 ]; then |
||||
|
echo "!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false" |
||||
|
echo "Wait until chain is sync with LND and try again." |
||||
|
echo "!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# check number of connected peers |
||||
|
echo "check for open channels" |
||||
|
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} listchannels 2>/dev/null | grep chan_id -c) |
||||
|
if [ ${openChannels} -eq 0 ]; then |
||||
|
echo "" |
||||
|
echo "!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "FAIL - You have NO ESTABLISHED CHANNELS .. open a channel first." |
||||
|
echo "!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# let user enter the invoice |
||||
|
l1="Enter the AMOUNT IN SATOSHI of the invoice:" |
||||
|
l2="1 ${network} = 100 000 000 SAT" |
||||
|
dialog --title "Pay thru Lightning Network" \ |
||||
|
--inputbox "$l1\n$l2" 9 50 2>$_temp |
||||
|
amount=$(cat $_temp | xargs | tr -dc '0-9') |
||||
|
shred $_temp |
||||
|
if [ ${#amount} -eq 0 ]; then |
||||
|
echo "FAIL - not a valid input (${amount})" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# build command |
||||
|
command="lncli --chain=${network} addinvoice ${amount}" |
||||
|
|
||||
|
# info output |
||||
|
clear |
||||
|
echo "******************************" |
||||
|
echo "Create Invoice / Payment Request" |
||||
|
echo "******************************" |
||||
|
echo "" |
||||
|
echo "COMMAND LINE: " |
||||
|
echo $command |
||||
|
echo "" |
||||
|
echo "RESULT:" |
||||
|
sleep 2 |
||||
|
|
||||
|
# execute command |
||||
|
result=$($command 2>$_error) |
||||
|
error=`cat ${_error}` |
||||
|
|
||||
|
#echo "result(${result})" |
||||
|
#echo "error(${error})" |
||||
|
|
||||
|
if [ ${#error} -gt 0 ]; then |
||||
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "FAIL" |
||||
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "${error}" |
||||
|
else |
||||
|
echo "******************************" |
||||
|
echo "WIN" |
||||
|
echo "******************************" |
||||
|
echo "${result}" |
||||
|
echo "" |
||||
|
rhash=$(echo "$result" | grep r_hash | cut -d '"' -f4) |
||||
|
payReq=$(echo "$result" | grep pay_req | cut -d '"' -f4) |
||||
|
echo "Give this Invoice/PaymentRequest to someone to pay it:" |
||||
|
echo "" |
||||
|
echo ${payReq} |
||||
|
echo "" |
||||
|
echo "You can use 'lncli --chain=${network} lookupinvoice ${rhash}' to check the payment. " |
||||
|
|
||||
|
# TODO: Offer to go into monitor for incommin payment loop. |
||||
|
|
||||
|
fi |
||||
|
echo "" |
@ -0,0 +1,63 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# load network and chain info |
||||
|
network=`cat .network` |
||||
|
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') |
||||
|
|
||||
|
command="lncli --chain=${network} newaddress np2wkh" |
||||
|
|
||||
|
clear |
||||
|
echo "******************************" |
||||
|
echo "Fund your Blockchain Wallet" |
||||
|
echo "******************************" |
||||
|
echo "" |
||||
|
echo "COMMAND LINE: " |
||||
|
echo $command |
||||
|
echo "" |
||||
|
echo "RESULT:" |
||||
|
|
||||
|
# PRECHECK) check if chain is in sync |
||||
|
chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c) |
||||
|
if [ ${chainInSync} -eq 0 ]; then |
||||
|
command="" |
||||
|
result="FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync " |
||||
|
fi |
||||
|
|
||||
|
# execute command |
||||
|
if [ ${#command} -gt 0 ]; then |
||||
|
result=$($command) |
||||
|
fi |
||||
|
|
||||
|
# on no result |
||||
|
if [ ${#result} -eq 0 ]; then |
||||
|
echo "Sorry something went wrong - thats unusual." |
||||
|
echo "" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# when result is available |
||||
|
echo "$result" |
||||
|
|
||||
|
# get address from result |
||||
|
address=$( echo "$result" | grep "address" | cut -d '"' -f4) |
||||
|
|
||||
|
# prepare coin info |
||||
|
coininfo="REAL Bitcoin" |
||||
|
if [ "$network" = "litecoin" ]; then |
||||
|
coininfo="REAL Litecoin" |
||||
|
fi |
||||
|
if [ "$chain" = "test" ]; then |
||||
|
coininfo="TESTNET Bitcoin" |
||||
|
fi |
||||
|
|
||||
|
# output info |
||||
|
echo "" |
||||
|
echo "******************************" |
||||
|
echo "TODO" |
||||
|
echo "******************************" |
||||
|
echo "Send ${coininfo} to address --> ${address}" |
||||
|
if [ "$chain" = "test" ]; then |
||||
|
echo "get some testnet coins from https://testnet.manu.backend.hamburg/faucet" |
||||
|
fi |
||||
|
echo "Whats next? --> Wait for confirmations. You can use lnbalance for main menu or info on LCD to check if funds have arrived." |
||||
|
echo "" |
@ -0,0 +1,136 @@ |
|||||
|
#!/bin/bash |
||||
|
_temp="./download/dialog.$$" |
||||
|
_error="./.error.out" |
||||
|
|
||||
|
# load network and chain info |
||||
|
network=`cat .network` |
||||
|
chain=$(sudo -bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') |
||||
|
|
||||
|
echo "" |
||||
|
echo "*** Precheck ***" |
||||
|
|
||||
|
# check if chain is in sync |
||||
|
chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c) |
||||
|
if [ ${chainInSync} -eq 0 ]; then |
||||
|
echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false" |
||||
|
echo "Wait until chain is sync with LND and try again." |
||||
|
echo "" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# check available funding |
||||
|
confirmedBalance=$(lncli --chain=${network} walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4) |
||||
|
if [ ${confirmedBalance} -eq 0 ]; then |
||||
|
echo "FAIL - You have 0 SATOSHI in your confirmed LND On-Chain Wallet." |
||||
|
echo "Please fund your on-chain wallet first and wait until confirmed." |
||||
|
echo "" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# check number of connected peers |
||||
|
numConnectedPeers=$(lncli --chain=${network} listpeers | grep pub_key -c) |
||||
|
if [ ${numConnectedPeers} -eq 0 ]; then |
||||
|
echo "FAIL - no peers connected on lightning network" |
||||
|
echo "You can only open channels to peer nodes to connected to first." |
||||
|
echo "Use CONNECT peer option in main menu first." |
||||
|
echo "" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# let user pick a peer to open a channels with |
||||
|
OPTIONS=() |
||||
|
while IFS= read -r grepLine |
||||
|
do |
||||
|
pubKey=$(echo ${grepLine} | cut -d '"' -f4) |
||||
|
#echo "grepLine(${pubKey})" |
||||
|
OPTIONS+=(${pubKey} "") |
||||
|
done < <(lncli --chain=${network} listpeers | grep pub_key) |
||||
|
TITLE="Open (Payment) Channel" |
||||
|
MENU="\nChoose a peer you connected to, to open the channel with: \n " |
||||
|
pubKey=$(dialog --clear \ |
||||
|
--title "$TITLE" \ |
||||
|
--menu "$MENU" \ |
||||
|
14 73 5 \ |
||||
|
"${OPTIONS[@]}" \ |
||||
|
2>&1 >/dev/tty) |
||||
|
|
||||
|
clear |
||||
|
if [ ${#pubKey} -eq 0 ]; then |
||||
|
echo "Selected CANCEL" |
||||
|
echo "" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# find out what is the minimum amount |
||||
|
# TODO find a better way - also consider dust and channel reserve |
||||
|
# details see here: https://github.com/btcontract/lnwallet/issues/52 |
||||
|
minSat=20000 |
||||
|
if [ "${network}" = "bitcoin" ]; then |
||||
|
minSat=250000 |
||||
|
fi |
||||
|
_error="./.error.out" |
||||
|
lncli --chain=${network} openchannel ${CHOICE} 1 0 2>$_error |
||||
|
error=`cat ${_error}` |
||||
|
if [ $(echo "${error}" | grep "channel is too small" -c) -eq 1 ]; then |
||||
|
minSat=$(echo "${error}" | tr -dc '0-9') |
||||
|
fi |
||||
|
|
||||
|
# let user enter a amount |
||||
|
l1="Amount in SATOSHI to fund this channel:" |
||||
|
l2="min required : ${minSat}" |
||||
|
l3="max available : ${confirmedBalance}" |
||||
|
dialog --title "Funding of Channel" \ |
||||
|
--inputbox "$l1\n$l2\n$l3" 10 60 2>$_temp |
||||
|
amount=$(cat $_temp | xargs | tr -dc '0-9') |
||||
|
shred $_temp |
||||
|
if [ ${#amount} -eq 0 ]; then |
||||
|
echo "FAIL - not a valid input (${amount})" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# build command |
||||
|
command="lncli --chain=${network} openchannel ${pubKey} ${amount} 0" |
||||
|
|
||||
|
# info output |
||||
|
clear |
||||
|
echo "******************************" |
||||
|
echo "Open Channel" |
||||
|
echo "******************************" |
||||
|
echo "" |
||||
|
echo "COMMAND LINE: " |
||||
|
echo $command |
||||
|
echo "" |
||||
|
echo "RESULT:" |
||||
|
|
||||
|
# execute command |
||||
|
result=$($command 2>$_error) |
||||
|
error=`cat ${_error}` |
||||
|
|
||||
|
#echo "result(${result})" |
||||
|
#echo "error(${error})" |
||||
|
|
||||
|
if [ ${#error} -gt 0 ]; then |
||||
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "FAIL" |
||||
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "${error}" |
||||
|
else |
||||
|
echo "******************************" |
||||
|
echo "WIN" |
||||
|
echo "******************************" |
||||
|
echo "${result}" |
||||
|
echo "" |
||||
|
echo "Whats next? --> You need to wait 6 confirmations, for the channel to be ready." |
||||
|
fundingTX=$(echo "${result}" | grep 'funding_txid' | cut -d '"' -f4) |
||||
|
if [ "${network}" = "bitcoin" ]; then |
||||
|
if [ "${chain}" = "main" ]; then |
||||
|
echo "https://blockexplorer.com/tx/${fundingTX}" |
||||
|
else |
||||
|
echo "https://testnet.blockexplorer.com/tx/${fundingTX}" |
||||
|
fi |
||||
|
fi |
||||
|
if [ "${network}" = "litecoin" ]; then |
||||
|
echo "https://live.blockcypher.com/ltc/tx/${fundingTX}/" |
||||
|
fi |
||||
|
fi |
||||
|
echo "" |
@ -0,0 +1,106 @@ |
|||||
|
#!/bin/bash |
||||
|
_temp="./download/dialog.$$" |
||||
|
_error="./.error.out" |
||||
|
|
||||
|
# load network and chain info |
||||
|
network=`cat .network` |
||||
|
chain=$(sudo -bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') |
||||
|
|
||||
|
echo "" |
||||
|
echo "*** Precheck ***" |
||||
|
|
||||
|
# check if chain is in sync |
||||
|
chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c) |
||||
|
if [ ${chainInSync} -eq 0 ]; then |
||||
|
echo "!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false" |
||||
|
echo "Wait until chain is sync with LND and try again." |
||||
|
echo "!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
|
||||
|
# check number of connected peers |
||||
|
echo "check for open channels" |
||||
|
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} listchannels 2>/dev/null | grep chan_id -c) |
||||
|
if [ ${openChannels} -eq 0 ]; then |
||||
|
echo "" |
||||
|
echo "!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "FAIL - You have NO ESTABLISHED CHANNELS .. open a channel first." |
||||
|
echo "!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
paymentRequestStart="???" |
||||
|
if [ "${network}" = "bitcoin" ]; then |
||||
|
if [ "${chain}" = "main" ]; then |
||||
|
paymentRequestStart="lnbc" |
||||
|
else |
||||
|
paymentRequestStart="lntb" |
||||
|
fi |
||||
|
elif [ "${network}" = "litecoin" ]; then |
||||
|
paymentRequestStart="lnltc" |
||||
|
fi |
||||
|
|
||||
|
testSite="???" |
||||
|
if [ "${network}" = "bitcoin" ]; then |
||||
|
if [ "${chain}" = "main" ]; then |
||||
|
testSite="https://satoshis.place" |
||||
|
else |
||||
|
testSite="https://testnet.satoshis.place" |
||||
|
fi |
||||
|
elif [ "${network}" = "litecoin" ]; then |
||||
|
testSite="https://millionlitecoinhomepage.net" |
||||
|
fi |
||||
|
|
||||
|
# let user enter the invoice |
||||
|
l1="Copy the LightningInvoice/PaymentRequest into here:" |
||||
|
l2="Its a long string starting with '${paymentRequestStart}'" |
||||
|
l3="To try it out go to: ${testSite}" |
||||
|
dialog --title "Pay thru Lightning Network" \ |
||||
|
--inputbox "$l1\n$l2\n$l3" 10 70 2>$_temp |
||||
|
invoice=$(cat $_temp | xargs) |
||||
|
shred $_temp |
||||
|
if [ ${#invoice} -eq 0 ]; then |
||||
|
echo "FAIL - not a valid input (${invoice})" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# TODO: maybe try/show the decoded info first by using https://api.lightning.community/#decodepayreq |
||||
|
|
||||
|
# build command |
||||
|
command="lncli --chain=${network} sendpayment --pay_req=${invoice}" |
||||
|
|
||||
|
# info output |
||||
|
clear |
||||
|
echo "******************************" |
||||
|
echo "Pay Invoice / Payment Request" |
||||
|
echo "******************************" |
||||
|
echo "" |
||||
|
echo "COMMAND LINE: " |
||||
|
echo $command |
||||
|
echo "" |
||||
|
echo "RESULT (may wait in case of timeout):" |
||||
|
|
||||
|
# execute command |
||||
|
result=$($command 2>$_error) |
||||
|
error=`cat ${_error}` |
||||
|
|
||||
|
#echo "result(${result})" |
||||
|
#echo "error(${error})" |
||||
|
|
||||
|
if [ ${#error} -gt 0 ]; then |
||||
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "FAIL" |
||||
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "${error}" |
||||
|
else |
||||
|
echo "${result}" |
||||
|
echo "******************************" |
||||
|
echo "WIN" |
||||
|
echo "******************************" |
||||
|
echo "It worked :) - check out the service you were paying." |
||||
|
fi |
||||
|
echo "" |
@ -1,22 +1,27 @@ |
|||||
echo "" |
echo "" |
||||
|
|
||||
|
# load network |
||||
|
network=`cat .network` |
||||
|
|
||||
echo "!!!! This will DELETE your personal data from the HDD !!!!" |
echo "!!!! This will DELETE your personal data from the HDD !!!!" |
||||
echo "--> use the HDD with just blockchain in a fresh setup" |
echo "--> use the HDD with just blockchain in a fresh setup" |
||||
echo "Press ENTER to continue - CTRL+c to CANCEL" |
echo "Press ENTER to continue - CTRL+c to CANCEL" |
||||
read key |
read key |
||||
sudo dphys-swapfile swapoff |
sudo dphys-swapfile swapoff |
||||
sudo systemctl stop bitcoind.service |
sudo systemctl stop ${network}d.service |
||||
sudo systemctl stop lnd.service |
sudo systemctl stop lnd.service |
||||
sudo rm -f -r /mnt/hdd/lnd |
sudo rm -f -r /mnt/hdd/lnd |
||||
sudo rm -f /mnt/hdd/swapfile |
sudo rm -f /mnt/hdd/swapfile |
||||
sudo rm -f /mnt/hdd/bitcoin/bitcoin.conf |
sudo rm -f /mnt/hdd/${network}/${network}.conf |
||||
sudo rm -f /mnt/hdd/bitcoin/bitcoin.pid |
sudo rm -f /mnt/hdd/${network}/${network}.pid |
||||
sudo rm -f /mnt/hdd/bitcoin/*.dat |
sudo rm -f /mnt/hdd/${network}/*.dat |
||||
sudo rm -f /mnt/hdd/bitcoin/*.log |
sudo rm -f /mnt/hdd/${network}/*.log |
||||
sudo rm -f /mnt/hdd/bitcoin/bitcoin.conf |
sudo rm -f /mnt/hdd/${network}/*.pid |
||||
sudo rm -f /mnt/hdd/bitcoin/testnet3/*.dat |
sudo rm -f /mnt/hdd/${network}/testnet3/*.dat |
||||
sudo rm -f /mnt/hdd/bitcoin/testnet3/*.log |
sudo rm -f /mnt/hdd/${network}/testnet3/*.log |
||||
sudo rm -f /mnt/hdd/bitcoin/testnet3/.lock |
sudo rm -f /mnt/hdd/${network}/testnet3/.lock |
||||
sudo rm -f -r /mnt/hdd/bitcoin/database |
sudo rm -f -r /mnt/hdd/${network}/database |
||||
sudo chown admin:admin -R /mnt/hdd/bitcoin |
sudo rm -f -r /mnt/hdd/tor |
||||
|
sudo chown admin:admin -R /mnt/hdd/${network} |
||||
echo "1" > /home/admin/.setup |
echo "1" > /home/admin/.setup |
||||
echo "OK - the HDD is now clean" |
echo "OK - the HDD is now clean" |
||||
|
@ -0,0 +1,171 @@ |
|||||
|
#!/bin/sh |
||||
|
echo "" |
||||
|
|
||||
|
# *** BITCOIN *** |
||||
|
bitcoinList="" # url to list with other sources |
||||
|
bitcoinUrl="ftp://anonymous:anonymous@tll9xsfkjht8j26z.myfritz.net/raspiblitz-bitcoin-2018-07-16" |
||||
|
bitcoinSize=100 |
||||
|
|
||||
|
# *** LITECOIN *** |
||||
|
litecoinList="" # url to list with other sources |
||||
|
litecoinUrl="ftp://anonymous:anonymous@ftp.rotzoll.de/pub/raspiblitz-litecoin-2018-07-29" |
||||
|
litecoinSize=19000000 |
||||
|
|
||||
|
# load network |
||||
|
network=`cat .network` |
||||
|
|
||||
|
# settings based on network |
||||
|
list=$bitcoinList |
||||
|
url=$bitcoinUrl |
||||
|
size=$bitcoinSize |
||||
|
if [ "$network" = "litecoin" ]; then |
||||
|
list=$litecoinList |
||||
|
url=$litecoinUrl |
||||
|
size=$litecoinSize |
||||
|
fi |
||||
|
|
||||
|
# screen background monitoring settings |
||||
|
name="Download" |
||||
|
targetDir="/mnt/hdd/download/" |
||||
|
targetSize=$size |
||||
|
maxTimeoutLoops=100 |
||||
|
command="sudo wget -c -r -P ${targetDir} -q --show-progress ${url}" |
||||
|
|
||||
|
# starting session if needed |
||||
|
echo "checking if ${name} has a running screen session" |
||||
|
screen -wipe 1>/dev/null |
||||
|
isRunning=$( screen -S ${name} -ls | grep "${name}" -c ) |
||||
|
echo "isRunning(${isRunning})" |
||||
|
if [ ${isRunning} -eq 0 ]; then |
||||
|
echo "Starting screen session" |
||||
|
screen -S ${name} -dm ${command} |
||||
|
else |
||||
|
echo "Continue screen session" |
||||
|
fi |
||||
|
sleep 3 |
||||
|
|
||||
|
# monitor session |
||||
|
screenDump="... started ..." |
||||
|
actualSize=0 |
||||
|
timeout=1 |
||||
|
timeoutInfo="-" |
||||
|
while : |
||||
|
do |
||||
|
|
||||
|
# check if session is still running |
||||
|
screen -wipe 1>/dev/null |
||||
|
isRunning=$( screen -S ${name} -ls | grep "${name}" -c ) |
||||
|
if [ ${isRunning} -eq 0 ]; then |
||||
|
timeout=0 |
||||
|
echo "OK - session finished" |
||||
|
break |
||||
|
fi |
||||
|
|
||||
|
# calculate progress and write it to file for LCD to read |
||||
|
freshSize=$( du -s ${targetDir} | head -n1 | awk '{print $1;}' ) |
||||
|
if [ ${#actualSize} -eq 0 ]; then |
||||
|
freshSize=0 |
||||
|
fi |
||||
|
progress=$(echo "scale=2; $freshSize*100/$targetSize" | bc) |
||||
|
echo $progress > '.${name}.progress' |
||||
|
|
||||
|
# detect if since last loop any progress occured |
||||
|
if [ ${actualSize} -eq ${freshSize} ]; then |
||||
|
timeoutInfo="${timeout}/${maxTimeoutLoops}" |
||||
|
timeout=$(( $timeout + 1 )) |
||||
|
else |
||||
|
timeout=1 |
||||
|
timeoutInfo="no timeout detected" |
||||
|
fi |
||||
|
actualSize=$freshSize |
||||
|
|
||||
|
# detect if mx timeout loop limit is reached |
||||
|
if [ ${timeout} -gt ${maxTimeoutLoops} ]; then |
||||
|
echo "FAIL - download hit timeout" |
||||
|
break |
||||
|
fi |
||||
|
|
||||
|
# display info screen |
||||
|
clear |
||||
|
echo "****************************************" |
||||
|
echo "Monitoring Screen Session: ${name}" |
||||
|
echo "Progress: ${progress}% (${actualSize} of ${targetSize})" |
||||
|
echo "Timeout: ${timeoutInfo}" |
||||
|
echo "Press key x to abort this process" |
||||
|
echo "****************************************" |
||||
|
screen -S ${name} -X hardcopy .${name}.out |
||||
|
newScreenDump=$(cat .Download.out | grep . | tail -15) |
||||
|
if [ ${#newScreenDump} -gt 0 ]; then |
||||
|
screenDump=$newScreenDump |
||||
|
fi |
||||
|
echo $screenDump |
||||
|
|
||||
|
# wait 2 seconds for key input |
||||
|
read -n 1 -t 2 keyPressed |
||||
|
|
||||
|
# check if user wants to abort session |
||||
|
if [ "${keyPressed}" = "x" ]; then |
||||
|
echo "" |
||||
|
echo "Aborting ${name}" |
||||
|
break |
||||
|
fi |
||||
|
|
||||
|
done |
||||
|
|
||||
|
# clean up |
||||
|
rm -f .${name}.out |
||||
|
rm -f .${name}.progress |
||||
|
|
||||
|
# quit session if still running |
||||
|
if [ ${isRunning} -eq 1 ]; then |
||||
|
# get the PID of screen session |
||||
|
sessionPID=$(screen -ls | grep "${name}" | cut -d "." -f1 | xargs) |
||||
|
echo "killing screen session PID(${sessionPID})" |
||||
|
# kill all child processes of screen sceesion |
||||
|
pkill -P ${sessionPID} |
||||
|
echo "proccesses klilled" |
||||
|
sleep 3 |
||||
|
# tell the screen session to quit and wait a bit |
||||
|
screen -S ${name} -X quit 1>/dev/null |
||||
|
sleep 3 |
||||
|
echo "cleaning screen" |
||||
|
screen -wipe 1>/dev/null |
||||
|
sleep 3 |
||||
|
fi |
||||
|
|
||||
|
# the path wget will download to |
||||
|
targetPath=$(echo ${url} | cut -d '@' -f2) |
||||
|
echo "path to downloaded data is ${targetPath}" |
||||
|
|
||||
|
# calculate progress and write it to file for LCD to read |
||||
|
finalSize=$( du -s ${targetDir} | head -n1 | awk '{print $1;}' ) |
||||
|
if [ ${#actualSize} -eq 0 ]; then |
||||
|
finalSize=0 |
||||
|
fi |
||||
|
echo "final size is ${finalSize} of targeted size ${targetSize}" |
||||
|
|
||||
|
# check result |
||||
|
if [ ${finalSize} -lt ${targetSize} ]; then |
||||
|
|
||||
|
# Download failed |
||||
|
sleep 3 |
||||
|
echo -ne '\007' |
||||
|
dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want keep already downloaded data?" 6 57 |
||||
|
response=$? |
||||
|
case $response in |
||||
|
1) sudo rm -rf ${targetDir}${targetPath} ;; |
||||
|
esac |
||||
|
./00mainMenu.sh |
||||
|
exit 1; |
||||
|
|
||||
|
else |
||||
|
|
||||
|
# Download worked |
||||
|
echo "*** Moving Files ***" |
||||
|
sudo mv ${targetDir}${targetPath} /mnt/hdd/${network} |
||||
|
echo "OK" |
||||
|
|
||||
|
# continue setup |
||||
|
./60finishHDD.sh |
||||
|
|
||||
|
fi |
@ -0,0 +1,17 @@ |
|||||
|
#!/bin/bash |
||||
|
echo "" |
||||
|
echo "*** UPDATING SHELL SCRIPTS FROM GITHUB ***" |
||||
|
echo "justincase, not the final upadte mechanism" |
||||
|
echo "******************************************" |
||||
|
cd /home/admin/raspiblitz |
||||
|
git pull |
||||
|
cd .. |
||||
|
rm *.sh |
||||
|
rm -r assets |
||||
|
sudo -u admin cp /home/admin/raspiblitz/home.admin/*.sh /home/admin |
||||
|
sudo -u admin chmod +x *.sh |
||||
|
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/assets /home/admin/ |
||||
|
echo "******************************************" |
||||
|
echo "OK - shell scripts and assests are up to date" |
||||
|
echo "Reboot recommended" |
||||
|
echo "" |
@ -0,0 +1,23 @@ |
|||||
|
# RaspiBlitz: systemd unit for bitcoind |
||||
|
|
||||
|
[Unit] |
||||
|
Description=Bitcoin daemon |
||||
|
Wants=getpublicip.service |
||||
|
After=getpublicip.service |
||||
|
|
||||
|
# for use with sendmail alert (coming soon) |
||||
|
#OnFailure=systemd-sendmail@%n |
||||
|
|
||||
|
[Service] |
||||
|
User=bitcoin |
||||
|
Group=bitcoin |
||||
|
Type=forking |
||||
|
PIDFile=/home/bitcoin/.bitcoin/bitcoind.pid |
||||
|
ExecStart=/usr/local/bin/bitcoind -daemon -conf=/home/bitcoin/.bitcoin/bitcoin.conf -pid=/home/bitcoin/.bitcoin/bitcoind.pid |
||||
|
KillMode=process |
||||
|
Restart=always |
||||
|
TimeoutSec=120 |
||||
|
RestartSec=30 |
||||
|
|
||||
|
[Install] |
||||
|
WantedBy=multi-user.target |
@ -0,0 +1,20 @@ |
|||||
|
# RaspiBolt LND Mainnet: systemd unit for getpublicip.sh script |
||||
|
# /etc/systemd/system/getpublicip.service |
||||
|
|
||||
|
[Unit] |
||||
|
Description=getpublicip.sh: get public ip address from ipinfo.io |
||||
|
After=network.target |
||||
|
|
||||
|
[Service] |
||||
|
User=root |
||||
|
Group=root |
||||
|
Type=simple |
||||
|
ExecStart=/usr/local/bin/getpublicip.sh |
||||
|
ExecStartPost=/bin/sleep 5 |
||||
|
Restart=always |
||||
|
|
||||
|
RestartSec=600 |
||||
|
TimeoutSec=10 |
||||
|
|
||||
|
[Install] |
||||
|
WantedBy=multi-user.target |
@ -0,0 +1,16 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
echo 'getpublicip.sh started, writing public IP address every 10 minutes into /run/publicip' |
||||
|
while [ 0 ]; |
||||
|
do |
||||
|
# check if TOR is running |
||||
|
torExists=$(sudo ls /mnt/hdd/tor/lnd9735/hostname 2>/dev/null | grep hostname -c) |
||||
|
if [ ${torExists} -eq 0 ]; then |
||||
|
# get and set public IP |
||||
|
printf "PUBLICIP=$(curl -vv ipinfo.io/ip 2> /run/publicip.log)\n" > /run/publicip; |
||||
|
else |
||||
|
# set onion address |
||||
|
printf "PUBLICIP=$(sudo cat /mnt/hdd/tor/lnd9735/hostname)\n" > /run/publicip; |
||||
|
fi |
||||
|
sleep 600 |
||||
|
done; |
@ -0,0 +1,29 @@ |
|||||
|
# litecoind configuration |
||||
|
|
||||
|
# mainnet/testnet - to switch just comment/uncomment |
||||
|
#testnet=1 |
||||
|
|
||||
|
# Bitcoind options |
||||
|
server=1 |
||||
|
daemon=1 |
||||
|
txindex=1 |
||||
|
disablewallet=1 |
||||
|
|
||||
|
# Connection settings |
||||
|
rpcuser=raspibolt |
||||
|
rpcpassword=passwordB |
||||
|
zmqpubrawblock=tcp://127.0.0.1:28332 |
||||
|
zmqpubrawtx=tcp://127.0.0.1:28333 |
||||
|
|
||||
|
# Raspberry Pi optimizations |
||||
|
dbcache=100 |
||||
|
maxorphantx=10 |
||||
|
maxmempool=50 |
||||
|
maxconnections=40 |
||||
|
maxuploadtarget=5000 |
||||
|
|
||||
|
# litecoin specials |
||||
|
discardfee=0.00000001 |
||||
|
mintxfee=0.00000001 |
||||
|
minrelaytxfee=0.00000001 |
||||
|
datadir=/home/bitcoin/.litecoin |
@ -0,0 +1,20 @@ |
|||||
|
[Unit] |
||||
|
Description=Bitcoin daemon |
||||
|
Wants=getpublicip.service |
||||
|
After=getpublicip.service |
||||
|
|
||||
|
# for use with sendmail alert (coming soon) |
||||
|
#OnFailure=systemd-sendmail@%n |
||||
|
|
||||
|
[Service] |
||||
|
User=bitcoin |
||||
|
Group=bitcoin |
||||
|
Type=simple |
||||
|
ExecStart=/usr/local/bin/litecoind -daemon -conf=/home/bitcoin/.litecoin/litecoin.conf |
||||
|
KillMode=process |
||||
|
Restart=always |
||||
|
TimeoutSec=120 |
||||
|
RestartSec=30 |
||||
|
|
||||
|
[Install] |
||||
|
WantedBy=multi-user.target |
@ -0,0 +1,31 @@ |
|||||
|
# lnd configuration |
||||
|
|
||||
|
[Application Options] |
||||
|
debuglevel=info |
||||
|
maxpendingchannels=5 |
||||
|
alias=raspiblitz |
||||
|
color=#68F442 |
||||
|
|
||||
|
# RPC open to all connections on Port 10009 |
||||
|
rpclisten=0.0.0.0:10009 |
||||
|
# Domain, could use https://freedns.afraid.org |
||||
|
#tlsextradomain=lightning.yourhost.com |
||||
|
|
||||
|
[Bitcoin] |
||||
|
bitcoin.active=1 |
||||
|
|
||||
|
# enable either testnet or mainnet |
||||
|
#bitcoin.testnet=1 |
||||
|
bitcoin.mainnet=1 |
||||
|
|
||||
|
bitcoin.node=bitcoind |
||||
|
bitcoind.rpchost=127.0.0.1 |
||||
|
bitcoind.rpcuser=raspibolt |
||||
|
bitcoind.rpcpass=passwordB |
||||
|
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332 |
||||
|
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333 |
||||
|
|
||||
|
[autopilot] |
||||
|
autopilot.active=1 |
||||
|
autopilot.maxchannels=5 |
||||
|
autopilot.allocation=0.6 |
@ -1,22 +0,0 @@ |
|||||
# lnd configuration |
|
||||
|
|
||||
[Application Options] |
|
||||
debuglevel=info |
|
||||
debughtlc=true |
|
||||
maxpendingchannels=5 |
|
||||
# LINE7 -insert-> alias=[ALIAS] |
|
||||
color=#68F442 |
|
||||
|
|
||||
[Bitcoin] |
|
||||
bitcoin.active=1 |
|
||||
|
|
||||
# enable either testnet or mainnet |
|
||||
bitcoin.testnet=1 |
|
||||
#bitcoin.mainnet=1 |
|
||||
|
|
||||
bitcoin.node=bitcoind |
|
||||
|
|
||||
[autopilot] |
|
||||
autopilot.active=1 |
|
||||
autopilot.maxchannels=5 |
|
||||
autopilot.allocation=0.6 |
|
@ -0,0 +1,27 @@ |
|||||
|
# lnd configuration |
||||
|
|
||||
|
[Application Options] |
||||
|
debuglevel=info |
||||
|
maxpendingchannels=5 |
||||
|
alias=raspiblitz |
||||
|
color=#68F442 |
||||
|
|
||||
|
# RPC open to all connections on Port 10009 |
||||
|
rpclisten=0.0.0.0:10009 |
||||
|
# Domain, could use https://freedns.afraid.org |
||||
|
#tlsextradomain=lightning.yourhost.com |
||||
|
|
||||
|
[Litecoin] |
||||
|
litecoin.active=1 |
||||
|
litecoin.mainnet=1 |
||||
|
litecoin.node=litecoind |
||||
|
litecoind.rpchost=127.0.0.1 |
||||
|
litecoind.rpcuser=raspibolt |
||||
|
litecoind.rpcpass=passwordB |
||||
|
litecoind.zmqpubrawblock=tcp://127.0.0.1:28332 |
||||
|
litecoind.zmqpubrawtx=tcp://127.0.0.1:28333 |
||||
|
|
||||
|
[autopilot] |
||||
|
autopilot.active=1 |
||||
|
autopilot.maxchannels=5 |
||||
|
autopilot.allocation=0.6 |
@ -0,0 +1,27 @@ |
|||||
|
# RaspiBlitz: systemd unit for lnd |
||||
|
|
||||
|
[Unit] |
||||
|
Description=LND Lightning Daemon |
||||
|
Wants=bitcoind.service |
||||
|
After=bitcoind.service |
||||
|
|
||||
|
# for use with sendmail alert |
||||
|
#OnFailure=systemd-sendmail@%n |
||||
|
|
||||
|
[Service] |
||||
|
# get var PUBIP from file |
||||
|
EnvironmentFile=/run/publicip |
||||
|
|
||||
|
ExecStart=/usr/local/bin/lnd --externalip=${PUBLICIP} |
||||
|
PIDFile=/home/bitcoin/.lnd/lnd.pid |
||||
|
User=bitcoin |
||||
|
Group=bitcoin |
||||
|
LimitNOFILE=128000 |
||||
|
Type=simple |
||||
|
KillMode=process |
||||
|
TimeoutSec=180 |
||||
|
Restart=always |
||||
|
RestartSec=60 |
||||
|
|
||||
|
[Install] |
||||
|
WantedBy=multi-user.target |
@ -0,0 +1,32 @@ |
|||||
|
# RaspiBlitz: systemd unit for lnd |
||||
|
|
||||
|
[Unit] |
||||
|
Description=LND Lightning Daemon |
||||
|
Wants=bitcoind.service |
||||
|
After=bitcoind.service |
||||
|
|
||||
|
# for use with sendmail alert |
||||
|
#OnFailure=systemd-sendmail@%n |
||||
|
|
||||
|
[Service] |
||||
|
# get var PUBIP from file |
||||
|
EnvironmentFile=/run/publicip |
||||
|
|
||||
|
# TOR Hidden Service v2 |
||||
|
ExecStart=/usr/local/bin/lnd --tor.active --tor.v2 --listen=127.0.0.1:9735 |
||||
|
|
||||
|
# TOR Hidden Service v3 |
||||
|
# ExecStart=/usr/local/bin/lnd --tor.active --tor.v3 --externalip=${PUBLICIP} --listen=127.0.0.1:9735 |
||||
|
|
||||
|
PIDFile=/home/bitcoin/.lnd/lnd.pid |
||||
|
User=bitcoin |
||||
|
Group=bitcoin |
||||
|
LimitNOFILE=128000 |
||||
|
Type=simple |
||||
|
KillMode=process |
||||
|
TimeoutSec=180 |
||||
|
Restart=always |
||||
|
RestartSec=60 |
||||
|
|
||||
|
[Install] |
||||
|
WantedBy=multi-user.target |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 176 KiB |
After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 40 KiB |
@ -0,0 +1,12 @@ |
|||||
|
## Hardware Needed (Amazon.fr Shopping List) |
||||
|
|
||||
|
*The RaspiBlitz software is build and tested for the following Hardware set that you can buy cheap on Amazon.fr:* |
||||
|
|
||||
|
* RaspBerry Pi 3 (38,00 EUR) https://www.amazon.fr/dp/B07BDR5PDW |
||||
|
* Micro SD-Card 16GB (9,53 EUR) https://www.amazon.fr/dp/B073K14CVB/ |
||||
|
* Power (8,99 EUR) https://www.amazon.fr/dp/B01566WOAG |
||||
|
* 1TB Hard Drive (46,80 EUR) https://www.amazon.fr/dp/B07997KKSK |
||||
|
* Case (7,41 EUR) https://www.amazon.fr/dp/B0173GQF70/ |
||||
|
* LCD-Display (16,99 EUR) https://www.amazon.fr/dp/B01N2N86HB/ |
||||
|
|
||||
|
**Total Price: 127,72 EUR** |
@ -1,3 +1,8 @@ |
|||||
Your are from the UK? Your help is needed! |
*The RaspiBlitz software is build and tested for the following Hardware set that you can buy cheap on Amazon.co.uk:* |
||||
|
|
||||
It would be great if you can create a shopping list for amazon UK for the RaspiBlitz and test if everything is running with the hardware setup. Thx. |
* RaspBerry Pi 3 https://www.amazon.co.uk/Raspberry-Pi-Model-64-Bit-Processor/dp/B07BDR5PDW |
||||
|
* Micro SD-Card 16GB https://www.amazon.co.uk/Kingston-SDC10G2-16GB-microSDHC-Included/dp/B0162YQEIE |
||||
|
* Power https://www.amazon.co.uk/iTrunk-Raspberry-Model-Supply-Charger/dp/B01MFFSPHE |
||||
|
* 1TB Hard Drive https://www.amazon.co.uk/Toshiba-Canvio-Basics-Portable-External/dp/B00KWHJY7Q |
||||
|
* Case https://www.amazon.co.uk/SB-Components-Transparent-Case-Raspberry/dp/B0173GQF8Y |
||||
|
* LCD-Display https://www.amazon.co.uk/ELEGOO-480x320-Raspberry-Monitor-Interface/dp/B01MRQTMTD |