raspiblitz/home.admin/config.scripts/bonus.specter.sh

484 lines
17 KiB
Bash
Raw Normal View History

2020-03-16 15:11:39 +01:00
#!/bin/bash
# https://github.com/cryptoadvance/specter-desktop
2020-03-16 15:11:39 +01:00
2022-02-10 15:49:19 +00:00
pinnedVersion="1.8.1"
2020-11-04 18:33:25 +00:00
2020-03-16 15:11:39 +01:00
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "config script to switch Specter Desktop on, off, configure or update"
echo "bonus.specter.sh [status|on|off|config|update] <mainnet|testnet|signet>"
2020-11-04 18:33:25 +00:00
echo "installing the version $pinnedVersion by default"
2020-03-16 15:11:39 +01:00
exit 1
fi
echo "# bonus.specter.sh $1 $2"
2021-12-20 11:40:34 +01:00
source /mnt/hdd/raspiblitz.conf
if [ $# -gt 1 ];then
CHAIN=$2
chain=${CHAIN::-3}
fi
2020-03-16 15:11:39 +01:00
2020-10-08 20:52:37 +02:00
# get status key/values
if [ "$1" = "status" ]; then
if [ "${specter}" = "on" ]; then
echo "configured=1"
2022-05-05 10:59:50 +02:00
installed=$(sudo ls /etc/systemd/system/specter.service 2>/dev/null | grep -c 'specter.service')
echo "installed=${installed}"
2020-10-08 20:52:37 +02:00
# get network info
merging pre-1.7.1 (#2462) * fix copychain returns * typo in sync loop * stop services on inconsistent state * calling correct provisioning * apply bitcoin and lncli aliases in all scripts * network.aliases: add CLNETWORK * make cln default plugin dir: cln-plugins-enabled similar to the nginx model make 2 directories for plugins: cln-plugins-enabled - symlinked to ~/.lightning/plugins plugins from here are loaded automatically on cln start cln-plugins-available: plugins are downloaded here to be run until the next cln restart (or stopped with runonce) note the disk is mounted with noexec so plugins can't run from there discuss in: https://github.com/rootzoll/raspiblitz/issues/2295 * move shutdown script * change all place where shutdown script is used * change notify & release * moved shutdown script * moved shutdown scripts * add more debug info * moving github script * remove chain in sync * no longer needed chain in sync * move debug script * patch patch command * make sure setup file is sourced * remove debug output * make sure lnd is put behind tor * change indent * get fresh sync progress * avoid scrolling in menus * use new selfsignedcert if no lnd tls.cert present * sparko: add info and connect menu with own cert https://github.com/rootzoll/raspiblitz/issues/2295 * cln.rest: add connect option for Zeus https://github.com/rootzoll/raspiblitz/issues/2295 * cln: add the backup plugin + options Usage options: cln-plugin.backup.sh [on] [testnet|mainnet|signet] cln-plugin.backup.sh [restore] [testnet|mainnet|signet] [force] cln-plugin.backup.sh [backup-compact] [testnet|mainnet|signet] https://github.com/lightningd/plugins/tree/master/backup Discussed in: https://github.com/rootzoll/raspiblitz/issues/2295 * cln: add cln-plugin.standard.python.sh Install and show the output of the chosen plugin for C-lightning Usage: cln-plugin.standard-python.sh on [plugin-name] [testnet|mainnet|signet] [runonce] tested plugins: summary | helpme | feeadjuster find more at: https://github.com/lightningd/plugins discussed in: https://github.com/rootzoll/raspiblitz/issues/2295 * shellcheck: change all `egrep` to `grep -E` https://github.com/koalaman/shellcheck/wiki/SC2196 * do not resolve aliases, use as variables * lnd: fix lnd.conf for parallel networks discussed in: https://github.com/rootzoll/raspiblitz/issues/2290 * lnd: add LND option for parallel networks * deprecate Testnet in SETTINGS keysend and autopilot only for mainnet due to: https://github.com/rootzoll/raspiblitz/issues/2290 * lnd: autopilot and autounlock for testnet * fix comments * add the SYSTEM menu for parallel chains * RTL update to v0.11.0 make chain specific directory for the config: /home/rtl/${netprefix}RTL/ use ${netprefix}lnd.conf in config override Environmen tvaribales for cln in the systemd service: /etc/systemd/system/${netprefix}${typeprefix}RTL.service discussed in: https://github.com/rootzoll/raspiblitz/issues/2384 * lnd.setname.sh for testnet * display ${CHAIN} in the SYSTEM menu options * keep _aliases file when live patches are applied * all lncli_aliases to be used as variables * default to KIllMode=control-group in services https://www.man7.org/linux/man-pages/man5/systemd.kill.5.html discussed in: https://github.com/rootzoll/raspiblitz/issues/1901 * add cln.hsmtool.sh for hsm_secret handling encrypt | decrypt | autounlock the hsm_secret for C-lightning usage: cln.hsmtool.sh [unlock] [testnet|mainnet|signet] cln.hsmtool.sh [encrypt|decrypt] [testnet|mainnet|signet] cln.hsmtool.sh [autounlock-on|autounlock-off] [testnet|mainnet|signet] discussed in: https://github.com/rootzoll/raspiblitz/issues/2295 * add cln.install-service.sh to set up cln with systemd script to set up or update the CLN systemd service checks for hsm_secret encryption, autounlock and the sparko plugin usage: /home/admin/config.scripts/cln.install-service.sh $CHAIN discussed in: https://github.com/rootzoll/raspiblitz/issues/2295 * use symlink to cln-plugins-enabled for all plugins * keep lnd autopilot and autounlock mainnet only mainnet only settings: lnd autopilot lnd keysend circuibreaker lnd autounlock StaticChannelBackup to DropBox and USB * cln FUNDING fix parsing address * cln.hsmtool: add change-password and lock options * always set password A * cached peer info * fix printing cache * fix check for existing files * handle bitcoind not running * result with newline * test line break * test new line * test new line * two vars on output * #2388 improve online check (less pinging) * used cached peer status * move chache * cach file permissions * allow sudo call * fix cache * remove double scan info * add conf info to sync screen * reorder info * add space * add space * order info * internet suppress error messages * order info * fix offering Blockchain copy * fix hostname * final ready state info * lnd unlock after provision * remove debug exit * harmonize ready state * add status to lnd unlock * update lnd unlock script * edit the unlock * remove debug echo * add debug * add debug * fix if statement * debug output * switch position of source setupdata * #1126 preparing new setup with new c-lightning (#2396) * move debug script * patch patch command * make sure setup file is sourced * remove debug output * make sure lnd is put behind tor * change indent * get fresh sync progress * always set password A * cached peer info * fix printing cache * fix check for existing files * handle bitcoind not running * result with newline * test line break * test new line * test new line * two vars on output * #2388 improve online check (less pinging) * used cached peer status * move chache * cach file permissions * allow sudo call * fix cache * remove double scan info * add conf info to sync screen * reorder info * add space * add space * order info * internet suppress error messages * order info * fix offering Blockchain copy * fix hostname * final ready state info * lnd unlock after provision * remove debug exit * harmonize ready state * add status to lnd unlock * update lnd unlock script * edit the unlock * remove debug echo * add debug * add debug * fix if statement * debug output * switch position of source setupdata * lnd.unlock: fix typo * netwok.monitor.sh debug * cln-plugin.summary: fix paths * rtl: fix permission of config on copy * CASHOUT: use aliases for lnd * rtl: install correctly for paralell chains * use CHAIN in CLN and LND menu * cln: add CASHOUT option * CLOSEALL and CASHOUT: Improve labels and comments Explaining CASHOUT in the label as discussed in: https://github.com/rootzoll/raspiblitz/issues/2358 * cln.install: fix tor config * cln: installthe latest master until the next release * _commands: source _aliases only if exists * network aliases: fall back to 'main' for 'chain' * new setup: keep testnet3 blocks and chainstate * new setup: improve capitalization in menu * improve help and comments * cln: install Sparko if configured, but not present * cln: add new wallet and import seed options * fix peernum * make sure that aliases get created on lnd setup * no error if aliases not yet exist * debug state * fix network alias when not set * fix syntax error * add debug error info * mute unlocking echos * add debug wait * add debug wait * make sure info is uptodate * make alias info as defaults * rename option * update sync info for no lightning * add action string * update sync info * move name dialog * wait for sync progress info * wait for syncprogress info * fix syntax * get fresh data * make sure to disable lnd * add c-lightning to debug * add setup logs to debug output * fix syntax error * add new-force wallet * try fix call hsmtool * hsm output tool * fix output * add seed-force * refactor blitz.mnemonic.py * test seed * debug info * dump object * try check * correct putput * fix syntax * check lnd for valid seed * fix gui * add Suez install script discussed in: https://github.com/rootzoll/raspiblitz/issues/2366 * cln rescue file export * get correct version * add cln export gui * cln.backup.sh cln-import * correct bytesize * generate cln wallet with passwordc * fix syntax * fix syntax * mute not needed error msg * PEERING: correct message on success * cln.install-service: fix sparko check * add Suez to menu for CLN and LND needs to be installed with the bitcoin user to be able to interact with CLN related: https://github.com/rootzoll/raspiblitz/issues/2366 * debug _provison.setup.sh stop bitcoind and restart with new config to avoid rpc password error disable and enable service instead of daemon-reload CLN: don't use passwordC as seedPassword * add cln.setname.sh make lnd.setname.sh work with parallel wallets * improve comments * SYSTEM: add CLNLOG and CLNCONF options * SYSTEM menu fixes * cln: add more aliases cln, clnlog, clnconf * cln: activate the backup plugin on every install * SERVICES menu: fix chantools/CLN switch * cln: load plugins from ${netprefix}cln-plugins-enabled changed the config paths to $lightning-dir/config or /networkname/config plugins are downloaded to the SDcard: /home/bitcoin/cln-plugins-available/ symlinked and loaded automatically from: /home/bitcoin/${netprefix}cln-plugins-enabled Related: #2295 * sparko: don't show logs after install * #2425 Adding experimental Blitz WebUI & API (#2426) * no password C & D when cln * add debug echos * set defaults before * #2228 wider grep to detect nvms (#2427) * cln.hsmtool: init backup with the new wallet * cln.install: fix access to raspiblitz.conf * cln-plugin.backup: fix path to backup-cli * cln: hide unhelpful warnings during setup * remove old jinja template rendering * fix lnd unlock detection * cln: look for files in .lightning dir with sudo * cln: correct lightning name in FInalDialog + typo * cln: make sure .lightning/bitcoin dir exists * FinalDialog: make the 24 words fit * cln.install.sh: create cln config if not present * Simplify localIP detection and improve compatibility (#2432) * show tail info on provision * only show lnd options when activated * fix syntax * only show main lightning impl options for RC1 * cln: always start the lightnind.service * cln: clear before showing summary * start cln on the end of provisioning * exit 0 on cln menu * press key after single actions * remove key press on cln actions * change to none * detect cln running * fix syntax * fix lightniing info * add TODO for CLN * add clnblockheight * zty with user bitcoin * check synced to chain for cln * fix increment * try scanprogress * use cln sync detection and progress * replace LNTYPE * next line * fix spaces * fix spaces * Update README.md (#2456) Fix 404 * Fix FAQ links (#2441) * Fix invalid URL ( (#2440) * support channels (#2382) * use #2370 height optimization * adjust exit codes in menu scripts * adjust password menu exit codes * adapt shutdown for cln * settings adapt to running lightning impl * fix syntax * debug info * add debug * better height * add default values * add config entry if not there yet * change default value * Added exit info for cln * make sure to load config file if available * add sparko to menu * add default for sparko * replace default sparko entry * show sparko installed or not * add more description to sparko option * RTL for clightnign in service menu * main menu item rtl * add RTL description * debug in RTL install * install sparko on recovery * update menu with cln * rework menu options Co-authored-by: openoms <oms@tuta.io> Co-authored-by: openoms <43343391+openoms@users.noreply.github.com> Co-authored-by: rek79 <rek79@users.noreply.github.com> Co-authored-by: Bitpaint <67663265+bitpaint@users.noreply.github.com> Co-authored-by: João Thallis <joaothallis@icloud.com> Co-authored-by: Peter Flock <78184669+peterflock@users.noreply.github.com> Co-authored-by: nyxnor <nyxnor@protonmail.com>
2021-08-04 00:18:30 +02:00
localip=$(hostname -I | awk '{print $1}')
toraddress=$(sudo cat /mnt/hdd/tor/specter/hostname 2>/dev/null)
fingerprint=$(openssl x509 -in /home/specter/.specter/cert.pem -fingerprint -noout | cut -d"=" -f2)
2022-05-05 10:59:50 +02:00
echo "localIP='${localip}'"
echo "httpPort=''"
echo "httpsPort='25441'"
echo "httpsForced='1'"
echo "httpsSelfsigned='1'"
2020-10-08 20:52:37 +02:00
echo "toraddress='${toraddress}'"
echo "fingerprint='${fingerprint}'"
# check for error
serviceFailed=$(sudo systemctl status specter | grep -c 'inactive (dead)')
2020-10-08 20:52:37 +02:00
if [ "${serviceFailed}" = "1" ]; then
echo "error='Service Failed'"
exit 1
fi
else
echo "configured=0"
2022-05-05 10:59:50 +02:00
echo "installed=0"
2020-10-08 20:52:37 +02:00
fi
2020-10-08 20:52:37 +02:00
exit 0
fi
2020-03-16 15:11:39 +01:00
# show info menu
if [ "$1" = "menu" ]; then
# get status
echo "# collecting status info ... (please wait)"
source <(sudo /home/admin/config.scripts/bonus.specter.sh status)
2020-10-08 20:52:37 +02:00
echo "# toraddress: ${toraddress}"
2020-03-16 15:11:39 +01:00
if [ "${runBehindTor}" = "on" ] && [ ${#toraddress} -gt 0 ]; then
# Tor
2022-02-13 12:23:34 +00:00
sudo /home/admin/config.scripts/blitz.display.sh qr "${toraddress}"
whiptail --title " Specter Desktop " --msgbox "Open in your local web browser & accept self-signed cert:
2022-05-05 10:59:50 +02:00
https://${localIP}:25441
2020-06-29 17:31:12 +02:00
SHA1 Thumb/Fingerprint:
${fingerprint}
2020-03-16 15:11:39 +01:00
Login with the Pin being Password B. If you have connected to a different Bitcoin RPC Endpoint, the Pin is the configured RPCPassword.
2020-03-16 15:11:39 +01:00
Hidden Service address for TOR Browser (QR see LCD):
2020-10-08 20:52:37 +02:00
https://${toraddress}
Unfortunately the camera is currently not usable via Tor, though.
" 18 74
2022-02-13 12:23:34 +00:00
sudo /home/admin/config.scripts/blitz.display.sh hide
2020-03-16 15:11:39 +01:00
else
# IP + Domain
whiptail --title " Specter Desktop " --msgbox "Open in your local web browser & accept self-signed cert:
2022-05-05 10:59:50 +02:00
https://${localIP}:25441
2020-06-29 17:31:12 +02:00
SHA1 Thumb/Fingerprint:
${fingerprint}
2020-10-08 20:52:37 +02:00
Login with the PIN being Password B. If you have connected to a different Bitcoin RPC Endpoint, the PIN is the configured RPCPassword.\n
2020-03-16 15:11:39 +01:00
Activate TOR to access the web block explorer from outside your local network.
2020-10-08 20:52:37 +02:00
" 15 74
2020-03-16 15:11:39 +01:00
fi
2020-06-06 22:23:50 +02:00
echo "# please wait ..."
2020-03-16 15:11:39 +01:00
exit 0
fi
2020-10-11 19:47:05 +01:00
# blockfilterindex
# add blockfilterindex with default value (0) to bitcoin.conf if missing
if ! grep -Eq "^blockfilterindex=.*" /mnt/hdd/${network}/${network}.conf; then
echo "blockfilterindex=0" | sudo tee -a /mnt/hdd/${network}/${network}.conf >/dev/null
fi
# set variable ${blockfilterindex}
source <(grep -E "^blockfilterindex=.*" /mnt/hdd/${network}/${network}.conf)
function configure_specter {
echo "# --> creating App-config"
if [ "${runBehindTor}" = "on" ];then
proxy="socks5h://localhost:9050"
torOnly="true"
tor_control_port="9051"
else
proxy=""
torOnly="false"
tor_control_port=""
fi
cat > /home/admin/config.json <<EOF
{
"auth": {
"method": "rpcpasswordaspin",
"password_min_chars": 6,
"rate_limit": 10,
"registration_link_timeout": 1
},
"active_node_alias": "raspiblitz_${chain}net",
"proxy_url": "${proxy}",
"only_tor": "${torOnly}",
"tor_control_port": "${tor_control_port}",
"tor_status": true,
"hwi_bridge_url": "/hwi/api/"
}
EOF
sudo mkdir -p /home/specter/.specter/nodes
sudo mv /home/admin/config.json /home/specter/.specter/config.json
sudo chown -RL specter:specter /home/specter/
echo "# Adding the raspiblitz_${chain}net node to Specter"
RPCUSER=$(sudo cat /mnt/hdd/${network}/${network}.conf | grep rpcuser | cut -c 9-)
PASSWORD_B=$(sudo cat /mnt/hdd/${network}/${network}.conf | grep rpcpassword | cut -c 13-)
echo "# Connect Specter to the default mainnet node"
cat > /home/admin/default.json <<EOF
{
"name": "raspiblitz_mainnet",
"alias": "default",
"autodetect": false,
"datadir": "",
"user": "${RPCUSER}",
"password": "${PASSWORD_B}",
"port": "8332",
"host": "localhost",
"protocol": "http",
"external_node": true,
"fullpath": "/home/specter/.specter/nodes/default.json"
}
EOF
sudo mv /home/admin/default.json /home/specter/.specter/nodes/default.json
sudo chown -RL specter:specter /home/specter/
if [ "${chain}" != "main" ]; then
if [ "${chain}" = "test" ];then
portprefix=1
elif [ "${chain}" = "sig" ];then
portprefix=3
fi
PORT="${portprefix}8332"
echo "# Connect Specter to the raspiblitz_${chain}net node"
cat > /home/admin/raspiblitz_${chain}net.json <<EOF
{
"name": "raspiblitz_${chain}net",
"alias": "raspiblitz_${chain}net",
"autodetect": false,
"datadir": "",
"user": "${RPCUSER}",
"password": "${PASSWORD_B}",
"port": "${PORT}",
"host": "localhost",
"protocol": "http",
"external_node": true,
"fullpath": "/home/specter/.specter/nodes/raspiblitz_${chain}net.json"
}
EOF
sudo mv /home/admin/raspiblitz_${chain}net.json /home/specter/.specter/nodes/raspiblitz_${chain}net.json
sudo chown -RL specter:specter /home/specter/
fi
}
# config
if [ "$1" = "config" ]; then
configure_specter
echo "# Restarting Specter - reload it's page to log in with the new settings"
sudo systemctl restart specter
exit 0
fi
2020-03-16 15:11:39 +01:00
# switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "# --> INSTALL Specter Desktop"
2020-03-16 15:11:39 +01:00
isInstalled=$(sudo ls /etc/systemd/system/specter.service 2>/dev/null | grep -c 'specter.service' || /bin/true)
2020-03-16 15:11:39 +01:00
if [ ${isInstalled} -eq 0 ]; then
2020-06-06 22:23:50 +02:00
echo "# --> Enable wallets in Bitcoin Core"
/home/admin/config.scripts/network.wallet.sh on
2020-03-16 15:11:39 +01:00
2020-06-06 22:23:50 +02:00
echo "# --> Installing prerequisites"
sudo apt update
sudo apt-get install -y virtualenv libffi-dev libusb-1.0.0-dev libudev-dev
2020-03-16 15:11:39 +01:00
sudo adduser --disabled-password --gecos "" specter
2022-05-05 10:59:50 +02:00
if [ "$(ls /home | grep -c "specter")" == "0" ]; then
echo "error='was not able to create user specter'"
exit 1
fi
echo "# add the user to the debian-tor group"
sudo usermod -a -G debian-tor specter
# store data on the disk
sudo mkdir -p /mnt/hdd/app-data/.specter 2>/dev/null
# move old Specter data to app-data (except .env)
sudo mv -f /home/bitcoin/.specter/* /mnt/hdd/app-data/.specter/ 2>/dev/null
sudo rm -rf /home/bitcoin/.specter 2>/dev/null
# symlink to specter user
sudo chown -R specter:specter /mnt/hdd/app-data/.specter
sudo ln -s /mnt/hdd/app-data/.specter /home/specter/ 2>/dev/null
sudo chown -R specter:specter /home/specter/.specter
2020-06-06 22:23:50 +02:00
echo "# --> creating a virtualenv"
sudo -u specter virtualenv --python=python3 /home/specter/.env
2020-03-16 15:11:39 +01:00
2020-06-06 22:23:50 +02:00
echo "# --> pip-installing specter"
sudo -u specter /home/specter/.env/bin/python3 -m pip install --upgrade cryptoadvance.specter==$pinnedVersion || exit 1
# activating Authentication here ...
configure_specter
2020-03-16 15:11:39 +01:00
# Mandatory as the camera doesn't work without https
2020-06-06 22:23:50 +02:00
echo "# --> Creating self-signed certificate"
2020-06-29 19:45:13 +02:00
openssl req -x509 -newkey rsa:4096 -nodes -out /tmp/cert.pem -keyout /tmp/key.pem -days 365 -subj "/C=US/ST=Nooneknows/L=Springfield/O=Dis/CN=www.fakeurl.com"
sudo mv /tmp/cert.pem /home/specter/.specter
sudo chown -R specter:specter /home/specter/.specter/cert.pem
sudo mv /tmp/key.pem /home/specter/.specter
sudo chown -R specter:specter /home/specter/.specter/key.pem
2020-03-16 15:11:39 +01:00
# open firewall
2020-06-06 22:23:50 +02:00
echo "# --> Updating Firewall"
sudo ufw allow 25441 comment 'specter'
2020-06-06 22:17:16 +02:00
sudo ufw --force enable
echo
2020-03-16 15:11:39 +01:00
2020-06-06 22:23:50 +02:00
echo "# --> Installing udev-rules for hardware-wallets"
2020-09-20 19:07:38 +01:00
# Ledger
2020-03-16 15:11:39 +01:00
cat > /home/admin/20-hw1.rules <<EOF
HW.1 / Nano
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2581", ATTRS{idProduct}=="1b7c|2b7c|3b7c|4b7c", TAG+="uaccess", TAG+="udev-acl", OWNER="specter"
2020-03-16 15:11:39 +01:00
# Blue
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0000|0000|0001|0002|0003|0004|0005|0006|0007|0008|0009|000a|000b|000c|000d|000e|000f|0010|0011|0012|0013|0014|0015|0016|0017|0018|0019|001a|001b|001c|001d|001e|001f", TAG+="uaccess", TAG+="udev-acl", OWNER="specter"
2020-03-16 15:11:39 +01:00
# Nano S
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0001|1000|1001|1002|1003|1004|1005|1006|1007|1008|1009|100a|100b|100c|100d|100e|100f|1010|1011|1012|1013|1014|1015|1016|1017|1018|1019|101a|101b|101c|101d|101e|101f", TAG+="uaccess", TAG+="udev-acl", OWNER="specter"
2020-03-16 15:11:39 +01:00
# Aramis
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0002|2000|2001|2002|2003|2004|2005|2006|2007|2008|2009|200a|200b|200c|200d|200e|200f|2010|2011|2012|2013|2014|2015|2016|2017|2018|2019|201a|201b|201c|201d|201e|201f", TAG+="uaccess", TAG+="udev-acl", OWNER="specter"
2020-03-16 15:11:39 +01:00
# HW2
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0003|3000|3001|3002|3003|3004|3005|3006|3007|3008|3009|300a|300b|300c|300d|300e|300f|3010|3011|3012|3013|3014|3015|3016|3017|3018|3019|301a|301b|301c|301d|301e|301f", TAG+="uaccess", TAG+="udev-acl", OWNER="specter"
2020-03-16 15:11:39 +01:00
# Nano X
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0004|4000|4001|4002|4003|4004|4005|4006|4007|4008|4009|400a|400b|400c|400d|400e|400f|4010|4011|4012|4013|4014|4015|4016|4017|4018|4019|401a|401b|401c|401d|401e|401f", TAG+="uaccess", TAG+="udev-acl", OWNER="specter"
2020-03-16 15:11:39 +01:00
EOF
2020-09-20 19:07:38 +01:00
# ColdCard
2020-03-16 15:11:39 +01:00
cat > /home/admin/51-coinkite.rules <<EOF
# Linux udev support file.
#
# This is a example udev file for HIDAPI devices which changes the permissions
# to 0666 (world readable/writable) for a specific device on Linux systems.
#
# - Copy this file into /etc/udev/rules.d and unplug and re-plug your Coldcard.
# - Udev does not have to be restarted.
#
# probably not needed:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="d13e", ATTRS{idProduct}=="cc10", GROUP="plugdev", MODE="0666"
# required:
# from <https://github.com/signal11/hidapi/blob/master/udev/99-hid.rules>
KERNEL=="hidraw*", ATTRS{idVendor}=="d13e", ATTRS{idProduct}=="cc10", GROUP="plugdev", MODE="0666"
EOF
2020-09-20 19:07:38 +01:00
# Trezor
2020-03-16 15:11:39 +01:00
cat > /home/admin/51-trezor.rules <<EOF
# Trezor: The Original Hardware Wallet
# https://trezor.io/
#
# Put this file into /etc/udev/rules.d
#
# If you are creating a distribution package,
# put this into /usr/lib/udev/rules.d or /lib/udev/rules.d
# depending on your distribution
# Trezor
SUBSYSTEM=="usb", ATTR{idVendor}=="534c", ATTR{idProduct}=="0001", MODE="0660", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl", SYMLINK+="trezor%n"
KERNEL=="hidraw*", ATTRS{idVendor}=="534c", ATTRS{idProduct}=="0001", MODE="0660", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl"
# Trezor v2
SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="53c0", MODE="0660", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl", SYMLINK+="trezor%n"
SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="53c1", MODE="0660", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl", SYMLINK+="trezor%n"
KERNEL=="hidraw*", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="53c1", MODE="0660", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl"
EOF
2020-09-20 19:07:38 +01:00
# KeepKey
2020-03-16 15:11:39 +01:00
cat > /home/admin/51-usb-keepkey.rules <<EOF
# KeepKey: Your Private Bitcoin Vault
# http://www.keepkey.com/
# Put this file into /usr/lib/udev/rules.d or /etc/udev/rules.d
# KeepKey HID Firmware/Bootloader
SUBSYSTEM=="usb", ATTR{idVendor}=="2b24", ATTR{idProduct}=="0001", MODE="0666", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl", SYMLINK+="keepkey%n"
KERNEL=="hidraw*", ATTRS{idVendor}=="2b24", ATTRS{idProduct}=="0001", MODE="0666", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl"
# KeepKey WebUSB Firmware/Bootloader
SUBSYSTEM=="usb", ATTR{idVendor}=="2b24", ATTR{idProduct}=="0002", MODE="0666", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl", SYMLINK+="keepkey%n"
KERNEL=="hidraw*", ATTRS{idVendor}=="2b24", ATTRS{idProduct}=="0002", MODE="0666", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl"
EOF
sudo mv /home/admin/20-hw1.rules /home/admin/51-coinkite.rules /home/admin/51-trezor.rules /home/admin/51-usb-keepkey.rules /etc/udev/rules.d/
sudo chown root:root /etc/udev/rules.d/*
sudo udevadm trigger
sudo udevadm control --reload-rules
2020-06-06 22:17:16 +02:00
sudo groupadd plugdev || /bin/true
2020-03-16 15:11:39 +01:00
sudo usermod -aG plugdev bitcoin
sudo usermod -aG plugdev specter
2020-03-16 15:11:39 +01:00
# install service
echo "# --> Install specter systemd service"
cat > /home/admin/specter.service <<EOF
# systemd unit for Specter Desktop
2020-03-16 15:11:39 +01:00
[Unit]
Description=specter
2020-03-16 15:11:39 +01:00
Wants=${network}d.service
After=${network}d.service
[Service]
ExecStart=/home/specter/.env/bin/python3 -m cryptoadvance.specter server --host 0.0.0.0 --cert=/home/specter/.specter/cert.pem --key=/home/specter/.specter/key.pem
User=specter
Environment=PATH=/home/specter/.specter.env/bin:/home/specter/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin:/bin
2020-03-16 15:11:39 +01:00
Restart=always
TimeoutSec=120
RestartSec=30
StandardOutput=null
StandardError=journal
merging pre-1.7.1 (#2462) * fix copychain returns * typo in sync loop * stop services on inconsistent state * calling correct provisioning * apply bitcoin and lncli aliases in all scripts * network.aliases: add CLNETWORK * make cln default plugin dir: cln-plugins-enabled similar to the nginx model make 2 directories for plugins: cln-plugins-enabled - symlinked to ~/.lightning/plugins plugins from here are loaded automatically on cln start cln-plugins-available: plugins are downloaded here to be run until the next cln restart (or stopped with runonce) note the disk is mounted with noexec so plugins can't run from there discuss in: https://github.com/rootzoll/raspiblitz/issues/2295 * move shutdown script * change all place where shutdown script is used * change notify & release * moved shutdown script * moved shutdown scripts * add more debug info * moving github script * remove chain in sync * no longer needed chain in sync * move debug script * patch patch command * make sure setup file is sourced * remove debug output * make sure lnd is put behind tor * change indent * get fresh sync progress * avoid scrolling in menus * use new selfsignedcert if no lnd tls.cert present * sparko: add info and connect menu with own cert https://github.com/rootzoll/raspiblitz/issues/2295 * cln.rest: add connect option for Zeus https://github.com/rootzoll/raspiblitz/issues/2295 * cln: add the backup plugin + options Usage options: cln-plugin.backup.sh [on] [testnet|mainnet|signet] cln-plugin.backup.sh [restore] [testnet|mainnet|signet] [force] cln-plugin.backup.sh [backup-compact] [testnet|mainnet|signet] https://github.com/lightningd/plugins/tree/master/backup Discussed in: https://github.com/rootzoll/raspiblitz/issues/2295 * cln: add cln-plugin.standard.python.sh Install and show the output of the chosen plugin for C-lightning Usage: cln-plugin.standard-python.sh on [plugin-name] [testnet|mainnet|signet] [runonce] tested plugins: summary | helpme | feeadjuster find more at: https://github.com/lightningd/plugins discussed in: https://github.com/rootzoll/raspiblitz/issues/2295 * shellcheck: change all `egrep` to `grep -E` https://github.com/koalaman/shellcheck/wiki/SC2196 * do not resolve aliases, use as variables * lnd: fix lnd.conf for parallel networks discussed in: https://github.com/rootzoll/raspiblitz/issues/2290 * lnd: add LND option for parallel networks * deprecate Testnet in SETTINGS keysend and autopilot only for mainnet due to: https://github.com/rootzoll/raspiblitz/issues/2290 * lnd: autopilot and autounlock for testnet * fix comments * add the SYSTEM menu for parallel chains * RTL update to v0.11.0 make chain specific directory for the config: /home/rtl/${netprefix}RTL/ use ${netprefix}lnd.conf in config override Environmen tvaribales for cln in the systemd service: /etc/systemd/system/${netprefix}${typeprefix}RTL.service discussed in: https://github.com/rootzoll/raspiblitz/issues/2384 * lnd.setname.sh for testnet * display ${CHAIN} in the SYSTEM menu options * keep _aliases file when live patches are applied * all lncli_aliases to be used as variables * default to KIllMode=control-group in services https://www.man7.org/linux/man-pages/man5/systemd.kill.5.html discussed in: https://github.com/rootzoll/raspiblitz/issues/1901 * add cln.hsmtool.sh for hsm_secret handling encrypt | decrypt | autounlock the hsm_secret for C-lightning usage: cln.hsmtool.sh [unlock] [testnet|mainnet|signet] cln.hsmtool.sh [encrypt|decrypt] [testnet|mainnet|signet] cln.hsmtool.sh [autounlock-on|autounlock-off] [testnet|mainnet|signet] discussed in: https://github.com/rootzoll/raspiblitz/issues/2295 * add cln.install-service.sh to set up cln with systemd script to set up or update the CLN systemd service checks for hsm_secret encryption, autounlock and the sparko plugin usage: /home/admin/config.scripts/cln.install-service.sh $CHAIN discussed in: https://github.com/rootzoll/raspiblitz/issues/2295 * use symlink to cln-plugins-enabled for all plugins * keep lnd autopilot and autounlock mainnet only mainnet only settings: lnd autopilot lnd keysend circuibreaker lnd autounlock StaticChannelBackup to DropBox and USB * cln FUNDING fix parsing address * cln.hsmtool: add change-password and lock options * always set password A * cached peer info * fix printing cache * fix check for existing files * handle bitcoind not running * result with newline * test line break * test new line * test new line * two vars on output * #2388 improve online check (less pinging) * used cached peer status * move chache * cach file permissions * allow sudo call * fix cache * remove double scan info * add conf info to sync screen * reorder info * add space * add space * order info * internet suppress error messages * order info * fix offering Blockchain copy * fix hostname * final ready state info * lnd unlock after provision * remove debug exit * harmonize ready state * add status to lnd unlock * update lnd unlock script * edit the unlock * remove debug echo * add debug * add debug * fix if statement * debug output * switch position of source setupdata * #1126 preparing new setup with new c-lightning (#2396) * move debug script * patch patch command * make sure setup file is sourced * remove debug output * make sure lnd is put behind tor * change indent * get fresh sync progress * always set password A * cached peer info * fix printing cache * fix check for existing files * handle bitcoind not running * result with newline * test line break * test new line * test new line * two vars on output * #2388 improve online check (less pinging) * used cached peer status * move chache * cach file permissions * allow sudo call * fix cache * remove double scan info * add conf info to sync screen * reorder info * add space * add space * order info * internet suppress error messages * order info * fix offering Blockchain copy * fix hostname * final ready state info * lnd unlock after provision * remove debug exit * harmonize ready state * add status to lnd unlock * update lnd unlock script * edit the unlock * remove debug echo * add debug * add debug * fix if statement * debug output * switch position of source setupdata * lnd.unlock: fix typo * netwok.monitor.sh debug * cln-plugin.summary: fix paths * rtl: fix permission of config on copy * CASHOUT: use aliases for lnd * rtl: install correctly for paralell chains * use CHAIN in CLN and LND menu * cln: add CASHOUT option * CLOSEALL and CASHOUT: Improve labels and comments Explaining CASHOUT in the label as discussed in: https://github.com/rootzoll/raspiblitz/issues/2358 * cln.install: fix tor config * cln: installthe latest master until the next release * _commands: source _aliases only if exists * network aliases: fall back to 'main' for 'chain' * new setup: keep testnet3 blocks and chainstate * new setup: improve capitalization in menu * improve help and comments * cln: install Sparko if configured, but not present * cln: add new wallet and import seed options * fix peernum * make sure that aliases get created on lnd setup * no error if aliases not yet exist * debug state * fix network alias when not set * fix syntax error * add debug error info * mute unlocking echos * add debug wait * add debug wait * make sure info is uptodate * make alias info as defaults * rename option * update sync info for no lightning * add action string * update sync info * move name dialog * wait for sync progress info * wait for syncprogress info * fix syntax * get fresh data * make sure to disable lnd * add c-lightning to debug * add setup logs to debug output * fix syntax error * add new-force wallet * try fix call hsmtool * hsm output tool * fix output * add seed-force * refactor blitz.mnemonic.py * test seed * debug info * dump object * try check * correct putput * fix syntax * check lnd for valid seed * fix gui * add Suez install script discussed in: https://github.com/rootzoll/raspiblitz/issues/2366 * cln rescue file export * get correct version * add cln export gui * cln.backup.sh cln-import * correct bytesize * generate cln wallet with passwordc * fix syntax * fix syntax * mute not needed error msg * PEERING: correct message on success * cln.install-service: fix sparko check * add Suez to menu for CLN and LND needs to be installed with the bitcoin user to be able to interact with CLN related: https://github.com/rootzoll/raspiblitz/issues/2366 * debug _provison.setup.sh stop bitcoind and restart with new config to avoid rpc password error disable and enable service instead of daemon-reload CLN: don't use passwordC as seedPassword * add cln.setname.sh make lnd.setname.sh work with parallel wallets * improve comments * SYSTEM: add CLNLOG and CLNCONF options * SYSTEM menu fixes * cln: add more aliases cln, clnlog, clnconf * cln: activate the backup plugin on every install * SERVICES menu: fix chantools/CLN switch * cln: load plugins from ${netprefix}cln-plugins-enabled changed the config paths to $lightning-dir/config or /networkname/config plugins are downloaded to the SDcard: /home/bitcoin/cln-plugins-available/ symlinked and loaded automatically from: /home/bitcoin/${netprefix}cln-plugins-enabled Related: #2295 * sparko: don't show logs after install * #2425 Adding experimental Blitz WebUI & API (#2426) * no password C & D when cln * add debug echos * set defaults before * #2228 wider grep to detect nvms (#2427) * cln.hsmtool: init backup with the new wallet * cln.install: fix access to raspiblitz.conf * cln-plugin.backup: fix path to backup-cli * cln: hide unhelpful warnings during setup * remove old jinja template rendering * fix lnd unlock detection * cln: look for files in .lightning dir with sudo * cln: correct lightning name in FInalDialog + typo * cln: make sure .lightning/bitcoin dir exists * FinalDialog: make the 24 words fit * cln.install.sh: create cln config if not present * Simplify localIP detection and improve compatibility (#2432) * show tail info on provision * only show lnd options when activated * fix syntax * only show main lightning impl options for RC1 * cln: always start the lightnind.service * cln: clear before showing summary * start cln on the end of provisioning * exit 0 on cln menu * press key after single actions * remove key press on cln actions * change to none * detect cln running * fix syntax * fix lightniing info * add TODO for CLN * add clnblockheight * zty with user bitcoin * check synced to chain for cln * fix increment * try scanprogress * use cln sync detection and progress * replace LNTYPE * next line * fix spaces * fix spaces * Update README.md (#2456) Fix 404 * Fix FAQ links (#2441) * Fix invalid URL ( (#2440) * support channels (#2382) * use #2370 height optimization * adjust exit codes in menu scripts * adjust password menu exit codes * adapt shutdown for cln * settings adapt to running lightning impl * fix syntax * debug info * add debug * better height * add default values * add config entry if not there yet * change default value * Added exit info for cln * make sure to load config file if available * add sparko to menu * add default for sparko * replace default sparko entry * show sparko installed or not * add more description to sparko option * RTL for clightnign in service menu * main menu item rtl * add RTL description * debug in RTL install * install sparko on recovery * update menu with cln * rework menu options Co-authored-by: openoms <oms@tuta.io> Co-authored-by: openoms <43343391+openoms@users.noreply.github.com> Co-authored-by: rek79 <rek79@users.noreply.github.com> Co-authored-by: Bitpaint <67663265+bitpaint@users.noreply.github.com> Co-authored-by: João Thallis <joaothallis@icloud.com> Co-authored-by: Peter Flock <78184669+peterflock@users.noreply.github.com> Co-authored-by: nyxnor <nyxnor@protonmail.com>
2021-08-04 00:18:30 +02:00
# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
2020-03-16 15:11:39 +01:00
[Install]
WantedBy=multi-user.target
EOF
sudo mv /home/admin/specter.service /etc/systemd/system/specter.service
sudo systemctl enable specter
2020-03-16 15:11:39 +01:00
echo "# --> OK - the specter service is now enabled and started"
else
echo "# --> specter already installed."
2020-03-16 15:11:39 +01:00
fi
# setting value in raspi blitz config
/home/admin/config.scripts/blitz.conf.sh set specter "on"
2020-03-16 15:11:39 +01:00
2020-06-06 22:17:16 +02:00
# Hidden Service for SERVICE if Tor is active
2020-03-16 15:11:39 +01:00
if [ "${runBehindTor}" = "on" ]; then
# make sure to keep in sync with tor.network.sh script
2020-07-18 15:26:56 +02:00
# port 25441 is HTTPS with self-signed cert - specte only makes sense to be served over HTTPS
/home/admin/config.scripts/tor.onion-service.sh specter 443 25441
2020-03-16 15:11:39 +01:00
fi
2020-10-11 19:47:05 +01:00
# blockfilterindex on
# check txindex (parsed and sourced from bitcoin network config above)
if [ "${blockfilterindex}" = "0" ]; then
2020-10-11 19:47:05 +01:00
sudo sed -i "s/^blockfilterindex=.*/blockfilterindex=1/g" /mnt/hdd/${network}/${network}.conf
echo "# switching blockfilterindex=1"
isBitcoinRunning=$(systemctl is-active ${network}d | grep -c "^active")
if [ ${isBitcoinRunning} -eq 1 ]; then
echo "# ${network}d is running - so restarting"
sudo systemctl restart ${network}d
else
echo "# ${network}d is not running - so NOT restarting"
fi
echo "# The indexing takes ~10h on an RPi4 with SSD"
echo "# check with: sudo cat /mnt/hdd/bitcoin/debug.log | grep filter"
2020-10-11 19:47:05 +01:00
else
echo "# blockfilterindex is already active"
2020-10-11 19:47:05 +01:00
fi
2022-05-05 10:59:50 +02:00
# needed for API/WebUI as signal that install ran thru
echo "result='OK'"
2020-03-16 15:11:39 +01:00
exit 0
fi
# switch off
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspi blitz config
/home/admin/config.scripts/blitz.conf.sh set specter "off"
2020-03-16 15:11:39 +01:00
# Hidden Service if Tor is active
if [ "${runBehindTor}" = "on" ]; then
2022-05-05 10:59:50 +02:00
echo "# Removing Tor hidden service for specter ..."
/home/admin/config.scripts/tor.onion-service.sh off specter
fi
isInstalled=$(sudo ls /etc/systemd/system/specter.service 2>/dev/null | grep -c 'specter.service')
2022-05-05 10:59:50 +02:00
if [ ${isInstalled} -eq 0 ]; then
echo "error='was not installed'"
exit 1
fi
2020-03-16 15:11:39 +01:00
2022-05-05 10:59:50 +02:00
# removing base systemd service & code
echo "# --> REMOVING Specter Desktop"
sudo systemctl stop specter
sudo systemctl disable specter
sudo rm /etc/systemd/system/specter.service
sudo -u specter /home/specter/.env/bin/python3 -m pip uninstall --yes cryptoadvance.specter 1>&2
# get delete data status - either by parameter or if not set by user dialog
deleteData=""
if [ "$2" == "--delete-data" ]; then
deleteData="1"
fi
if [ "$2" == "--keep-data" ]; then
deleteData="0"
fi
if [ "${deleteData}" == "" ]; then
deleteData=whiptail --defaultno --yesno "Do you want to delete all Data related to specter? This includes also Bitcoin-Core-Wallets managed by specter?" 0 0
fi
# execute on delete data
if [ "${deleteData}" == "1" ]; 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
echo "# --> Removing the /mnt/hdd/app-data/.specter"
sudo rm -rf /mnt/hdd/app-data/.specter
else
2022-05-05 10:59:50 +02:00
echo "# --> wallets in core are preserved on the disk (if exist)"
echo "# --> /mnt/hdd/app-data/.specter is preserved on the disk"
2020-03-16 15:11:39 +01:00
fi
2022-05-05 10:59:50 +02:00
echo "# --> Removing the specter user and home directory"
sudo userdel -rf specter
echo "# --> OK Specter Desktop removed."
# needed for API/WebUI as signal that install ran thru
echo "result='OK'"
2020-03-16 15:11:39 +01:00
exit 0
fi
2020-09-02 10:11:50 +01:00
# update
if [ "$1" = "update" ]; then
echo "# --> UPDATING Specter Desktop "
sudo -u specter /home/specter/.env/bin/python3 -m pip install --upgrade cryptoadvance.specter
2020-09-02 10:11:50 +01:00
echo "# --> Updated to the latest in https://pypi.org/project/cryptoadvance.specter/#history ***"
echo "# --> Restarting the specter.service"
sudo systemctl restart specter
2020-09-02 10:11:50 +01:00
exit 0
fi
2020-06-06 22:23:50 +02:00
echo "error='unknown parameter'"
2020-03-16 15:11:39 +01:00
exit 1