From 0ec4313c85665f2907c1803cd63ae876df38e628 Mon Sep 17 00:00:00 2001 From: Ravin Perera <33562092+ravinsp@users.noreply.github.com> Date: Fri, 29 Apr 2022 08:34:43 +0530 Subject: [PATCH] UX improvements to installer and message board. (#131) - Changed y/n pattern of setup questions. - Registry address display during install. - Improve evernode status output. - Include config files in 'evernode log' output. - Fixed issue with country code detection on dns addresses. - Added space character validity check for dns address. --- installer/sashimono-install.sh | 3 +- installer/setup.sh | 53 ++++++++++++++++++++++++---------- mb-xrpl/lib/setup.js | 13 ++++----- src/main.cpp | 1 + 4 files changed, 47 insertions(+), 23 deletions(-) diff --git a/installer/sashimono-install.sh b/installer/sashimono-install.sh index 4573e18..c1daf3e 100755 --- a/installer/sashimono-install.sh +++ b/installer/sashimono-install.sh @@ -77,13 +77,14 @@ if [ "$NO_MB" == "" ]; then # Generate beta host account (if not already setup). if ! sudo -u $MB_XRPL_USER MB_DATA_DIR=$MB_XRPL_DATA node $MB_XRPL_BIN reginfo basic >/dev/null 2>&1; then stage "Configuring host xrpl account" + echo "Using registry: $EVERNODE_REGISTRY_ADDRESS" ! sudo -u $MB_XRPL_USER MB_DATA_DIR=$MB_XRPL_DATA node $MB_XRPL_BIN betagen $EVERNODE_REGISTRY_ADDRESS $inetaddr $lease_amount && echo "XRPLACC_FAILURE" && rollback doreg=1 fi # Register the host on Evernode. if [ ! -z $doreg ] || ! sudo -u $MB_XRPL_USER MB_DATA_DIR=$MB_XRPL_DATA node $MB_XRPL_BIN reginfo >/dev/null 2>&1; then - stage "Registering host on Evernode" + stage "Registering host on Evernode registry $EVERNODE_REGISTRY_ADDRESS" set -o pipefail # We need register operation exit code to detect failures (ignore the sed pipe exit code). # Append STAGE prefix to the lease offer creation logs, So they would get fetched from setup as stage logs. # Add -p to the progress logs so they would be printed overwriting the same line. diff --git a/installer/setup.sh b/installer/setup.sh index b38ac51..cdf1400 100755 --- a/installer/setup.sh +++ b/installer/setup.sh @@ -34,7 +34,7 @@ export MB_XRPL_USER="sashimbxrpl" export DOCKER_REGISTRY_USER="sashidockerreg" export DOCKER_REGISTRY_PORT=4444 export CG_SUFFIX="-cg" -export EVERNODE_REGISTRY_ADDRESS="rPmxne3NGeBJ5YY97tshCop2WVoS43bMez" +export EVERNODE_REGISTRY_ADDRESS="rDsg8R6MYfEB7Da861ThTRzVUWBa3xJgWL" # Configuring the sashimono service is the last stage of the installation. # So if the service exists, Previous sashimono installation has been complete. @@ -67,9 +67,13 @@ if ! $sashimono_installed ; then && exit 1 fi else - [ "$1" != "uninstall" ] && [ "$1" != "status" ] && [ "$1" != "list" ] && [ "$1" != "update" ] && [ "$1" != "log" ] \ + [ "$1" == "install" ] \ + && echo "$evernode is already installed on your host. Use the 'evernode' command to manage your host." \ + && exit 1 + + [ "$1" != "install" ] && [ "$1" != "uninstall" ] && [ "$1" != "status" ] && [ "$1" != "list" ] && [ "$1" != "update" ] && [ "$1" != "log" ] \ && echomult "$evernode host management tool - \nYour system is registered on $evernode. + \nYour host is registered on $evernode. \nSupported commands: \nstatus - View $evernode registration info \nlist - View contract instances running on this system @@ -140,7 +144,7 @@ function check_sys_req() { function resolve_ip_addr() { # Attempt to resolve ip (in case inetaddr is a DNS address) # This will resolve correctly if inetaddr is a valid ip or dns address. - ipaddr=$(getent hosts $inetaddr | head -1 | awk '{ print $1 }') + local ipaddr=$(getent hosts $inetaddr | head -1 | awk '{ print $1 }') # If invalid, reset inetaddr and return with non-zero code. if [ -z "$ipaddr" ] ; then @@ -149,8 +153,14 @@ function resolve_ip_addr() { fi } -function check_ip_or_dns_empty() { - [ -z "$inetaddr" ] && return 1 || return 0 +function check_inet_addr_validity() { + # inert address cannot be empty and cannot contain spaces. + if [ -z "$inetaddr" ] || [[ $inetaddr = *" "* ]] ; then + inetaddr="" + return 1 + else + return 0 + fi } function set_inet_addr() { @@ -161,20 +171,20 @@ function set_inet_addr() { if $interactive ; then - if [ -n "$inetaddr" ] && ! confirm "Detected ip address '$inetaddr'. This will be used to reach contract instances running - on your host. \n\nDo you want to specify a different IP or DNS address?" ; then + if [ -n "$inetaddr" ] && confirm "Detected ip address '$inetaddr'. This needs to be publicly reachable over + internet. \n\nIs this the IP/DNS address you want to use?" ; then return 0 fi inetaddr="" while [ -z "$inetaddr" ]; do # This will be asked if auto-detection fails or if user wants to specify manually. - read -p "Please specify the IP or DNS address your server is reachable at: " inetaddr 0" |bc -l) )) && echo -e "Using lease amount $lease_amount EVRs.\n" || echo -e "Using purchaser service target price as lease amount.\n" + (( $(echo "$lease_amount > 0" |bc -l) )) && echo -e "Using lease amount $lease_amount EVRs.\n" || echo -e "Using anchor tenant target price as lease amount.\n" echo "Starting installation..." install_evernode 0 diff --git a/mb-xrpl/lib/setup.js b/mb-xrpl/lib/setup.js index 1e3b956..d55830f 100644 --- a/mb-xrpl/lib/setup.js +++ b/mb-xrpl/lib/setup.js @@ -186,22 +186,21 @@ class Setup { try { const hostClient = new evernode.HostClient(acc.address, acc.secret); await hostClient.connect(); - console.log('Retrieving EVR balance...'); - const evrBalance = await hostClient.getEVRBalance(); - console.log(`EVR balance: ${evrBalance}`); - console.log('Retrieving reg info...'); - const hostInfo = await hostClient.getRegistration(); + + const [evrBalance, hostInfo] = await Promise.all([hostClient.getEVRBalance(), hostClient.getRegistration()]); if (hostInfo) { - console.log(`NFT: ${hostInfo.nfTokenId}`); + console.log(`Registration NFT: ${hostInfo.nfTokenId}`); } else { await hostClient.disconnect(); throw 'Host is not registered'; } + console.log(`EVR balance: ${evrBalance}`); + await hostClient.disconnect(); } catch { - throw 'EVR balance: [Error occured when retrieving EVR balance]'; + throw 'Error occured when retrieving account info.'; } } } diff --git a/src/main.cpp b/src/main.cpp index 87481f9..8255a18 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -142,6 +142,7 @@ int main(int argc, char **argv) conf::create(host_addr, "", inst_count, cpu_us, ram_kbytes, swap_kbytes, disk_kbytes) != 0) { std::cerr << "Invalid Sashimono Agent config creation args.\n"; + std::cerr << inst_count << ", " << cpu_us << ", " << ram_kbytes << ", " << swap_kbytes << ", " << disk_kbytes << "\n"; return 1; } }