From b0e344c500461954f2dd87c019688d4b677ebdb0 Mon Sep 17 00:00:00 2001 From: frennkie Date: Mon, 27 Jul 2020 15:36:01 +0200 Subject: [PATCH 1/3] Update blitz.subscriptions.ip2tor.py --- home.admin/config.scripts/blitz.subscriptions.ip2tor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/home.admin/config.scripts/blitz.subscriptions.ip2tor.py b/home.admin/config.scripts/blitz.subscriptions.ip2tor.py index 1fa76ed4f..310147d0a 100644 --- a/home.admin/config.scripts/blitz.subscriptions.ip2tor.py +++ b/home.admin/config.scripts/blitz.subscriptions.ip2tor.py @@ -54,8 +54,8 @@ if Path("/mnt/hdd/raspiblitz.conf").is_file(): is_testnet = False ENV = "PROD" - # DEFAULT_SHOPURL="shopdeu2vdhazvmllyfagdcvlpflzdyt5gwftmn4hjj3zw2oyelksaid.onion" - DEFAULT_SHOPURL = "ip2tor.fulmo.org" + DEFAULT_SHOPURL = "fulmo7x6yvgz6zs2b2ptduvzwevxmizhq23klkenslt5drxx2physlqd.onion" + # DEFAULT_SHOPURL = "ip2tor.fulmo.org" LND_IP = "127.0.0.1" LND_ADMIN_MACAROON_PATH = "/mnt/hdd/app-data/lnd/data/chain/{0}/{1}net/admin.macaroon".format(cfg.network.value, cfg.chain.value) @@ -66,7 +66,8 @@ if Path("/mnt/hdd/raspiblitz.conf").is_file(): else: ENV = "DEV" print("# blitz.ip2tor.py (development env)") - DEFAULT_SHOPURL = "ip2tor.fulmo.org" + DEFAULT_SHOPURL = "fulmo7x6yvgz6zs2b2ptduvzwevxmizhq23klkenslt5drxx2physlqd.onion" + # DEFAULT_SHOPURL = "ip2tor.fulmo.org" LND_IP = "192.168.178.95" LND_ADMIN_MACAROON_PATH = "/Users/rotzoll/Downloads/RaspiBlitzCredentials/admin.macaroon" LND_TLS_PATH = "/Users/rotzoll/Downloads/RaspiBlitzCredentials/tls.cert" From f30e074c3c8936648fa66403fcab2afbdac43a0d Mon Sep 17 00:00:00 2001 From: frennkie Date: Wed, 29 Jul 2020 09:13:30 +0200 Subject: [PATCH 2/3] Update blitz.subscriptions.ip2tor.py --- home.admin/config.scripts/blitz.subscriptions.ip2tor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/config.scripts/blitz.subscriptions.ip2tor.py b/home.admin/config.scripts/blitz.subscriptions.ip2tor.py index 310147d0a..0d9bc8bae 100644 --- a/home.admin/config.scripts/blitz.subscriptions.ip2tor.py +++ b/home.admin/config.scripts/blitz.subscriptions.ip2tor.py @@ -199,7 +199,7 @@ def apiPlaceOrderNew(session, shopurl, hostid, toraddressWithPort): 'product': "tor_bridge", 'host_id': hostid, 'tos_accepted': True, - 'comment': 'test', + 'comment': 'RaspiBlitz', 'target': toraddressWithPort, 'public_key': '' } From fe69fae904fa21b28120e40909f198f3daaef598 Mon Sep 17 00:00:00 2001 From: frennkie Date: Sun, 2 Aug 2020 14:41:27 +0200 Subject: [PATCH 3/3] Update blitz.notify (#1402) * add from and use system python --- home.admin/XXsendNotification.py | 11 +++++---- home.admin/config.scripts/blitz.notify.sh | 27 ++++++++++++++--------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/home.admin/XXsendNotification.py b/home.admin/XXsendNotification.py index 70e10c3c8..72ecd833c 100644 --- a/home.admin/XXsendNotification.py +++ b/home.admin/XXsendNotification.py @@ -87,8 +87,8 @@ def ext(cmd=None, message=None, debug=False): # e-Mail -def mail(recipient=None, message=None, subject=None, cert=None, encrypt=False, - from_name=None, from_address=None, debug=False): +def mail(recipient: str = None, message: str = None, subject: str = None, cert: str = None, + encrypt: bool = False, from_name: str = None, from_address: str = None, debug: bool = False): if debug: print("send mail") print("msg: {}".format(message)) @@ -107,7 +107,7 @@ def mail(recipient=None, message=None, subject=None, cert=None, encrypt=False, 'From: {} <{}>'.format(from_name, from_address), "Subject: {}".format(subject), "", - "{}".format(message.encode('utf8')) + "{}".format(message) ] with open(cert, 'rb') as pem: @@ -122,7 +122,7 @@ def mail(recipient=None, message=None, subject=None, cert=None, encrypt=False, msg['From'] = '{} <{}>'.format(from_name, from_address), msg['To'] = recipient - msg.set_payload(message.encode('utf8')) + msg.set_payload(message) msg_to_send = msg.as_bytes() # send message via e-Mail @@ -139,7 +139,7 @@ def mail(recipient=None, message=None, subject=None, cert=None, encrypt=False, raise Exception(err) -def slack(message=None, debug=False): +def slack(message: str = None, debug: bool = False): if debug: print("send slack") print("msg: {}".format(message)) @@ -148,4 +148,3 @@ def slack(message=None, debug=False): if __name__ == "__main__": main() - diff --git a/home.admin/config.scripts/blitz.notify.sh b/home.admin/config.scripts/blitz.notify.sh index 63a00404e..4a3c1041e 100755 --- a/home.admin/config.scripts/blitz.notify.sh +++ b/home.admin/config.scripts/blitz.notify.sh @@ -40,6 +40,14 @@ if ! grep -Eq "^notifyMailHostname=.*" /mnt/hdd/raspiblitz.conf; then echo "notifyMailHostname=$(hostname)" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null fi +if ! grep -Eq "^notifyMailFromAddress=.*" /mnt/hdd/raspiblitz.conf; then + echo "notifyMailFromAddress=rb@example.com" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null +fi + +if ! grep -Eq "^notifyMailFromName=.*" /mnt/hdd/raspiblitz.conf; then + echo "notifyMailFromName=\"RB User\"" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null +fi + if ! grep -Eq "^notifyMailUser=.*" /mnt/hdd/raspiblitz.conf; then echo "notifyMailUser=username" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null fi @@ -72,11 +80,12 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then echo "switching the NOTIFY ON" # install sstmp if not already present - /usr/bin/which ssmtp &>/dev/null - [ $? -eq 0 ] || sudo apt-get install -y ssmtp + if ! command -v ssmtp >/dev/null; then + sudo apt-get install -y ssmtp + fi # install python lib for smime into virtual env - /home/admin/python3-env-lnd/bin/python -m pip install smime + sudo -H /usr/bin/python3 -m pip install smime # write ssmtp config cat << EOF | sudo tee /etc/ssmtp/ssmtp.conf >/dev/null @@ -127,24 +136,22 @@ if [ "$1" = "send" ]; then exit 1 fi - /usr/bin/which ssmtp &>/dev/null - if ! [ $? -eq 0 ]; then + if ! command -v ssmtp >/dev/null; then echo "please run \"on\" first" exit 1 fi - # now parse settings from config and use to send the message if [ "${notifyMethod}" = "ext" ]; then - /home/admin/python3-env-lnd/bin/python3 /home/admin/XXsendNotification.py ext ${notifyExtCmd} "$2" + /usr/bin/python3 /home/admin/XXsendNotification.py ext ${notifyExtCmd} "$2" elif [ "${notifyMethod}" = "mail" ]; then if [ "${notifyMailEncrypt}" = "on" ]; then - /home/admin/python3-env-lnd/bin/python3 /home/admin/XXsendNotification.py mail "${@:3}" --cert ${notifyMailToCert} --encrypt ${notifyMailTo} "$2" + /usr/bin/python3 /home/admin/XXsendNotification.py mail "${@:3}" --from-address "${notifyMailFromAddress}" --from-name "${notifyMailFromName}" --cert "${notifyMailToCert}" --encrypt ${notifyMailTo} "$2" else - /home/admin/python3-env-lnd/bin/python3 /home/admin/XXsendNotification.py mail "${@:3}" ${notifyMailTo} "$2" + /usr/bin/python3 /home/admin/XXsendNotification.py mail "${@:3}" --from-address "${notifyMailFromAddress}" --from-name "${notifyMailFromName}" "${notifyMailTo}" "$2" fi elif [ "${notifyMethod}" = "slack" ]; then - /home/admin/python3-env-lnd/bin/python3 /home/admin/XXsendNotification.py slack -h "$2" + /usr/bin/python3 /home/admin/XXsendNotification.py slack -h "$2" else echo "unknown notification method - check /mnt/hdd/raspiblitz.conf" fi