Ejemplo n.º 1
0
def setup(args):
    release = latest_release()

    if args.nodetype == "archivenode":
        Helpers.archivenode_deprecate_message()

    composefileurl = os.getenv(
        COMPOSE_FILE_OVERIDE,
        f"https://raw.githubusercontent.com/radixdlt/node-runner/{cli_version()}/node-runner-cli/release_ymls/radix-{args.nodetype}-compose.yml"
    )
    print(
        f"Going to setup node type {args.nodetype} from location {composefileurl}.\n"
    )
    # TODO autoapprove
    continue_setup = input("Do you want to continue [Y/n]?:")

    if not Helpers.check_Yes(continue_setup):
        print(" Quitting ....")
        sys.exit()

    keystore_password, file_location = Base.generatekey(
        keyfile_path=Helpers.get_keyfile_path(), keygen_tag=release)
    Docker.setup_compose_file(composefileurl, file_location,
                              args.enabletransactions)

    trustednode_ip = Helpers.parse_trustednode(args.trustednode)

    compose_file_name = composefileurl.rsplit('/', 1)[-1]
    action = "update" if args.update else "start"
    print(
        f"About to {action} the node using docker-compose file {compose_file_name}, which is as below"
    )
    run_shell_command(f"cat {compose_file_name}", shell=True)
    # TODO AutoApprove
    should_start = input(f"\nOkay to start the node [Y/n]?:")
    if Helpers.check_Yes(should_start):
        if action == "update":
            print(
                f"For update, bringing down the node using compose file {compose_file_name}"
            )
            Docker.run_docker_compose_down(compose_file_name)
        Docker.run_docker_compose_up(keystore_password, compose_file_name,
                                     args.trustednode)
    else:
        print(f"""
            ---------------------------------------------------------------
            Bring up node by updating the file {compose_file_name}
            You can do it through cli using below command
                radixnode docker stop  -f {compose_file_name}
                radixnode docker start -f {compose_file_name} -t {args.trustednode}
            ----------------------------------------------------------------
            """)
Ejemplo n.º 2
0
def setup(args):
    if not args.release:
        release = latest_release()
    else:
        release = args.release

    if not args.nginxrelease:
        nginx_release = latest_release("radixdlt/radixdlt-nginx")
    else:
        nginx_release = args.nginxrelease

    if args.nodetype == "archivenode":
        Helpers.archivenode_deprecate_message()
    node_type_name = 'fullnode'
    node_dir = '/etc/radixdlt/node'
    nginx_dir = '/etc/nginx'
    nginx_secrets_dir = f"{nginx_dir}/secrets"
    node_secrets_dir = f"{node_dir}/secrets"
    nodebinaryUrl = os.getenv(
        NODE_BINARY_OVERIDE,
        f"https://github.com/radixdlt/radixdlt/releases/download/{release}/radixdlt-dist-{release}.zip"
    )

    # TODO add method to fetch latest nginx release
    nginxconfigUrl = os.getenv(
        NGINX_BINARY_OVERIDE,
        f"https://github.com/radixdlt/radixdlt-nginx/releases/download/{nginx_release}/radixdlt-nginx-{node_type_name}-conf.zip"
    )
    # TODO AutoApprove
    continue_setup = input(
        f"Going to setup node type {args.nodetype} for version {release} from location {nodebinaryUrl} and {nginxconfigUrl}. \n Do you want to continue Y/n:"
    )

    if not Helpers.check_Yes(continue_setup):
        print(" Quitting ....")
        sys.exit()

    backup_time = Helpers.get_current_date_time()
    SystemD.checkUser()
    keystore_password, keyfile_location = SystemD.generatekey(
        node_secrets_dir, keygen_tag=release)
    trustednode_ip = Helpers.parse_trustednode(args.trustednode)

    SystemD.backup_file(node_secrets_dir, f"environment", backup_time)
    SystemD.set_environment_variables(keystore_password, node_secrets_dir)

    SystemD.backup_file(node_dir, f"default.config", backup_time)

    SystemD.setup_default_config(trustednode=args.trustednode,
                                 hostip=args.hostip,
                                 node_dir=node_dir,
                                 node_type=args.nodetype,
                                 transactions_enable=args.enabletransactions)

    node_version = nodebinaryUrl.rsplit('/', 2)[-2]
    SystemD.backup_file("/etc/systemd/system", "radixdlt-node.service",
                        backup_time)
    SystemD.setup_service_file(node_version,
                               node_dir=node_dir,
                               node_secrets_path=node_secrets_dir)

    SystemD.download_binaries(nodebinaryUrl,
                              node_dir=node_dir,
                              node_version=node_version)

    SystemD.backup_file("/lib/systemd/system", f"nginx.service", backup_time)

    nginx_configured = SystemD.setup_nginx_config(
        nginx_config_location_Url=nginxconfigUrl,
        node_type=args.nodetype,
        nginx_etc_dir=nginx_dir,
        backup_time=backup_time)
    SystemD.create_ssl_certs(nginx_secrets_dir)
    if not args.update:
        SystemD.start_node_service()
    else:
        SystemD.restart_node_service()

    if nginx_configured and not args.update:
        SystemD.start_nginx_service()
    elif nginx_configured and args.update:
        SystemD.start_nginx_service()
    else:
        print("Nginx not configured or not updated")