raspiblitz/home.admin/config.scripts/internet.tor.sh

508 lines
16 KiB
Bash
Raw Normal View History

2018-12-02 19:52:01 +01:00
#!/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
# INFO
# --------------------
# basic install of Tor is done by the build script now .. on/off will just switch service on/off
# also thats where the sources are set and the preparation is done
2018-12-02 19:52:01 +01:00
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
2021-03-23 11:17:51 +00:00
echo "script to switch Tor on or off"
echo "internet.tor.sh [status|on|off|btcconf-on|btcconf-off|lndconf-on|update]"
2019-08-08 17:41:58 +02:00
exit 1
fi
torrc="/etc/tor/torrc"
2019-06-13 00:58:52 +02:00
activateBitcoinOverTOR()
{
echo "*** Changing ${network} Config ***"
btcExists=$(sudo ls /home/bitcoin/.${network}/${network}.conf | grep -c "${network}.conf")
if [ ${btcExists} -gt 0 ]; then
# make sure all is turned off and removed and then activate fresh (so that also old settings get removed)
deactivateBitcoinOverTOR
sudo chmod 777 /home/bitcoin/.${network}/${network}.conf
2021-03-23 11:17:51 +00:00
echo "Adding Tor config to the the ${network}.conf ..."
sudo sed -i "s/^torpassword=.*//g" /home/bitcoin/.${network}/${network}.conf
echo "onlynet=onion" >> /home/bitcoin/.${network}/${network}.conf
echo "proxy=127.0.0.1:9050" >> /home/bitcoin/.${network}/${network}.conf
echo "main.bind=127.0.0.1" >> /home/bitcoin/.${network}/${network}.conf
echo "test.bind=127.0.0.1" >> /home/bitcoin/.${network}/${network}.conf
echo "dnsseed=0" >> /home/bitcoin/.${network}/${network}.conf
echo "dns=0" >> /home/bitcoin/.${network}/${network}.conf
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
2021-03-23 11:17:51 +00:00
# remove empty lines
sudo sed -i '/^ *$/d' /home/bitcoin/.${network}/${network}.conf
2021-08-26 23:56:07 +02:00
sudo chmod 664 /home/bitcoin/.${network}/${network}.conf
# copy new bitcoin.conf to admin user for cli access
sudo cp /home/bitcoin/.${network}/${network}.conf /home/admin/.${network}/${network}.conf
sudo chown admin:admin /home/admin/.${network}/${network}.conf
2019-06-13 00:58:52 +02:00
else
2019-08-08 17:41:58 +02:00
echo "BTC config does not found (yet) - try with 'internet.tor.sh btcconf-on' again later"
2019-06-13 00:58:52 +02:00
fi
}
2019-08-08 17:41:58 +02:00
deactivateBitcoinOverTOR()
{
# always make sure also to remove old settings
2019-08-08 17:41:58 +02:00
sudo sed -i "s/^onlynet=.*//g" /home/bitcoin/.${network}/${network}.conf
sudo sed -i "s/^main.addnode=.*//g" /home/bitcoin/.${network}/${network}.conf
sudo sed -i "s/^test.addnode=.*//g" /home/bitcoin/.${network}/${network}.conf
2019-11-23 17:19:09 +01:00
sudo sed -i "s/^proxy=.*//g" /home/bitcoin/.${network}/${network}.conf
sudo sed -i "s/^main.bind=.*//g" /home/bitcoin/.${network}/${network}.conf
sudo sed -i "s/^test.bind=.*//g" /home/bitcoin/.${network}/${network}.conf
2019-11-23 17:19:09 +01:00
sudo sed -i "s/^dnsseed=.*//g" /home/bitcoin/.${network}/${network}.conf
sudo sed -i "s/^dns=.*//g" /home/bitcoin/.${network}/${network}.conf
2021-03-23 11:17:51 +00:00
# remove empty lines
2019-08-08 17:41:58 +02:00
sudo sed -i '/^ *$/d' /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
}
2019-06-13 00:58:52 +02:00
activateLndOverTOR()
{
2021-03-23 11:17:51 +00:00
echo "*** Putting LND behind Tor ***"
2019-06-13 00:58:52 +02:00
lndExists=$(sudo ls /etc/systemd/system/lnd.service | grep -c "lnd.service")
if [ ${lndExists} -gt 0 ]; then
2021-03-23 11:17:51 +00:00
# deprecate 'torpassword='
sudo sed -i '/\[Tor\]*/d' /mnt/hdd/lnd/lnd.conf
sudo sed -i '/^tor.password=*/d' /mnt/hdd/lnd/lnd.conf
# lnd-tor instance
# https://www.torservers.net/wiki/setup/server#multiple_tor_processes
NODENAME="lnd"
SOCKSPORT=9070
CONTROLPORT=$((SOCKSPORT+1))
echo "# Creating a dedicated Tor instance for $NODENAME"
sudo tor-instance-create $NODENAME
echo "# Make sure the user bitcoin is in the _tor-$NODENAME group"
sudo usermod -a -G _tor-$NODENAME bitcoin
# create tor data directory if it not exist
if [ ! -d "/mnt/hdd/tor-$NODENAME" ]; then
echo "# - creating tor data directory"
sudo mkdir -p /mnt/hdd/tor-$NODENAME
sudo mkdir -p /mnt/hdd/tor-$NODENAME/sys
else
echo "# - /mnt/hdd/tor-$NODENAME data directory exists"
fi
# make sure its the correct owner
sudo chmod -R 700 /mnt/hdd/tor-$NODENAME
sudo chown -R _tor-$NODENAME:_tor-$NODENAME /mnt/hdd/tor-$NODENAME
echo "
### torrc for tor@$NODENAME
### https://github.com/lightningnetwork/lnd/blob/master/docs/configuring_tor.md
DataDirectory /mnt/hdd/tor-$NODENAME/sys
PidFile /mnt/hdd/tor-$NODENAME/sys/tor.pid
SocksPort $SOCKSPORT
ControlPort $CONTROLPORT
CookieAuthentication 1
CookieAuthFileGroupReadable 1
SafeLogging 1
Log notice stdout
Log notice file /mnt/hdd/tor-$NODENAME/notice.log
Log info file /mnt/hdd/tor-$NODENAME/info.log
" | sudo tee /etc/tor/instances/$NODENAME/torrc
sudo chmod 644 /etc/tor/instances/$NODENAME/torrc
sudo mkdir -p /etc/systemd/system/tor@$NODENAME.service.d
sudo tee /etc/systemd/system/tor@$NODENAME.service.d/raspiblitz.conf >/dev/null <<EOF
# DO NOT EDIT! This file is generated by raspiblitz and will be overwritten
[Service]
ReadWriteDirectories=-/mnt/hdd/tor-$NODENAME
[Unit]
After=network.target nss-lookup.target mnt-hdd.mount
EOF
echo "Setup logrotate"
# add logrotate config for modified Tor dir on ext. disk
sudo tee /etc/logrotate.d/raspiblitz-tor-$NODENAME >/dev/null <<EOF
/mnt/hdd/tor-$NODENAME/*log {
daily
rotate 5
compress
delaycompress
missingok
notifempty
create 0640 _tor-$NODENAME _tor-$NODENAME
sharedscripts
postrotate
if invoke-rc.d tor status > /dev/null; then
invoke-rc.d tor reload > /dev/null
fi
endscript
}
EOF
sudo systemctl daemon-reload
sudo systemctl enable tor@$NODENAME
sudo systemctl start tor@$NODENAME
2019-06-13 00:58:52 +02:00
# modify LND service
echo "# Make sure LND is disabled"
2019-06-13 00:58:52 +02:00
sudo systemctl disable lnd 2>/dev/null
echo "# Editing /etc/systemd/system/lnd.service"
sudo sed -i "s/^ExecStart=\/usr\/local\/bin\/lnd.*\
/ExecStart=\/usr\/local\/bin\/lnd --tor\.active --tor\.streamisolation --tor\.v3 --tor\.socks=$SOCKSPORT --tor\.control=$CONTROLPORT --listen=127\.0\.0\.1\:9735 \${lndExtraParameter}/g" \
/etc/systemd/system/lnd.service
2020-09-28 21:26:04 +02:00
echo "# Enable LND again"
2019-06-13 00:58:52 +02:00
sudo systemctl enable lnd
echo "# OK"
echo
2019-06-13 00:58:52 +02:00
else
echo "# LND service not found (yet) - try with 'internet.tor.sh lndconf-on' again later"
2019-06-13 00:58:52 +02:00
fi
}
# check and load raspiblitz config
# to know which network is running
if [ -f "/home/admin/raspiblitz.info" ]; then
source /home/admin/raspiblitz.info
fi
if [ -f "/mnt/hdd/raspiblitz.conf" ]; then
source /mnt/hdd/raspiblitz.conf
fi
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
torRunning=$(sudo systemctl --no-pager status tor@default | grep -c "Active: active")
torFunctional=$(curl --connect-timeout 30 --socks5-hostname "127.0.0.1:9050" https://check.torproject.org 2>/dev/null | grep -c "Congratulations. This browser is configured to use Tor.")
if [ "${torFunctional}" == "" ]; then torFunctional=0; fi
if [ ${torFunctional} -gt 1 ]; then torFunctional=1; fi
# if started with status
if [ "$1" = "status" ]; then
# is Tor activated
if [ "${runBehindTor}" == "on" ]; then
echo "activated=1"
else
echo "activated=0"
fi
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
echo "torRunning=${torRunning}"
echo "torFunctional=${torFunctional}"
echo "config='${torrc}'"
exit 0
fi
# if started with btcconf-on
2019-08-08 17:41:58 +02:00
if [ "$1" = "btcconf-on" ]; then
2019-06-13 00:58:52 +02:00
activateBitcoinOverTOR
exit 0
fi
# if started with btcconf-off
2019-08-08 17:41:58 +02:00
if [ "$1" = "btcconf-off" ]; then
deactivateBitcoinOverTOR
2019-06-13 00:58:52 +02:00
exit 0
fi
# if started with lndconf-on
2019-08-08 17:41:58 +02:00
if [ "$1" = "lndconf-on" ]; then
activateLndOverTOR
exit 0
2018-12-02 19:52:01 +01:00
fi
2018-12-02 21:46:00 +01:00
# add default value to raspi config if needed
2019-08-07 01:49:17 +02:00
checkTorEntry=$(sudo cat /mnt/hdd/raspiblitz.conf | grep -c "runBehindTor")
if [ ${checkTorEntry} -eq 0 ]; then
2018-12-02 21:46:00 +01:00
echo "runBehindTor=off" >> /mnt/hdd/raspiblitz.conf
fi
2018-12-02 19:52:01 +01:00
# location of TOR config
2019-02-05 14:16:23 +00:00
# make sure /etc/tor exists
2019-02-10 16:55:41 +01:00
sudo mkdir /etc/tor 2>/dev/null
2018-12-02 19:52:01 +01:00
2020-11-15 22:16:13 +00:00
if [ "$1" != "update" ]; then
# stop services (if running)
echo "making sure services are not running"
sudo systemctl stop lnd 2>/dev/null
sudo systemctl stop ${network}d 2>/dev/null
sudo systemctl stop tor@default 2>/dev/null
fi
2018-12-02 19:52:01 +01:00
# switch on
2018-12-02 20:43:48 +01:00
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
2021-03-23 11:17:51 +00:00
echo "# switching Tor ON"
2018-12-02 19:52:01 +01:00
# *** CURL TOR PROXY ***
# see https://github.com/rootzoll/raspiblitz/issues/1341
#echo "socks5-hostname localhost:9050" > .curlrc.tmp
#sudo cp ./.curlrc.tmp /root/.curlrc
#sudo chown root:root /home/admin/.curlrc
#sudo cp ./.curlrc.tmp /home/pi/.curlrc
#sudo chown pi:pi /home/pi/.curlrc
#sudo cp ./.curlrc.tmp /home/admin/.curlrc
#sudo chown admin:admin /home/admin/.curlrc
#rm .curlrc.tmp
2020-11-16 16:29:08 +01:00
# make sure the network was set (by sourcing raspiblitz.conf)
if [ ${#network} -eq 0 ]; then
2021-03-23 11:17:51 +00:00
echo "!! FAIL - unknown network due to missing /mnt/hdd/raspiblitz.conf"
echo "# switching Tor config on for RaspiBlitz services is just possible after basic hdd/ssd setup"
echo "# but with new 'Tor by default' basic Tor socks will already be available from the start"
2020-11-16 16:29:08 +01:00
exit 1
fi
2018-12-02 19:52:01 +01:00
# setting value in raspi blitz config
sudo sed -i "s/^runBehindTor=.*/runBehindTor=on/g" /mnt/hdd/raspiblitz.conf
# install package just in case it was deinstalled
packageInstalled=$(dpkg -s tor-arm | grep -c 'Status: install ok')
if [ ${packageInstalled} -eq 0 ]; then
2020-11-23 22:13:55 +01:00
sudo apt install tor tor-arm torsocks -y
fi
# create tor data directory if it not exist
if [ ! -d "/mnt/hdd/tor" ]; then
echo "# - creating tor data directory"
2020-09-28 21:26:04 +02:00
sudo mkdir -p /mnt/hdd/tor
sudo mkdir -p /mnt/hdd/tor/sys
else
echo "# - tor data directory exists"
fi
# make sure its the correct owner
sudo chmod -R 700 /mnt/hdd/tor
sudo chown -R debian-tor:debian-tor /mnt/hdd/tor
# create tor config .. if not exists or is old
isTorConfigOK=$(sudo cat /etc/tor/torrc 2>/dev/null | grep -c "Bitcoin")
if [ ${isTorConfigOK} -eq 0 ]; then
echo "# - updating Tor config ${torrc}"
cat > ./torrc <<EOF
### torrc for tor@default
2018-12-02 19:52:01 +01:00
### 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
ControlPort 9051
SocksPort 9050
2019-01-13 22:03:23 +01:00
ExitRelay 0
2021-03-23 11:17:51 +00:00
CookieAuthentication 1
CookieAuthFileGroupReadable 1
2018-12-02 19:52:01 +01:00
2020-01-23 18:59:53 +01:00
# Hidden Service for WEB ADMIN INTERFACE
2018-12-02 19:52:01 +01:00
HiddenServiceDir /mnt/hdd/tor/web80/
HiddenServiceVersion 3
2018-12-02 19:52:01 +01:00
HiddenServicePort 80 127.0.0.1:80
2021-03-23 11:17:51 +00:00
# NOTE: since Bitcoin Core v0.21.0 sets up a v3 Tor service automatically
# see /mnt/hdd/bitcoin for the onion private key - delete and restart bitcoind to reset
# NOTE: LND is using a separate Tor instance: tor@lnd
# find the torrc at /etc/tor/instances/lnd/torrc
# onion private key at /mnt/hdd/lnd/v3_onion_private_key
2020-01-23 18:59:53 +01:00
# Hidden Service for LND RPC
2018-12-02 19:52:01 +01:00
HiddenServiceDir /mnt/hdd/tor/lndrpc10009/
HiddenServiceVersion 3
HiddenServicePort 10009 127.0.0.1:10009
2020-01-23 18:59:53 +01:00
# Hidden Service for LND REST
HiddenServiceDir /mnt/hdd/tor/lndrest8080/
HiddenServiceVersion 3
2020-01-23 18:59:53 +01:00
HiddenServicePort 8080 127.0.0.1:8080
2018-12-02 19:52:01 +01:00
EOF
sudo rm $torrc
sudo mv ./torrc $torrc
sudo chmod 644 $torrc
2020-09-28 21:26:04 +02:00
sudo chown -R debian-tor:debian-tor /var/run/tor/ 2>/dev/null
echo ""
2018-12-02 19:52:01 +01:00
2020-09-10 14:04:29 +02:00
sudo mkdir -p /etc/systemd/system/tor@default.service.d
2020-09-28 21:26:04 +02:00
sudo tee /etc/systemd/system/tor@default.service.d/raspiblitz.conf >/dev/null <<EOF
2021-03-23 11:17:51 +00:00
# DO NOT EDIT! This file is generated by raspiblitz and will be overwritten
2020-09-28 21:26:04 +02:00
[Service]
ReadWriteDirectories=-/mnt/hdd/tor
[Unit]
After=network.target nss-lookup.target mnt-hdd.mount
2020-09-28 21:26:04 +02:00
EOF
2019-06-12 23:40:56 +02:00
else
echo "# - Tor config ${torrc} is already updated"
2019-06-12 23:40:56 +02:00
fi
2019-06-12 23:40:56 +02:00
# ACTIVATE TOR SERVICE
2021-03-23 11:17:51 +00:00
echo "*** Enable Tor Service ***"
2019-06-12 23:40:56 +02:00
sudo systemctl daemon-reload
sudo systemctl enable tor@default
echo ""
2018-12-02 19:52:01 +01:00
2019-06-13 00:58:52 +02:00
# ACTIVATE BITCOIN OVER TOR (function call)
activateBitcoinOverTOR
2018-12-11 01:00:55 +01:00
2019-06-13 00:58:52 +02:00
# ACTIVATE LND OVER TOR (function call)
activateLndOverTOR
2018-12-02 19:52:01 +01:00
2020-01-26 23:57:27 +01:00
# ACTIVATE APPS OVER TOR
source /mnt/hdd/raspiblitz.conf 2>/dev/null
if [ "${BTCRPCexplorer}" = "on" ]; then
/home/admin/config.scripts/internet.hiddenservice.sh btc-rpc-explorer 80 3002
fi
if [ "${rtlWebinterface}" = "on" ]; then
2020-07-18 15:26:56 +02:00
/home/admin/config.scripts/internet.hiddenservice.sh RTL 80 3002 443 3003
2020-01-26 23:57:27 +01:00
fi
if [ "${BTCPayServer}" = "on" ]; then
2020-07-18 15:26:56 +02:00
/home/admin/config.scripts/internet.hiddenservice.sh btcpay 80 23002 443 23003
2020-01-26 23:57:27 +01:00
fi
if [ "${ElectRS}" = "on" ]; then
/home/admin/config.scripts/internet.hiddenservice.sh electrs 50002 50002 50001 50001
fi
2020-04-23 23:10:30 +02:00
if [ "${LNBits}" = "on" ]; then
2020-07-18 15:26:56 +02:00
/home/admin/config.scripts/internet.hiddenservice.sh lnbits 80 5002 443 5003
fi
if [ "${thunderhub}" = "on" ]; then
/home/admin/config.scripts/internet.hiddenservice.sh thunderhub 80 3012 443 3013
fi
if [ "${specter}" = "on" ]; then
# specter makes only sense to be served over https
/home/admin/config.scripts/internet.hiddenservice.sh specter 443 25441
2020-02-10 12:33:03 +01:00
fi
if [ "${sphinxrelay}" = "on" ]; then
/home/admin/config.scripts/internet.hiddenservice.sh sphinxrelay 80 3302 443 3303
toraddress=$(sudo cat /mnt/hdd/tor/sphinxrelay/hostname 2>/dev/null)
sudo -u sphinxrelay bash -c "echo '${toraddress}' > /home/sphinxrelay/sphinx-relay/dist/toraddress.txt"
fi
# get TOR address and store it readable for sphixrelay user
toraddress=$(sudo cat /mnt/hdd/tor/sphinxrelay/hostname 2>/dev/null)
sudo -u sphinxrelay bash -c "echo '${toraddress}' > /home/sphinxrelay/sphinx-relay/dist/toraddress.txt"
2020-01-26 23:57:27 +01:00
2020-09-05 22:30:19 +02:00
echo "Setup logrotate"
2020-09-28 21:26:04 +02:00
# add logrotate config for modified Tor dir on ext. disk
sudo tee /etc/logrotate.d/raspiblitz-tor >/dev/null <<EOF
2020-09-05 22:30:19 +02:00
/mnt/hdd/tor/*log {
daily
rotate 5
compress
delaycompress
missingok
notifempty
2020-09-28 21:26:04 +02:00
create 0640 debian-tor debian-tor
2020-09-05 22:30:19 +02:00
sharedscripts
postrotate
if invoke-rc.d tor status > /dev/null; then
invoke-rc.d tor reload > /dev/null
fi
endscript
}
EOF
2020-09-28 21:26:04 +02:00
# make sure its the correct owner before last Tor restart
sudo chmod -R 700 /mnt/hdd/tor
sudo chown -R debian-tor:debian-tor /mnt/hdd/tor
2020-09-28 21:26:04 +02:00
sudo systemctl restart tor@default
2020-09-05 22:30:19 +02:00
2021-03-23 11:17:51 +00:00
echo "OK - Tor is now ON"
2018-12-02 19:52:01 +01:00
echo "needs reboot to activate new setting"
exit 0
fi
# switch off
2018-12-02 20:43:48 +01:00
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
2021-03-23 11:17:51 +00:00
echo "# switching Tor OFF"
2018-12-02 19:52:01 +01:00
# setting value in raspi blitz config
sudo sed -i "s/^runBehindTor=.*/runBehindTor=off/g" /mnt/hdd/raspiblitz.conf
# *** CURL TOR PROXY ***
# sudo rm /root/.curlrc
# sudo rm /home/pi/.curlrc
# sudo rm /home/admin/.curlrc
2018-12-02 19:52:01 +01:00
# disable TOR service
2021-03-23 11:17:51 +00:00
echo "# *** Disable Tor service ***"
2018-12-02 19:52:01 +01:00
sudo systemctl disable tor@default
sudo systemctl disable tor@lnd
2018-12-02 19:52:01 +01:00
echo ""
2019-08-08 17:41:58 +02:00
# DEACTIVATE BITCOIN OVER TOR (function call)
deactivateBitcoinOverTOR
2018-12-02 19:52:01 +01:00
echo ""
2021-03-23 11:17:51 +00:00
echo "# *** Removing Tor from LND ***"
2018-12-02 19:52:01 +01:00
sudo systemctl disable lnd
echo "# editing /etc/systemd/system/lnd.service"
2020-03-21 23:18:19 -07:00
sudo sed -i "s/^ExecStart=\/usr\/local\/bin\/lnd.*/ExecStart=\/usr\/local\/bin\/lnd --externalip=\${publicIP}:\${lndPort} \${lndExtraParameter}/g" /etc/systemd/system/lnd.service
2018-12-11 01:00:55 +01:00
2020-11-30 21:27:51 +01:00
sudo /home/admin/config.scripts/internet.sh update-publicip
2018-12-02 19:52:01 +01:00
sudo systemctl enable lnd
echo "# OK"
2018-12-02 19:52:01 +01:00
echo ""
2021-03-23 11:17:51 +00:00
echo "# *** Stop Tor service ***"
2020-09-28 21:26:04 +02:00
sudo systemctl stop tor@default
sudo systemctl stop tor@lnd
2020-09-28 21:26:04 +02:00
echo ""
if [ "$2" == "clear" ]; then
echo "# *** Deinstall Tor & Delete Data ***"
sudo rm -r /mnt/hdd/tor 2>/dev/null
sudo apt remove tor tor-arm -y
fi
echo "# needs reboot to activate new setting"
2018-12-02 19:52:01 +01:00
exit 0
fi
2020-11-15 22:16:13 +00:00
# update
if [ "$1" = "update" ]; then
# as in https://2019.www.torproject.org/docs/debian#source
echo "# Install the dependencies"
sudo apt update
sudo apt install -y build-essential fakeroot devscripts
sudo apt build-dep -y tor deb.torproject.org-keyring
rm -rf /home/admin/download/debian-packages
mkdir -p /home/admin/download/debian-packages
cd /home/admin/download/debian-packages
echo "# Building Tor from the source code ..."
apt source tor
cd tor-*
debuild -rfakeroot -uc -us
cd ..
echo "# Stopping the tor.service before updating"
sudo systemctl stop tor
echo "# Update ..."
sudo dpkg -i tor_*.deb
echo "# Starting the tor.service "
sudo systemctl start tor
echo "# Installed $(tor --version)"
if [ $(systemctl status lnd | grep -c "active (running)") -gt 0 ];then
echo "# LND needs to restart"
sudo systemctl restart lnd
sleep 10
lncli unlock
fi
2020-11-15 22:16:13 +00:00
exit 0
fi
echo "# FAIL - Unknown Parameter $1"
echo "# may needs reboot to run normal again"
exit 1