예제 #1
0
def page_settings():
    check_logged_in()

    current_version = get_current_version()
    latest_version = get_latest_version()
    current_beta_version = get_current_beta_version()
    latest_beta_version = get_latest_beta_version()

    changelog = get_device_changelog()
    serial_number = get_device_serial()
    device_type = get_device_type()
    device_arch = get_device_arch()
    device_ram = get_device_ram()
    product_key = get_product_key()
    pk_skipped = skipped_product_key()
    pk_error = not is_valid_product_key()
    uptime = get_system_uptime()
    date = get_system_date()
    local_ip = get_local_ip()

    # Get QuickSync Rates
    upload_rate = 100
    download_rate = 100
    try:
        upload_rate = subprocess.check_output(
            ["cat", "/mnt/hdd/mynode/settings/quicksync_upload_rate"])
        download_rate = subprocess.check_output([
            "cat",
            "/mnt/hdd/mynode/settings/quicksync_background_download_rate"
        ])
    except:
        upload_rate = 100
        download_rate = 100

    logout_time_days, logout_time_hours = get_flask_session_timeout()

    templateData = {
        "title": "myNode Settings",
        "apps": get_all_applications(order_by="alphabetic"),
        "password_message": "",
        "current_version": current_version,
        "latest_version": latest_version,
        "current_beta_version": current_beta_version,
        "latest_beta_version": latest_beta_version,
        "has_checkin_error": has_checkin_error(),
        "upgrade_error": did_upgrade_fail(),
        "upgrade_log": get_recent_upgrade_log(),
        "upgrade_logs": get_all_upgrade_logs(),
        "serial_number": serial_number,
        "device_type": device_type,
        "device_arch": device_arch,
        "device_ram": device_ram,
        "swap_size": get_swap_size(),
        "product_key": product_key,
        "product_key_skipped": pk_skipped,
        "product_key_error": pk_error,
        "changelog": changelog,
        "is_https_forced": is_https_forced(),
        "logout_time_days": logout_time_days,
        "logout_time_hours": logout_time_hours,
        "using_bitcoin_custom_config": using_bitcoin_custom_config(),
        "using_lnd_custom_config": using_lnd_custom_config(),
        "is_bitcoin_synced": is_bitcoin_synced(),
        "is_installing_docker_images": is_installing_docker_images(),
        "firewall_rules": get_firewall_rules(),
        "is_testnet_enabled": is_testnet_enabled(),
        "is_quicksync_disabled": not is_quicksync_enabled(),
        "netdata_enabled": is_service_enabled("netdata"),
        "is_uploader_device": is_uploader(),
        "download_rate": download_rate,
        "upload_rate": upload_rate,
        "is_btc_lnd_tor_enabled": is_btc_lnd_tor_enabled(),
        "is_aptget_tor_enabled": is_aptget_tor_enabled(),
        "skip_fsck": skip_fsck(),
        "uptime": uptime,
        "date": date,
        "local_ip": local_ip,
        "throttled_data": get_throttled_data(),
        "oom_error": has_oom_error(),
        "oom_info": get_oom_error_info(),
        "drive_usage": get_drive_usage(),
        "cpu_usage": get_cpu_usage(),
        "ram_usage": get_ram_usage(),
        "device_temp": get_device_temp(),
        "ui_settings": read_ui_settings()
    }
    return render_template('settings.html', **templateData)
