2018-12-24 00:56:22 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# SHORTCUT COMMANDS you can call as user 'admin' from terminal
|
|
|
|
|
2020-04-29 14:16:47 +02:00
|
|
|
# command: raspiblitz
|
2019-06-30 19:55:18 +02:00
|
|
|
# calls the the raspiblitz mainmenu (legacy)
|
2020-04-29 14:16:47 +02:00
|
|
|
function raspiblitz() {
|
2019-06-30 19:55:18 +02:00
|
|
|
cd /home/admin
|
|
|
|
./00raspiblitz.sh
|
|
|
|
}
|
|
|
|
|
|
|
|
# command: blitz
|
|
|
|
# calls the the raspiblitz mainmenu (shortcut)
|
|
|
|
function blitz() {
|
2019-01-14 16:16:43 +01:00
|
|
|
cd /home/admin
|
2019-04-16 19:55:25 +02:00
|
|
|
./00raspiblitz.sh
|
2019-06-30 17:47:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# command: menu
|
|
|
|
# calls directly the main menu
|
|
|
|
function menu() {
|
|
|
|
cd /home/admin
|
|
|
|
./00mainMenu.sh
|
|
|
|
}
|
|
|
|
|
|
|
|
# command: repair
|
|
|
|
# calls directly the repair menu
|
2019-06-30 19:55:18 +02:00
|
|
|
function repair() {
|
2019-06-30 17:47:11 +02:00
|
|
|
cd /home/admin
|
|
|
|
./98repairMenu.sh
|
2019-12-19 00:23:54 +01:00
|
|
|
}
|
|
|
|
|
2020-09-29 12:35:22 +02:00
|
|
|
# command: sourcemode
|
|
|
|
function sourcemode() {
|
|
|
|
cd /home/admin
|
|
|
|
./98repairMenu.sh sourcemode
|
|
|
|
}
|
|
|
|
|
2020-02-20 13:24:57 +01:00
|
|
|
# command: check
|
|
|
|
function check() {
|
|
|
|
/home/admin/config.scripts/blitz.configcheck.py
|
|
|
|
}
|
|
|
|
|
2020-04-28 18:28:49 +02:00
|
|
|
# command: debug
|
|
|
|
function debug() {
|
|
|
|
cd /home/admin
|
|
|
|
./XXdebugLogs.sh
|
|
|
|
}
|
|
|
|
|
2020-06-28 14:56:31 +02:00
|
|
|
# command: patch
|
|
|
|
# syncs script with latest set github and branch
|
|
|
|
function patch() {
|
|
|
|
cd /home/admin
|
|
|
|
./XXsyncScripts.sh -run
|
|
|
|
}
|
|
|
|
|
2020-04-28 18:28:49 +02:00
|
|
|
# command: restart
|
|
|
|
function restart() {
|
|
|
|
cd /home/admin
|
|
|
|
./XXshutdown.sh reboot
|
|
|
|
}
|
|
|
|
|
2020-06-04 10:54:36 +02:00
|
|
|
# command: off
|
2020-04-28 18:28:49 +02:00
|
|
|
function off() {
|
|
|
|
cd /home/admin
|
|
|
|
./XXshutdown.sh
|
|
|
|
}
|
|
|
|
|
2020-09-16 13:33:14 +02:00
|
|
|
# command: github
|
|
|
|
# jumpng directly into the options to change branch/repo/pr
|
|
|
|
function github() {
|
|
|
|
cd /home/admin
|
|
|
|
./99updateMenu.sh github
|
|
|
|
}
|
|
|
|
|
2020-01-24 21:46:51 +01:00
|
|
|
# command: hdmi
|
|
|
|
function hdmi() {
|
|
|
|
echo "# SWITCHING VIDEO OUTPUT TO --> HDMI"
|
2020-01-24 21:55:54 +01:00
|
|
|
sudo /home/admin/config.scripts/blitz.lcd.sh hdmi on
|
2020-01-24 21:46:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# command: lcd
|
|
|
|
function lcd() {
|
|
|
|
echo "# SWITCHING VIDEO OUTPUT TO --> LCD"
|
2020-01-24 21:55:54 +01:00
|
|
|
sudo /home/admin/config.scripts/blitz.lcd.sh hdmi off
|
2020-01-24 21:46:51 +01:00
|
|
|
}
|
|
|
|
|
2019-12-19 00:29:53 +01:00
|
|
|
# command: manage
|
|
|
|
function manage() {
|
2019-12-19 00:23:54 +01:00
|
|
|
if [ $(cat /mnt/hdd/raspiblitz.conf 2>/dev/null | grep -c "lndmanage=on") -eq 1 ]; then
|
2019-12-19 00:29:53 +01:00
|
|
|
cd /home/admin/lndmanage
|
2019-12-19 00:23:54 +01:00
|
|
|
source venv/bin/activate
|
2020-01-22 02:52:15 +01:00
|
|
|
echo "NOTICE: Needs at least one active channel to run without error."
|
2019-12-19 00:29:53 +01:00
|
|
|
echo "to exit (venv) enter ---> deactivate"
|
2019-12-19 00:23:54 +01:00
|
|
|
lndmanage
|
|
|
|
else
|
2020-01-23 17:48:11 +01:00
|
|
|
echo "lndmanage not installed - to install run:"
|
2019-12-19 00:23:54 +01:00
|
|
|
echo "sudo /home/admin/config.scripts/bonus.lndmanage.sh on"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-04-29 14:16:47 +02:00
|
|
|
# command: torthistx
|
|
|
|
function torthistx() {
|
|
|
|
if [ $(cat /mnt/hdd/raspiblitz.conf 2>/dev/null | grep -c "runBehindTor=on") -eq 1 ]; then
|
|
|
|
echo "Broadcasting transaction through Tor to Blockstreams API and into the network."
|
|
|
|
curl --socks5-hostname localhost:9050 -d $1 -X POST http://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion/api/tx
|
|
|
|
else
|
|
|
|
echo "Not running behind Tor - to install run:"
|
|
|
|
echo "sudo /home/admin/config.scripts/internet.tor.sh on"
|
|
|
|
fi
|
|
|
|
}
|
2020-06-04 10:54:36 +02:00
|
|
|
|
|
|
|
# command: status
|
2020-06-20 11:01:06 +02:00
|
|
|
# start the status screen in the terminal
|
2020-06-04 10:54:36 +02:00
|
|
|
function status() {
|
2020-08-08 22:22:31 +02:00
|
|
|
echo "Gathering data - please wait a moment..."
|
|
|
|
sudo -u pi /home/admin/00infoLCD.sh --pause 0
|
2020-06-20 11:01:06 +02:00
|
|
|
}
|
|
|
|
|
2020-11-17 21:17:35 +01:00
|
|
|
# command: lnbalance
|
|
|
|
# show balance report
|
|
|
|
function balance() {
|
|
|
|
echo "*** YOUR SATOSHI BALANCES ***"
|
|
|
|
/home/admin/config.scripts/lnd.balance.sh
|
|
|
|
}
|
|
|
|
|
|
|
|
# command: lnchannels
|
|
|
|
# show channel listing
|
|
|
|
function channels() {
|
|
|
|
echo "*** YOUR LIGHTNING CHANNELS ***"
|
|
|
|
/home/admin/config.scripts/lnd.channels.sh
|
|
|
|
}
|
|
|
|
|
|
|
|
# command: lnfwdreport
|
|
|
|
# show forwarding report
|
|
|
|
function fwdreport() {
|
|
|
|
/home/admin/config.scripts/lnd.fwdreport.sh -menu
|
|
|
|
}
|
|
|
|
|
2020-09-28 21:32:40 +02:00
|
|
|
# command: bos
|
2020-06-20 11:01:06 +02:00
|
|
|
# switch to the bos user for Balance of Satoshis
|
2020-09-28 21:32:40 +02:00
|
|
|
function bos() {
|
2020-09-22 19:09:16 +02:00
|
|
|
if [ $(grep -c "bos=on" < /mnt/hdd/raspiblitz.conf) -eq 1 ]; then
|
2020-10-06 20:45:29 +02:00
|
|
|
echo "# switching to the bos user with the command: 'sudo su - bos'"
|
2021-03-18 00:50:26 +01:00
|
|
|
echo "# use command 'exit' and then 'raspiblitz' to return to menu"
|
|
|
|
echo "# use command 'bos --help' to list all possible options"
|
2020-06-20 11:01:06 +02:00
|
|
|
sudo su - bos
|
2021-03-18 00:50:26 +01:00
|
|
|
echo "# use command 'raspiblitz' to return to menu"
|
2020-06-20 11:01:06 +02:00
|
|
|
else
|
|
|
|
echo "Balance of Satoshis is not installed - to install run:"
|
|
|
|
echo "/home/admin/config.scripts/bonus.bos.sh on"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-10-18 15:29:17 +02:00
|
|
|
# command: pyblock
|
|
|
|
# switch to the pyblock user for PyBLOCK
|
|
|
|
function pyblock() {
|
|
|
|
if [ $(grep -c "pyblock=on" < /mnt/hdd/raspiblitz.conf) -eq 1 ]; then
|
|
|
|
echo "# switching to the pyblock user with the command: 'sudo su - pyblock'"
|
2021-03-18 00:50:26 +01:00
|
|
|
echo "# use command 'exit' and then 'raspiblitz' to return to menu"
|
|
|
|
echo "# use command 'pyblock' again to start"
|
2020-10-18 15:29:17 +02:00
|
|
|
sudo su - pyblock
|
2021-03-18 00:50:26 +01:00
|
|
|
echo "# use command 'raspiblitz' to return to menu"
|
2020-10-18 15:29:17 +02:00
|
|
|
else
|
|
|
|
echo "PyBlock is not installed - to install run:"
|
|
|
|
echo "/home/admin/config.scripts/bonus.pyblock.sh on"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-09-28 21:32:40 +02:00
|
|
|
# command: jm
|
2020-06-20 11:01:06 +02:00
|
|
|
# switch to the joinmarket user for the JoininBox menu
|
2020-09-28 21:32:40 +02:00
|
|
|
function jm() {
|
2020-09-22 19:09:16 +02:00
|
|
|
if [ $(grep -c "joinmarket=on" < /mnt/hdd/raspiblitz.conf) -eq 1 ]; then
|
2020-10-06 20:45:29 +02:00
|
|
|
echo "# switching to the joinmarket user with the command: 'sudo su - joinmarket'"
|
2020-06-20 11:01:06 +02:00
|
|
|
sudo su - joinmarket
|
2020-11-06 18:13:06 +01:00
|
|
|
echo "# use command 'raspiblitz' to return to menu"
|
2020-06-20 11:01:06 +02:00
|
|
|
else
|
|
|
|
echo "JoinMarket is not installed - to install run:"
|
|
|
|
echo "sudo /home/admin/config.scripts/bonus.joinmarket.sh on"
|
|
|
|
fi
|
|
|
|
}
|
2020-08-08 22:29:57 +02:00
|
|
|
|
2020-09-22 19:23:27 +02:00
|
|
|
# command: faraday
|
|
|
|
# switch to the faraday user for the Faraday Service
|
|
|
|
function faraday() {
|
|
|
|
if [ $(grep -c "faraday=on" < /mnt/hdd/raspiblitz.conf) -eq 1 ]; then
|
2020-10-06 20:45:29 +02:00
|
|
|
echo "# switching to the faraday user with the command: 'sudo su - faraday'"
|
2020-11-06 18:13:06 +01:00
|
|
|
echo "# use command 'exit' and then 'raspiblitz' to return to menu"
|
|
|
|
echo "# use command 'frcli --help' now to get more info"
|
2020-09-22 19:23:27 +02:00
|
|
|
sudo su - faraday
|
2021-03-18 00:50:26 +01:00
|
|
|
echo "# use command 'raspiblitz' to return to menu"
|
2020-09-22 19:23:27 +02:00
|
|
|
else
|
|
|
|
echo "Faraday is not installed - to install run:"
|
|
|
|
echo "/home/admin/config.scripts/bonus.faraday.sh on"
|
2020-09-28 15:31:54 +02:00
|
|
|
fi
|
2020-09-28 15:24:36 +02:00
|
|
|
}
|
2020-09-22 19:23:27 +02:00
|
|
|
|
2021-03-18 22:46:58 +01:00
|
|
|
|
|
|
|
# command: lit
|
|
|
|
# switch to the lit user for the loop, pool & faraday services
|
|
|
|
function lit() {
|
|
|
|
if [ $(grep -c "lit=on" < /mnt/hdd/raspiblitz.conf) -eq 1 ]; then
|
|
|
|
echo "# switching to the lit user with the command: 'sudo su - lit'"
|
|
|
|
echo "# use command 'exit' and then 'raspiblitz' to return to menu"
|
|
|
|
echo "# use the commands: 'lncli', 'loop', 'pool' and 'frcli'"
|
|
|
|
sudo su - lit
|
|
|
|
echo "# use command 'raspiblitz' to return to menu"
|
|
|
|
else
|
|
|
|
echo "LIT is not installed - to install run:"
|
|
|
|
echo "/home/admin/config.scripts/bonus.lit.sh on"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-09-22 19:09:16 +02:00
|
|
|
# command: loop
|
|
|
|
# switch to the loop user for the Lightning Loop Service
|
|
|
|
function loop() {
|
|
|
|
if [ $(grep -c "loop=on" < /mnt/hdd/raspiblitz.conf) -eq 1 ]; then
|
2020-10-06 20:45:29 +02:00
|
|
|
echo "# switching to the loop user with the command: 'sudo su - loop'"
|
2020-11-06 18:13:06 +01:00
|
|
|
echo "# use command 'exit' and then 'raspiblitz' to return to menu"
|
|
|
|
echo "# use command 'loop --help' now to get more info"
|
2020-09-22 19:09:16 +02:00
|
|
|
sudo su - loop
|
2021-03-18 00:50:26 +01:00
|
|
|
echo "# use command 'raspiblitz' to return to menu"
|
2020-09-22 19:09:16 +02:00
|
|
|
else
|
|
|
|
echo "Lightning Loop is not installed - to install run:"
|
|
|
|
echo "/home/admin/config.scripts/bonus.loop.sh on"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-11-06 12:49:26 +01:00
|
|
|
# command: pool
|
|
|
|
# switch to the pool user for the Pool Service
|
|
|
|
function pool() {
|
|
|
|
if [ $(grep -c "pool=on" < /mnt/hdd/raspiblitz.conf) -gt 0 ]; then
|
|
|
|
echo "# switching to the pool user with the command: 'sudo su - pool'"
|
2020-11-06 18:13:06 +01:00
|
|
|
echo "# use command 'exit' and then 'raspiblitz' to return to menu"
|
|
|
|
echo "# use command 'pool --help' now to get more info"
|
2020-11-06 12:49:26 +01:00
|
|
|
sudo su - pool
|
2021-03-18 00:50:26 +01:00
|
|
|
echo "# use command 'raspiblitz' to return to menu"
|
2020-11-06 12:49:26 +01:00
|
|
|
else
|
|
|
|
echo "Pool is not installed - to install run:"
|
|
|
|
echo "/home/admin/config.scripts/bonus.pool.sh on"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-03-18 14:05:49 +01:00
|
|
|
# aliases for lit
|
|
|
|
# switch to the pool user for the Pool Service
|
|
|
|
if [ $(grep -c "lit=on" < /mnt/hdd/raspiblitz.conf) -gt 0 ]; then
|
|
|
|
source /mnt/hdd/raspiblitz.conf
|
|
|
|
alias lit-frcli="sudo -u lit frcli --rpcserver=localhost:8443 \
|
|
|
|
--tlscertpath=/home/lit/.lit/tls.cert \
|
|
|
|
--macaroonpath=/home/lit/.faraday/${chain}net/faraday.macaroon"
|
|
|
|
alias lit-loop="sudo -u lit loop --rpcserver=localhost:8443 \\
|
|
|
|
--tlscertpath=/home/lit/.lit/tls.cert \\
|
|
|
|
--macaroonpath=/home/lit/.loop/${chain}net/loop.macaroon"
|
|
|
|
alias lit-pool="sudo -u lit pool --rpcserver=localhost:8443 \
|
|
|
|
--tlscertpath=/home/lit/.lit/tls.cert \
|
|
|
|
--macaroonpath=/home/lit/.pool/${chain}net/pool.macaroon"
|
|
|
|
fi
|
|
|
|
|
2020-08-08 22:29:57 +02:00
|
|
|
# command: gettx
|
|
|
|
# retrieve transaction from mempool or blockchain and print as JSON
|
|
|
|
# $ gettx "f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16"
|
|
|
|
function gettx() {
|
|
|
|
tx_id="${1:-f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16}"
|
|
|
|
if result=$(bitcoin-cli getrawtransaction "${tx_id}" 1 2>/dev/null); then
|
|
|
|
echo "${result}"
|
|
|
|
else
|
|
|
|
echo "{\"error\": \"unable to find TX\", \"tx_id\": \"${tx_id}\"}"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# command: watchtx
|
|
|
|
# try to retrieve transaction from mempool or blockchain until certain confirmation target
|
|
|
|
# is reached and then exit cleanly. Default is to wait for 2 confs and to sleep for 60 secs.
|
|
|
|
# $ watchtx "f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16" 6 30
|
|
|
|
function watchtx() {
|
|
|
|
tx_id="${1}"
|
|
|
|
wait_n_confirmations="${2:-2}"
|
|
|
|
sleep_time="${3:-60}"
|
|
|
|
|
|
|
|
echo "Waiting for ${wait_n_confirmations} confirmations"
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
|
|
|
|
if result=$(bitcoin-cli getrawtransaction "${tx_id}" 1 2>/dev/null); then
|
|
|
|
confirmations=$(echo "${result}" | jq .confirmations)
|
|
|
|
|
|
|
|
if [[ "${confirmations}" -ge "${wait_n_confirmations}" ]]; then
|
|
|
|
printf "confirmations: ${confirmations} - target reached!\n"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
printf "confirmations: ${confirmations} - "
|
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
printf "unable to find TX - "
|
|
|
|
fi
|
|
|
|
|
|
|
|
printf "sleeping for ${sleep_time} seconds...\n"
|
|
|
|
sleep ${sleep_time}
|
|
|
|
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# command: notifyme
|
|
|
|
# A wrapper for blitz.notify.sh that will send a notification using the configured
|
|
|
|
# method and settings.
|
|
|
|
# This makes sense when waiting for commands to finish and then sending a notification.
|
|
|
|
# $ notifyme "Hello there..!"
|
|
|
|
# $ ./run_job_which_takes_long.sh && notifyme "I'm done."
|
|
|
|
# $ ./run_job_which_takes_long.sh && notifyme "success" || notifyme "fail"
|
|
|
|
function notifyme() {
|
|
|
|
content="${1:-Notified}"
|
|
|
|
/home/admin/config.scripts/blitz.notify.sh send "${content}"
|
|
|
|
}
|