#!/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 -y libusb-1.0.0-dev libudev-dev virtualenv libssl-dev # 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 <=0.13.0,<0.14.0' 'hidapi>=0.7.99,<0.8.0' 'libusb1>=1.7,<2.0' 'mnemonic>=0.18.0,<0.19.0' 'pyaes>=1.6,<2.0' 'typing-extensions>=3.7,<4.0' pip3 install hwi --no-dependencies curl https://raw.githubusercontent.com/cryptoadvance/specter-desktop/master/requirements.txt | xargs -n 1 pip install pip3 install cryptoadvance.specter --no-dependencies exit sudo service cryptoadvance-specter restart # Hidden Service for BTC-RPC-explorer if Tor is active source /mnt/hdd/raspiblitz.conf if [ "${runBehindTor}" = "on" ]; then # correct old Hidden Service with port sudo sed -i "s/^HiddenServicePort 25441 127.0.0.1:25441/HiddenServicePort 80 127.0.0.1:25441/g" /etc/tor/torrc /home/admin/config.scripts/internet.hiddenservice.sh cryptoadvance-specter 80 25441 fi exit 0 fi # switch off if [ "$1" = "0" ] || [ "$1" = "off" ]; then # setting value in raspi blitz config sudo sed -i "s/^specter=.*/specter=off/g" /mnt/hdd/raspiblitz.conf isInstalled=$(sudo ls /etc/systemd/system/cryptoadvance-specter.service 2>/dev/null | grep -c 'cryptoadvance-specter.service') if [ ${isInstalled} -eq 1 ]; then echo "*** REMOVING Cryptoadvance Specter ***" sudo systemctl stop cryptoadvance-specter sudo systemctl disable cryptoadvance-specter sudo rm /etc/systemd/system/cryptoadvance-specter.service if whiptail --defaultno --yesno "Do you want to delete all Data related to specter? This includes also Bitcoin-Core-Wallets managed by specter?" 0 0; then echo "*** Removing wallets in core ***" bitcoin-cli listwallets | jq -r .[] | tail -n +2 for i in $(bitcoin-cli listwallets | jq -r .[] | tail -n +2) do name=$(echo $i | cut -d"/" -f2) bitcoin-cli unloadwallet specter/$name done sudo rm -rf /home/bitcoin/.bitcoin/specter echo "*** Removing /home/bitcoin/.specter ***" sudo rm -rf /home/bitcoin/.specter fi echo "OK Cryptoadvance Specter removed." else echo "Cryptoadvance Specter is not installed." fi exit 0 fi echo "FAIL - Unknown Parameter $1" exit 1