mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-28 04:26:28 +02:00
rework BTCPay status
This commit is contained in:
@@ -19,6 +19,7 @@ from blitzpy import RaspiBlitzConfig
|
|||||||
LND_REST_API = "LND-REST-API"
|
LND_REST_API = "LND-REST-API"
|
||||||
LND_GRPC_API = "LND-GRPC-API"
|
LND_GRPC_API = "LND-GRPC-API"
|
||||||
LNBITS = "LNBITS"
|
LNBITS = "LNBITS"
|
||||||
|
BTCPAY = "BTCPAY"
|
||||||
|
|
||||||
# load config
|
# load config
|
||||||
cfg = RaspiBlitzConfig()
|
cfg = RaspiBlitzConfig()
|
||||||
@@ -243,6 +244,7 @@ your RaspiBlitz behind TOR.
|
|||||||
lnd_rest_api=False
|
lnd_rest_api=False
|
||||||
lnd_grpc_api=False
|
lnd_grpc_api=False
|
||||||
lnbits=False
|
lnbits=False
|
||||||
|
btcbay=False
|
||||||
try:
|
try:
|
||||||
if os.path.isfile(SUBSCRIPTIONS_FILE):
|
if os.path.isfile(SUBSCRIPTIONS_FILE):
|
||||||
os.system("sudo chown admin:admin {0}".format(SUBSCRIPTIONS_FILE))
|
os.system("sudo chown admin:admin {0}".format(SUBSCRIPTIONS_FILE))
|
||||||
@@ -252,15 +254,24 @@ your RaspiBlitz behind TOR.
|
|||||||
if sub['active'] and sub['name'] == LND_REST_API: lnd_rest_api=True
|
if sub['active'] and sub['name'] == LND_REST_API: lnd_rest_api=True
|
||||||
if sub['active'] and sub['name'] == LND_GRPC_API: lnd_grpc_api=True
|
if sub['active'] and sub['name'] == LND_GRPC_API: lnd_grpc_api=True
|
||||||
if sub['active'] and sub['name'] == LNBITS: lnbits=True
|
if sub['active'] and sub['name'] == LNBITS: lnbits=True
|
||||||
|
if sub['active'] and sub['name'] == BTCPAY: btcpay=True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
# check if BTCPayserver is installed
|
||||||
|
btcPayServer=False
|
||||||
|
statusData= subprocess.run(['/home/admin/config.scripts/bonus.btcpayserver.sh', 'status'], stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
|
||||||
|
if statusData.find("BTCPayServer=on") > -1:
|
||||||
|
btcPayServer=True
|
||||||
|
|
||||||
# ask user for which RaspiBlitz service the bridge should be used
|
# ask user for which RaspiBlitz service the bridge should be used
|
||||||
choices = []
|
choices = []
|
||||||
choices.append( ("REST","LND REST API {0}".format("--> ALREADY BRIDGED" if lnd_rest_api else "")) )
|
choices.append( ("REST","LND REST API {0}".format("--> ALREADY BRIDGED" if lnd_rest_api else "")) )
|
||||||
choices.append( ("GRPC","LND gRPC API {0}".format("--> ALREADY BRIDGED" if lnd_grpc_api else "")) )
|
choices.append( ("GRPC","LND gRPC API {0}".format("--> ALREADY BRIDGED" if lnd_grpc_api else "")) )
|
||||||
if cfg.lnbits:
|
if cfg.lnbits:
|
||||||
choices.append( ("LNBITS","LNbits Webinterface {0}".format("--> ALREADY BRIDGED" if lnd_grpc_api else "")) )
|
choices.append( ("LNBITS","LNbits Webinterface {0}".format("--> ALREADY BRIDGED" if lnd_grpc_api else "")) )
|
||||||
|
if btcPayServer:
|
||||||
|
choices.append( ("BTCPAY","BTCPay Server Webinterface {0}".format("--> ALREADY BRIDGED" if btcpay else "")) )
|
||||||
choices.append( ("SELF","Create a custom IP2TOR Bridge") )
|
choices.append( ("SELF","Create a custom IP2TOR Bridge") )
|
||||||
|
|
||||||
d = Dialog(dialog="dialog",autowidgetsize=True)
|
d = Dialog(dialog="dialog",autowidgetsize=True)
|
||||||
@@ -291,6 +302,11 @@ your RaspiBlitz behind TOR.
|
|||||||
servicename=LNBITS
|
servicename=LNBITS
|
||||||
torAddress = subprocess.run(['sudo', 'cat', '/mnt/hdd/tor/lnbits/hostname'], stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
|
torAddress = subprocess.run(['sudo', 'cat', '/mnt/hdd/tor/lnbits/hostname'], stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
|
||||||
torPort=443
|
torPort=443
|
||||||
|
if tag == "BTCPAY":
|
||||||
|
# get TOR address for BTCPAY
|
||||||
|
servicename=BTCPAY
|
||||||
|
torAddress = subprocess.run(['sudo', 'cat', '/mnt/hdd/tor/btcpay/hostname'], stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
|
||||||
|
torPort=443
|
||||||
if tag == "SELF":
|
if tag == "SELF":
|
||||||
servicename="CUSTOM"
|
servicename="CUSTOM"
|
||||||
try:
|
try:
|
||||||
|
@@ -13,42 +13,102 @@ source /mnt/hdd/raspiblitz.conf
|
|||||||
# get cpu architecture
|
# get cpu architecture
|
||||||
source /home/admin/raspiblitz.info
|
source /home/admin/raspiblitz.info
|
||||||
|
|
||||||
|
if [ "$1" = "status" ]; then
|
||||||
|
if [ "${BTCPayServer}" = "on" ]; then
|
||||||
|
echo "installed=1"
|
||||||
|
|
||||||
|
localIP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
||||||
|
echo "localIP='${localIP}'"
|
||||||
|
echo "httpsPort='23001'"
|
||||||
|
echo "publicIP='${publicIP}'"
|
||||||
|
|
||||||
|
# check for LetsEnryptDomain for DynDns
|
||||||
|
error=""
|
||||||
|
source <(sudo /home/admin/config.scripts/blitz.subscriptions.ip2tor.py ip-by-tor $publicIP)
|
||||||
|
if [ ${#error} -eq 0 ]; then
|
||||||
|
echo "publicDomain='${domain}'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sslFingerprintIP=$(openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout 2>/dev/null | cut -d"=" -f2)
|
||||||
|
echo "sslFingerprintIP='${sslFingerprintIP}'"
|
||||||
|
|
||||||
|
toraddress=$(sudo cat /mnt/hdd/tor/btcpay/hostname 2>/dev/null)
|
||||||
|
echo "toraddress='${toraddress}'"
|
||||||
|
|
||||||
|
sslFingerprintTOR=$(openssl x509 -in /mnt/hdd/app-data/nginx/tor_tls.cert -fingerprint -noout 2>/dev/null | cut -d"=" -f2)
|
||||||
|
echo "sslFingerprintTOR='${sslFingerprintTOR}'"
|
||||||
|
|
||||||
|
# check for IP2TOR
|
||||||
|
error=""
|
||||||
|
source <(sudo /home/admin/config.scripts/blitz.subscriptions.ip2tor.py ip-by-tor $toraddress)
|
||||||
|
if [ ${#error} -eq 0 ]; then
|
||||||
|
echo "ip2torType='${ip2tor-v1}'"
|
||||||
|
echo "ip2torID='${id}'"
|
||||||
|
echo "ip2torIP='${ip}'"
|
||||||
|
echo "ip2torPort='${port}'"
|
||||||
|
# check for LetsEnryptDomain on IP2TOR
|
||||||
|
error=""
|
||||||
|
source <(sudo /home/admin/config.scripts/blitz.subscriptions.letsencrypt.py domain-by-ip $ip)
|
||||||
|
if [ ${#error} -eq 0 ]; then
|
||||||
|
echo "ip2torDomain='${domain}'"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check for error
|
||||||
|
isDead=$(sudo systemctl status btcpayserver | grep -c 'inactive (dead)')
|
||||||
|
if [ ${isDead} -eq 1 ]; then
|
||||||
|
echo "error='Service Failed'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "installed=0"
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# show info menu
|
# show info menu
|
||||||
if [ "$1" = "menu" ]; then
|
if [ "$1" = "menu" ]; then
|
||||||
|
|
||||||
# get network info
|
# get LNbits status info
|
||||||
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
echo "# collecting status info ... (please wait)"
|
||||||
toraddress=$(sudo cat /mnt/hdd/tor/btcpay/hostname 2>/dev/null)
|
source <(sudo /home/admin/config.scripts/bonus.btcpayserver.sh status)
|
||||||
|
|
||||||
if [ "${BTCPayDomain}" == "localhost" ]; then
|
text="Local Webrowser: https://${localIP}:${httpsPort}"
|
||||||
|
|
||||||
# TOR
|
if [ ${#publicDomain} -gt 0 ]; then
|
||||||
|
text="${text}
|
||||||
|
Public Domain: https://${publicDomain}:${httpsPort}
|
||||||
|
port forwarding on router needs to be active & may change port"
|
||||||
|
fi
|
||||||
|
|
||||||
|
text="${text}
|
||||||
|
SHA1 ${sslFingerprintIP}"
|
||||||
|
|
||||||
|
if [ "${runBehindTor}" = "on" ] && [ ${#toraddress} -gt 0 ]; then
|
||||||
/home/admin/config.scripts/blitz.lcd.sh qr "${toraddress}"
|
/home/admin/config.scripts/blitz.lcd.sh qr "${toraddress}"
|
||||||
whiptail --title " BTCPay Server (TOR) " --msgbox "Have TOR Browser installed on your laptop and open:\n
|
text="${text}\n
|
||||||
${toraddress}\n
|
TOR Browser Hidden Service address (QR see LCD):
|
||||||
See LCD of RaspiBlitz for QR code of this address if you want to open on mobile devices with TOR browser.
|
${toraddress}"
|
||||||
" 12 67
|
fi
|
||||||
|
|
||||||
|
if [ ${#ip2torDomain} -gt 0 ]; then
|
||||||
|
text="${text}\n
|
||||||
|
IP2TOR+LetsEncrypt: https://${ip2torDomain}:${ip2torPort}
|
||||||
|
SHA1 ${sslFingerprintTOR}"
|
||||||
|
elif [ ${#ip2torIP} -gt 0 ]; then
|
||||||
|
text="${text}\n
|
||||||
|
IP2TOR: https://${ip2torIP}:${ip2torPort}
|
||||||
|
SHA1 ${sslFingerprintTOR}
|
||||||
|
go MAINMENU > SUBSCRIBE and add LetsEncrypt HTTPS Domain"
|
||||||
|
elif [ ${#publicDomain} -eq 0 ]; then
|
||||||
|
text="${text}\n
|
||||||
|
To enable easy reachablity with normal brower from the outside
|
||||||
|
consider adding a IP2TOR Bridge (MAINMENU > SUBSCRIBE)."
|
||||||
|
fi
|
||||||
|
|
||||||
|
whiptail --title " BTCPay Server " --msgbox "${text}" 15 69
|
||||||
|
|
||||||
/home/admin/config.scripts/blitz.lcd.sh hide
|
/home/admin/config.scripts/blitz.lcd.sh hide
|
||||||
else
|
|
||||||
|
|
||||||
if [ "${BTCPayDomain}" == "off" ]; then
|
|
||||||
BTCPayDomain="${localip}:23001"
|
|
||||||
fi
|
|
||||||
|
|
||||||
fingerprint=$(openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout | cut -d"=" -f2)
|
|
||||||
|
|
||||||
torinfo="For details or troubleshoot check for 'BTCPay'\nin README of https://github.com/rootzoll/raspiblitz"
|
|
||||||
if [ "${runBehindTor}" == "on" ] && [ ${#toraddress} -gt 0 ]; then
|
|
||||||
torinfo="To reach BTCPay Server oder Tor use:\n${toraddress}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# IP + Domain
|
|
||||||
whiptail --title " BTCPay Server (Domain) " --msgbox "Open the following URL in your local web browser:
|
|
||||||
https://${BTCPayDomain}\n
|
|
||||||
SHA1 Thumb/Fingerprint: ${fingerprint}\n
|
|
||||||
${torinfo}" 14 67
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "please wait ..."
|
echo "please wait ..."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user