2019-12-28 13:27:32 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import signal
|
|
|
|
import sys
|
|
|
|
from argparse import RawTextHelpFormatter
|
|
|
|
from configparser import ConfigParser, DEFAULTSECT
|
2020-05-23 15:59:58 +01:00
|
|
|
from blitzpy import RaspiBlitzConfig, RaspiBlitzInfo
|
2019-12-28 13:27:32 +00:00
|
|
|
|
2019-12-28 14:25:38 +00:00
|
|
|
LND_CONF = "/mnt/hdd/lnd/lnd.conf"
|
2019-12-28 13:27:32 +00:00
|
|
|
RB_CONF = "/mnt/hdd/raspiblitz.conf"
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
# make sure CTRL+C works
|
|
|
|
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
|
|
|
|
|
|
|
description = """RaspiBlitz Config Check"""
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description=description, formatter_class=RawTextHelpFormatter)
|
|
|
|
parser.add_argument("-V", "--version",
|
|
|
|
help="print version", action="version",
|
|
|
|
version="0.1")
|
|
|
|
|
|
|
|
parser.add_argument("-p", "--print",
|
|
|
|
help="print parsed config", action="store_true")
|
|
|
|
|
2019-12-29 11:55:05 +01:00
|
|
|
parser.add_argument("-q", "--quiet",
|
|
|
|
help="suppress normal output", action="store_true")
|
|
|
|
|
|
|
|
|
2019-12-28 13:27:32 +00:00
|
|
|
# parse args
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
# Raspi Config
|
|
|
|
rb_cfg_valid = False
|
|
|
|
|
|
|
|
rb_cfg = RaspiBlitzConfig()
|
|
|
|
if os.path.exists(rb_cfg.abs_path):
|
|
|
|
try:
|
|
|
|
rb_cfg.reload()
|
|
|
|
|
|
|
|
rb_cfg_valid = True
|
2019-12-29 11:55:05 +01:00
|
|
|
if not args.quiet:
|
|
|
|
print("RaspiBlitz Config: \tOK")
|
2019-12-28 13:27:32 +00:00
|
|
|
except Exception as err:
|
2019-12-29 11:55:05 +01:00
|
|
|
if not args.quiet:
|
|
|
|
print("RaspiBlitz Config: \tERROR")
|
|
|
|
log.warning(err)
|
2020-02-20 13:24:57 +01:00
|
|
|
print("# Use command to fix: nano /mnt/hdd/raspiblitz.conf")
|
|
|
|
print("# CTRL+o to save / CRTL+x to exit / then reboot")
|
2019-12-28 13:27:32 +00:00
|
|
|
|
|
|
|
else:
|
2019-12-29 11:55:05 +01:00
|
|
|
if not args.quiet:
|
|
|
|
print("RaspiBlitz Config: \tMISSING")
|
2019-12-28 13:27:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Raspi Info
|
|
|
|
rb_info_valid = False
|
|
|
|
|
|
|
|
rb_info = RaspiBlitzInfo()
|
|
|
|
if os.path.exists(rb_info.abs_path):
|
|
|
|
try:
|
|
|
|
rb_info.reload()
|
|
|
|
|
|
|
|
rb_info_valid = True
|
2019-12-29 11:55:05 +01:00
|
|
|
if not args.quiet:
|
|
|
|
print("RaspiBlitz Info: \tOK")
|
2019-12-28 13:27:32 +00:00
|
|
|
except Exception as err:
|
2019-12-29 11:55:05 +01:00
|
|
|
if not args.quiet:
|
|
|
|
print("RaspiBlitz Info: \tERROR")
|
|
|
|
log.warning(err)
|
|
|
|
|
2019-12-28 13:27:32 +00:00
|
|
|
else:
|
2019-12-29 11:55:05 +01:00
|
|
|
if not args.quiet:
|
|
|
|
print("RaspiBlitz Info: \tMISSING")
|
2019-12-28 13:27:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
if args.print:
|
2019-12-29 11:55:05 +01:00
|
|
|
print("====================\n= RaspiBlitzConfig =\n====================")
|
2019-12-28 13:27:32 +00:00
|
|
|
if rb_cfg_valid:
|
|
|
|
print("auto_nat_discovery: \t\t{}".format(rb_cfg.auto_nat_discovery))
|
|
|
|
print("auto_pilot: \t\t\t{}".format(rb_cfg.auto_pilot))
|
|
|
|
print("auto_unlock: \t\t\t{}".format(rb_cfg.auto_unlock))
|
|
|
|
print("chain: \t\t\t\t{}".format(rb_cfg.chain))
|
|
|
|
print("dynDomain: \t\t\t{}".format(rb_cfg.dynDomain))
|
|
|
|
print("dyn_update_url: \t\t{}".format(rb_cfg.dyn_update_url))
|
|
|
|
print("hostname: \t\t\t{}".format(rb_cfg.hostname))
|
|
|
|
print("invoice_allow_donations: \t{}".format(rb_cfg.invoice_allow_donations))
|
|
|
|
print("invoice_default_amount: \t{}".format(rb_cfg.invoice_default_amount))
|
|
|
|
print("lcd_rotate: \t\t\t{}".format(rb_cfg.lcd_rotate))
|
|
|
|
print("lnd_address: \t\t\t{}".format(rb_cfg.lnd_address))
|
|
|
|
print("lnd_port: \t\t\t{}".format(rb_cfg.lnd_port))
|
|
|
|
print("network: \t\t\t{}".format(rb_cfg.network))
|
|
|
|
print("public_ip: \t\t\t{}".format(rb_cfg.public_ip))
|
|
|
|
print("rtl_web_interface: \t\t{}".format(rb_cfg.rtl_web_interface))
|
|
|
|
print("run_behind_tor: \t\t{}".format(rb_cfg.run_behind_tor))
|
|
|
|
print("ssh_tunnel: \t\t\t{}".format(rb_cfg.ssh_tunnel))
|
|
|
|
print("touchscreen: \t\t\t{}".format(rb_cfg.touchscreen))
|
|
|
|
print("version: \t\t\t{}".format(rb_cfg.version))
|
|
|
|
print("")
|
2019-12-29 11:55:05 +01:00
|
|
|
else:
|
|
|
|
print("invalid or missing")
|
|
|
|
print("")
|
|
|
|
|
2019-12-28 13:27:32 +00:00
|
|
|
|
2019-12-29 11:55:05 +01:00
|
|
|
print("==================\n= RaspiBlitzInfo =\n==================")
|
2019-12-28 13:27:32 +00:00
|
|
|
if rb_info_valid:
|
|
|
|
print("state: \t\t{}".format(rb_info.state))
|
|
|
|
print("")
|
2019-12-29 11:55:05 +01:00
|
|
|
else:
|
|
|
|
print("invalid or missing")
|
|
|
|
print("")
|
|
|
|
|
2019-12-28 13:27:32 +00:00
|
|
|
|
|
|
|
if rb_cfg_valid:
|
|
|
|
sys.exit(0)
|
|
|
|
else:
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|
|
|
|
|