mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-04-12 05:39:22 +02:00
Merge branch 'v1.6' of https://github.com/rootzoll/raspiblitz into v1.6
This commit is contained in:
commit
78a5e9107d
@ -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()
|
||||
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
@ -198,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': ''
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user