From e1195e6f3e0435a43882641a343cd97216854a78 Mon Sep 17 00:00:00 2001 From: Benjamin Canou Date: Fri, 29 Jun 2018 17:00:04 +0200 Subject: [PATCH] Client: use TEZOS_CLIENT_UNSAFE_DISABLE_DISCLAIMER=Y to disable the banner --- src/bin_client/main_client.ml | 130 +++++++++++++++------------- src/bin_client/test/test_lib.inc.sh | 2 + 2 files changed, 71 insertions(+), 61 deletions(-) diff --git a/src/bin_client/main_client.ml b/src/bin_client/main_client.ml index 0a19d64e3..57e73cca4 100644 --- a/src/bin_client/main_client.ml +++ b/src/bin_client/main_client.ml @@ -9,68 +9,76 @@ open Client_config +let disable_disclaimer = + match Sys.getenv_opt "TEZOS_CLIENT_UNSAFE_DISABLE_DISCLAIMER" with + | Some ("yes" | "y" | "YES" | "Y") -> true + | _ -> false + let display_warning_banner ctxt = - let default () = - Format.eprintf - "@[@{@{Warning@}@}@,@,\ - \ This is @{<warning>NOT@} the Tezos Mainnet.@,\ - \ The Tezos Mainnet is not yet released.@,\ - @,\ - \ Use your fundraiser keys @{<warning>AT YOUR OWN RISK@}.@,\ - All transactions happening on the Betanet @{<warning>are expected to be valid in the Mainnet@}.@,\ - \ In doubt, we recommend that you wait for the lunch of the Mainnet.@]@\n@." ; - Lwt.return_unit in - Shell_services.P2p.versions ctxt >>= function - | Error _ -> default () - | Ok versions -> - match String.split_on_char '_' (List.hd versions).name with - | "TEZOS" :: "ZERONET" :: _date :: [] -> - Format.eprintf - "@[<v 2>@{<warning>@{<title>Warning@}@}@,@,\ - \ This is @{<warning>NOT@} the Tezos Mainnet.@,\ - \ The Tezos Mainnet is not yet released.@,\ - @,\ - \ The node you are connecting to claims to be running on the@,\ - \ @{<warning>Tezos Zeronet DEVELOPMENT NETWORK@}.@,\ - \ Do @{<warning>NOT@} use your fundraiser keys on this network.@,\ - Zeronet is a testing network, with free tokens and frequent resets.@]@\n@." ; - Lwt.return_unit - | "TEZOS" :: "ALPHANET" :: _date :: [] -> - Format.eprintf - "@[<v 2>@{<warning>@{<title>Warning@}@}@,@,\ - \ This is @{<warning>NOT@} the Tezos Mainnet.@,\ - \ The Tezos Mainnet is not yet released.@,\ - @,\ - \ The node you are connecting to claims to be running on the@,\ - \ @{<warning>Tezos Alphanet DEVELOPMENT NETWORK.@}@,\ - \ Do @{<warning>NOT@} use your fundraiser keys on this network.@,\ - \ Alphanet is a testing network, with free tokens.@]@\n@." ; - Lwt.return_unit - | "TEZOS" :: "BETANET" :: _date :: [] -> - Format.eprintf - "@[<v 2>@{<warning>@{<title>Warning@}@}@,@,\ - \ This is @{<warning>NOT@} the Tezos Mainnet.@,\ - \ The Tezos Mainnet is not yet released.@,\ - @,\ - \ The node you are connecting to claims to be running on the@,\ - \ @{<warning>Tezos Betanet EXPERIMENTAL NETWORK@}.@,\ - \ Betanet is a pre-release experimental network and comes with no warranty.@,\ - \ Use your fundraiser keys on this network @{<warning>AT YOUR OWN RISK@}.@,\ - \ All transactions happening on the Betanet @{<warning>are expected to be valid in the Mainnet@}.@,\ - \ If in doubt, we recommend that you wait for the Mainnet lunch.@]@\n@." ; - Lwt.return_unit - | "TEZOS" :: _date :: [] -> - Format.eprintf - "@[<v 2>@{<warning>@{<title>Warning@}@}@,@,\ - \ This is @{<warning>NOT@} the Tezos Mainnet.@,\ - \ The Tezos Mainnet is not yet released.@,\ - @,\ - \ The node you are connecting to claims to be running in a@,\ - \ @{<warning>Tezos TEST SANDBOX@}.@,\ - \ Do @{<warning>NOT@} use your fundraiser keys on this network.@,\ - You should not see this message if you are not a developer.@]@\n@." ; - Lwt.return_unit - | _ -> default () + if disable_disclaimer then + Lwt.return () + else + let default () = + Format.eprintf + "@[<v 2>@{<warning>@{<title>Warning@}@}@,@,\ + \ This is @{<warning>NOT@} the Tezos Mainnet.@,\ + \ The Tezos Mainnet is not yet released.@,\ + @,\ + \ Use your fundraiser keys @{<warning>AT YOUR OWN RISK@}.@,\ + All transactions happening on the Betanet @{<warning>are expected to be valid in the Mainnet@}.@,\ + \ In doubt, we recommend that you wait for the lunch of the Mainnet.@]@\n@." ; + Lwt.return_unit in + Shell_services.P2p.versions ctxt >>= function + | Error _ -> default () + | Ok versions -> + match String.split_on_char '_' (List.hd versions).name with + | "TEZOS" :: "ZERONET" :: _date :: [] -> + Format.eprintf + "@[<v 2>@{<warning>@{<title>Warning@}@}@,@,\ + \ This is @{<warning>NOT@} the Tezos Mainnet.@,\ + \ The Tezos Mainnet is not yet released.@,\ + @,\ + \ The node you are connecting to claims to be running on the@,\ + \ @{<warning>Tezos Zeronet DEVELOPMENT NETWORK@}.@,\ + \ Do @{<warning>NOT@} use your fundraiser keys on this network.@,\ + Zeronet is a testing network, with free tokens and frequent resets.@]@\n@." ; + Lwt.return_unit + | "TEZOS" :: "ALPHANET" :: _date :: [] -> + Format.eprintf + "@[<v 2>@{<warning>@{<title>Warning@}@}@,@,\ + \ This is @{<warning>NOT@} the Tezos Mainnet.@,\ + \ The Tezos Mainnet is not yet released.@,\ + @,\ + \ The node you are connecting to claims to be running on the@,\ + \ @{<warning>Tezos Alphanet DEVELOPMENT NETWORK.@}@,\ + \ Do @{<warning>NOT@} use your fundraiser keys on this network.@,\ + \ Alphanet is a testing network, with free tokens.@]@\n@." ; + Lwt.return_unit + | "TEZOS" :: "BETANET" :: _date :: [] -> + Format.eprintf + "@[<v 2>@{<warning>@{<title>Warning@}@}@,@,\ + \ This is @{<warning>NOT@} the Tezos Mainnet.@,\ + \ The Tezos Mainnet is not yet released.@,\ + @,\ + \ The node you are connecting to claims to be running on the@,\ + \ @{<warning>Tezos Betanet EXPERIMENTAL NETWORK@}.@,\ + \ Betanet is a pre-release experimental network and comes with no warranty.@,\ + \ Use your fundraiser keys on this network @{<warning>AT YOUR OWN RISK@}.@,\ + \ All transactions happening on the Betanet @{<warning>are expected to be valid in the Mainnet@}.@,\ + \ If in doubt, we recommend that you wait for the Mainnet lunch.@]@\n@." ; + Lwt.return_unit + | "TEZOS" :: _date :: [] -> + Format.eprintf + "@[<v 2>@{<warning>@{<title>Warning@}@}@,@,\ + \ This is @{<warning>NOT@} the Tezos Mainnet.@,\ + \ The Tezos Mainnet is not yet released.@,\ + @,\ + \ The node you are connecting to claims to be running in a@,\ + \ @{<warning>Tezos TEST SANDBOX@}.@,\ + \ Do @{<warning>NOT@} use your fundraiser keys on this network.@,\ + You should not see this message if you are not a developer.@]@\n@." ; + Lwt.return_unit + | _ -> default () let get_commands_for_version ctxt block protocol = Shell_services.Blocks.protocols ctxt ~block () >>= function diff --git a/src/bin_client/test/test_lib.inc.sh b/src/bin_client/test/test_lib.inc.sh index eb28d2bb3..e1f20362b 100755 --- a/src/bin_client/test/test_lib.inc.sh +++ b/src/bin_client/test/test_lib.inc.sh @@ -7,6 +7,8 @@ cd "$test_dir" sandbox_file="$test_dir/sandbox.json" parameters_file="$test_dir/protocol_parameters.json" +export TEZOS_CLIENT_UNSAFE_DISABLE_DISCLAIMER=Y + tezos_sandboxed_node="${1:-$test_dir/../../bin_node/tezos-sandboxed-node.sh}" local_node="${2:-$test_dir/../../../_build/default/src/bin_node/main.exe}" tezos_init_sandboxed_client="${3:-$test_dir/../../bin_client/tezos-init-sandboxed-client.sh}"