From 0efa33461aa3354c25ae91e6c9fd52a6ef090ed7 Mon Sep 17 00:00:00 2001 From: Kim Neunert Date: Mon, 16 Mar 2020 15:11:39 +0100 Subject: [PATCH] #1059 adding specter-desktop --- home.admin/00mainMenu.sh | 6 + home.admin/00settingsMenuServices.sh | 29 ++ .../bonus.cryptoadvance-specter.sh | 288 ++++++++++++++++++ 3 files changed, 323 insertions(+) create mode 100755 home.admin/config.scripts/bonus.cryptoadvance-specter.sh diff --git a/home.admin/00mainMenu.sh b/home.admin/00mainMenu.sh index c0292c7b7..60aa02cb3 100755 --- a/home.admin/00mainMenu.sh +++ b/home.admin/00mainMenu.sh @@ -57,6 +57,9 @@ fi if [ "${loop}" == "on" ]; then OPTIONS+=(LOOP "Loop In/Out Service") fi +if [ "${specter}" == "on" ]; then + OPTIONS+=(SPECTER "Cryptoadvance Specter") +fi # Basic Options OPTIONS+=(INFO "RaspiBlitz Status Screen") @@ -147,6 +150,9 @@ case $CHOICE in LOOP) /home/admin/config.scripts/bonus.loop.sh menu ;; + SPECTER) + /home/admin/config.scripts/bonus.cryptoadvance-specter.sh menu + ;; lnbalance) clear echo "*** YOUR SATOSHI BALANCES ***" diff --git a/home.admin/00settingsMenuServices.sh b/home.admin/00settingsMenuServices.sh index 068025c94..56b7fc2fc 100644 --- a/home.admin/00settingsMenuServices.sh +++ b/home.admin/00settingsMenuServices.sh @@ -12,6 +12,7 @@ if [ ${#autoUnlock} -eq 0 ]; then autoUnlock="off"; fi if [ ${#runBehindTor} -eq 0 ]; then runBehindTor="off"; fi if [ ${#rtlWebinterface} -eq 0 ]; then rtlWebinterface="off"; fi if [ ${#BTCRPCexplorer} -eq 0 ]; then BTCRPCexplorer="off"; fi +if [ ${#specter} -eq 0 ]; then specter="off"; fi if [ ${#chain} -eq 0 ]; then chain="main"; fi if [ ${#autoNatDiscovery} -eq 0 ]; then autoNatDiscovery="off"; fi if [ ${#networkUPnP} -eq 0 ]; then networkUPnP="off"; fi @@ -66,6 +67,7 @@ l 'Lightning Loop' ${loop} \ 4 'Run behind TOR' ${runBehindTor} \ 5 'RTL Webinterface' ${rtlWebinterface} \ b 'BTC-RPC-Explorer' ${BTCRPCexplorer} \ +s 'Cyryptoadvance Specter' ${specter} \ 6 'LND Auto-Unlock' ${autoUnlock} \ 9 'Touchscreen' ${touchscreenMenu} \ r 'LCD Rotate' ${lcdrotateMenu} \ @@ -83,6 +85,7 @@ l 'Lightning Loop' ${loop} \ 4 'Run behind TOR' ${runBehindTor} \ 5 'RTL Webinterface' ${rtlWebinterface} \ b 'BTC-RPC-Explorer' ${BTCRPCexplorer} \ +s 'Cyryptoadvance Specter' ${specter} \ 6 'LND Auto-Unlock' ${autoUnlock} \ 7 'BTC UPnP (AutoNAT)' ${networkUPnP} \ 8 'LND UPnP (AutoNAT)' ${autoNatDiscovery} \ @@ -370,6 +373,32 @@ else echo "BTC-RPC-Explorer Setting unchanged." fi +# cryptoadvance Specter process choice +choice="off"; check=$(echo "${CHOICES}" | grep -c "s") +if [ ${check} -eq 1 ]; then choice="on"; fi +if [ "${specter}" != "${choice}" ]; then + echo "Cryptoadvance Specter Setting changed .." + anychange=1 + /home/admin/config.scripts/bonus.cryptoadvance-specter.sh ${choice} + errorOnInstall=$? + if [ "${choice}" = "on" ]; then + if [ ${errorOnInstall} -eq 0 ]; then + #sudo sytemctl start cryptoadvance-specter + /home/admin/config.scripts/bonus.cryptoadvance-specter.sh menu + #whiptail --title " Installed Cryptoadvance Specter " --msgbox "\ + #You should be able to reach specter on port 25441. The Login is Password B.\n + #" 14 50 + else + l1="!!! FAIL on Cryptoadvance Specter install !!!" + l2="Try manual install on terminal after reboot with:" + l3="/home/admin/config.scripts/bonus.cryptoadvance-specter.sh on" + dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65 + fi + fi +else + echo "Cryptoadvance Specter Setting unchanged." +fi + # LND Auto-Unlock choice="off"; check=$(echo "${CHOICES}" | grep -c "6") if [ ${check} -eq 1 ]; then choice="on"; fi diff --git a/home.admin/config.scripts/bonus.cryptoadvance-specter.sh b/home.admin/config.scripts/bonus.cryptoadvance-specter.sh new file mode 100755 index 000000000..42e30e893 --- /dev/null +++ b/home.admin/config.scripts/bonus.cryptoadvance-specter.sh @@ -0,0 +1,288 @@ +#!/bin/bash + +# https://github.com/cryptoadvance/specter-desktop +# ~/.config/btc-rpc-explorer.env +# https://github.com/janoside/btc-rpc-explorer/blob/master/.env-sample + +# command info +if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then + echo "small config script to switch cryptoadvance specter on or off" + echo "bonus.cryptoadvance-specter.sh [status|on|off]" + exit 1 +fi + +source /mnt/hdd/raspiblitz.conf + +# show info menu +if [ "$1" = "menu" ]; then + + # get status + echo "# collecting status info ... (please wait)" + source <(sudo /home/admin/config.scripts/bonus.cryptoadvance-specter.sh status) + + # get network info + localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') + toraddress=https://$(sudo cat /mnt/hdd/tor/cryptoadvance-specter/hostname 2>/dev/null) + + if [ "${runBehindTor}" = "on" ] && [ ${#toraddress} -gt 0 ]; then + + # TOR + /home/admin/config.scripts/blitz.lcd.sh qr "${toraddress}" + whiptail --title " Cryptoadvance Specter " --msgbox "Open the following URL in your local web browser: +https://${localip}:25441 +You have to accept the self-signed-certificate. +Login with the Pin being Password B. If you have connected to a different Bitcoin RPC Endpoint, the Pin is the configured RPCPassword. +Hidden Service address for TOR Browser (QR see LCD): +${toraddress}\n +" 16 70 + /home/admin/config.scripts/blitz.lcd.sh hide + else + + # IP + Domain + whiptail --title " Cryptoadvance Specter " --msgbox "Open the following URL in your local web browser: +https://${localip}:25441 +You have to accept the self-signed-certificate. +Login with the Pin being Password B. If you have connected to a different Bitcoin RPC Endpoint, the Pin is the configured RPCPassword.\n +Activate TOR to access the web block explorer from outside your local network. +Unfortunately the camera is currently not usable via Tor, though. +" 12 54 + fi + + echo "please wait ..." + exit 0 +fi + +# add default value to raspi config if needed +if ! grep -Eq "^specter=" /mnt/hdd/raspiblitz.conf; then + echo "specter=off" >> /mnt/hdd/raspiblitz.conf +fi + +# status +if [ "$1" = "status" ]; then + + if [ "${specter}" = "on" ]; then + echo "configured=1" + + # check for error + isDead=$(sudo systemctl status cryptoadvance-specter | grep -c 'inactive (dead)') + if [ ${isDead} -eq 1 ]; then + echo "error='Service Failed'" + exit 1 + fi + + else + echo "configured=0" + fi + exit 0 +fi + +# stop service +echo "making sure services are not running" +sudo systemctl stop cryptoadvance-specter 2>/dev/null + +# switch on +if [ "$1" = "1" ] || [ "$1" = "on" ]; then + echo "*** INSTALL Cryptoadvance Specter ***" + + isInstalled=$(sudo ls /etc/systemd/system/cryptoadvance-specter.service 2>/dev/null | grep -c 'cryptoadvance-specter.service') + if [ ${isInstalled} -eq 0 ]; then + + echo "*** Enable wallets in Bitcoin Core ***" + sudo sed -i "s/^disablewallet=.*/disablewallet=0/g" /home/bitcoin/.bitcoin/bitcoin.conf + sudo service bitcoind stop + sudo service bitcoind start + + echo "*** Installing prerequisites ***" + sudo apt install libusb-1.0.0-dev libudev-dev virtualenv + + # activating Authentication here ... + echo "*** creating App-config ***" + cat > /home/admin/config.json < /home/admin/20-hw1.rules < /home/admin/51-coinkite.rules < +KERNEL=="hidraw*", ATTRS{idVendor}=="d13e", ATTRS{idProduct}=="cc10", GROUP="plugdev", MODE="0666" +EOF + cat > /home/admin/51-trezor.rules < /home/admin/51-usb-keepkey.rules < /home/admin/cryptoadvance-specter.service <