예제 #2
0
def page_status():
    check_logged_in()
    t1 = get_system_time_in_ms()

    current_version = get_current_version()
    latest_version = get_latest_version()
    current_beta_version = get_current_beta_version()
    latest_beta_version = get_latest_beta_version()

    changelog = get_device_changelog()
    serial_number = get_device_serial()
    device_type = get_device_type()
    device_arch = get_device_arch()
    device_ram = get_device_ram()
    product_key = get_product_key()
    pk_skipped = skipped_product_key()
    pk_error = not is_valid_product_key()
    uptime = get_system_uptime()
    date = get_system_date()
    local_ip = get_local_ip()

    # Get Startup Status
    #startup_status_log = get_journalctl_log("mynode")

    # Get QuickSync Status
    quicksync_enabled = is_quicksync_enabled()
    quicksync_status = "Disabled"
    quicksync_status_color = "gray"
    quicksync_status_log = get_quicksync_log()
    if quicksync_enabled:
        quicksync_status = get_service_status_basic_text("quicksync")
        quicksync_status_color = get_service_status_color("quicksync")

    # Get Bitcoin Status
    # bitcoin_status_log = get_file_log( get_bitcoin_log_file() )
    # GET lnd, loop, pool logs from file???
    #lnd_status_log = get_file_log("/mnt/hdd/mynode/lnd/logs/bitcoin/mainnet/lnd.log")
    #loop_status_log = get_file_log("/mnt/hdd/mynode/loop/logs/mainnet/loopd.log")
    #pool_status_log = get_file_log("/mnt/hdd/mynode/pool/logs/mainnet/poold.log")

    # Get Status
    # lnd_status_log = get_journalctl_log("lnd")
    # loop_status_log = get_journalctl_log("loop")
    # pool_status_log = get_journalctl_log("pool")
    # lndhub_status_log = get_journalctl_log("lndhub")
    # tor_status_log = get_journalctl_log("tor@default")
    # electrs_status_log = get_journalctl_log("electrs")
    # netdata_status_log = get_journalctl_log("netdata")
    # rtl_status_log = get_journalctl_log("rtl")
    # lnbits_status_log = get_journalctl_log("lnbits")
    # thunderhub_status_log = get_journalctl_log("thunderhub")
    # ckbunker_status_log = get_journalctl_log("ckbunker")
    # sphinxrelay_status_log = get_journalctl_log("sphinxrelay")
    # docker_status_log = get_journalctl_log("docker")
    # docker_image_build_status_log = get_journalctl_log("docker_images")

    # Find running containers
    running_containers = get_docker_running_containers()

    templateData = {
        "title": "myNode Status",
        "password_message": "",
        "current_version": current_version,
        "latest_version": latest_version,
        "current_beta_version": current_beta_version,
        "latest_beta_version": latest_beta_version,
        "has_checkin_error": has_checkin_error(),
        "upgrade_error": did_upgrade_fail(),
        "upgrade_logs": get_recent_upgrade_log(),
        "serial_number": serial_number,
        "device_type": device_type,
        "device_arch": device_arch,
        "device_ram": device_ram,
        "product_key": product_key,
        "product_key_skipped": pk_skipped,
        "product_key_error": pk_error,
        "changelog": changelog,
        "lnd_wallet_exists": lnd_wallet_exists(),
        "lnd_ready": is_lnd_ready(),
        "is_installing_docker_images": is_installing_docker_images(),
        "running_containers": running_containers,
        #"startup_status_log": startup_status_log,
        "startup_status": get_service_status_basic_text("mynode"),
        "startup_status_color": get_service_status_color("mynode"),
        "is_quicksync_enabled": is_quicksync_enabled(),
        #"quicksync_status_log": quicksync_status_log,
        "quicksync_status": quicksync_status,
        "quicksync_status_color": quicksync_status_color,
        "is_bitcoin_synced": is_bitcoin_synced(),
        #"bitcoin_status_log": bitcoin_status_log,
        "bitcoin_status": get_service_status_basic_text("bitcoin"),
        "bitcoin_status_color": get_service_status_color("bitcoin"),
        #"lnd_status_log": lnd_status_log,
        "lnd_status": get_service_status_basic_text("lnd"),
        "lnd_status_color": get_service_status_color("lnd"),
        #"loop_status_log": loop_status_log,
        "loop_status": get_service_status_basic_text("loop"),
        "loop_status_color": get_service_status_color("loop"),
        #"pool_status_log": pool_status_log,
        "pool_status": get_service_status_basic_text("pool"),
        "pool_status_color": get_service_status_color("pool"),
        #"lit_status_log": get_journalctl_log("lit"),
        "lit_status": get_service_status_basic_text("lit"),
        "lit_status_color": get_service_status_color("lit"),
        #"tor_status_log": tor_status_log,
        "tor_status": get_service_status_basic_text("tor@default"),
        "tor_status_color": get_service_status_color("tor@default"),
        #"lndhub_status_log": lndhub_status_log,
        "lndhub_status": get_service_status_basic_text("lndhub"),
        "lndhub_status_color": get_service_status_color("lndhub"),
        #"netdata_status_log": netdata_status_log,
        "netdata_status": get_service_status_basic_text("netdata"),
        "netdata_status_color": get_service_status_color("netdata"),
        #"electrs_status_log": electrs_status_log,
        "electrs_status": get_service_status_basic_text("electrs"),
        "electrs_status_color": get_service_status_color("electrs"),
        #"rtl_status_log": rtl_status_log,
        "rtl_status": get_service_status_basic_text("rtl"),
        "rtl_status_color": get_service_status_color("rtl"),
        #"lnbits_status_log": lnbits_status_log,
        "lnbits_status": get_service_status_basic_text("lnbits"),
        "lnbits_status_color": get_service_status_color("lnbits"),
        #"thunderhub_status_log": thunderhub_status_log,
        "thunderhub_status": get_service_status_basic_text("thunderhub"),
        "thunderhub_status_color": get_service_status_color("thunderhub"),
        #"ckbunker_status_log": ckbunker_status_log,
        "ckbunker_status": get_service_status_basic_text("ckbunker"),
        "ckbunker_status_color": get_service_status_color("ckbunker"),
        #"sphinxrelay_status_log": sphinxrelay_status_log,
        "sphinxrelay_status": get_service_status_basic_text("sphinxrelay"),
        "sphinxrelay_status_color": get_service_status_color("sphinxrelay"),
        #"docker_status_log": docker_status_log,
        "docker_status": get_service_status_basic_text("docker"),
        "docker_status_color": get_service_status_color("docker"),
        #"docker_image_build_status_log": docker_image_build_status_log,
        "docker_image_build_status": get_docker_image_build_status(),
        "docker_image_build_status_color":
        get_docker_image_build_status_color(),
        #"whirlpool_status_log": get_journalctl_log("whirlpool"),
        "whirlpool_status": get_service_status_basic_text("whirlpool"),
        "whirlpool_status_color": get_service_status_color("whirlpool"),
        #"dojo_status_log": get_journalctl_log("dojo"),
        "dojo_status": get_service_status_basic_text("dojo"),
        "dojo_status_color": get_service_status_color("dojo"),
        #"btcpayserver_status_log": get_journalctl_log("btcpayserver"),
        "btcpayserver_status": get_service_status_basic_text("btcpayserver"),
        "btcpayserver_status_color": get_service_status_color("btcpayserver"),
        #"mempool_status_log": get_journalctl_log("mempool"),
        "mempool_status": get_service_status_basic_text("mempool"),
        "mempool_status_color": get_service_status_color("mempool"),
        #"caravan_status_log": get_journalctl_log("caravan"),
        "caravan_status": get_service_status_basic_text("caravan"),
        "caravan_status_color": get_service_status_color("caravan"),
        #"specter_status_log": get_journalctl_log("specter"),
        "specter_status": get_service_status_basic_text("specter"),
        "specter_status_color": get_service_status_color("specter"),
        #"nginx_status_log": get_journalctl_log("nginx"),
        "nginx_status": get_service_status_basic_text("nginx"),
        "nginx_status_color": get_service_status_color("nginx"),
        #"www_status_log": get_journalctl_log("www"),
        "www_status": get_service_status_basic_text("www"),
        "www_status_color": get_service_status_color("www"),
        #"ufw_status_log": get_journalctl_log("ufw"),
        "ufw_status": get_service_status_basic_text("ufw"),
        "ufw_status_color": get_service_status_color("ufw"),
        "firewall_rules": get_firewall_rules(),
        "is_quicksync_disabled": not quicksync_enabled,
        "netdata_enabled": is_service_enabled("netdata"),
        "uptime": uptime,
        "date": date,
        "local_ip": local_ip,
        "throttled_data": get_throttled_data(),
        "oom_error": has_oom_error(),
        "oom_info": get_oom_error_info(),
        "drive_usage": get_drive_usage(),
        "cpu_usage": get_cpu_usage(),
        "ram_usage": get_ram_usage(),
        "device_temp": get_device_temp(),
        "ui_settings": read_ui_settings()
    }
    t2 = get_system_time_in_ms()
    templateData["load_time"] = t2 - t1
    return render_template('status.html', **templateData)