diff --git a/installer/sashimono-install.sh b/installer/sashimono-install.sh index 71e007e..26051ba 100755 --- a/installer/sashimono-install.sh +++ b/installer/sashimono-install.sh @@ -459,8 +459,6 @@ mkdir -p $SASHIMONO_DATA cp "$script_dir"/sashimono-uninstall.sh $SASHIMONO_BIN chmod +x $SASHIMONO_BIN/sashimono-uninstall.sh -# Setting up Sashimono admin group. -! grep -q $SASHIADMIN_GROUP /etc/group && ! groupadd $SASHIADMIN_GROUP && echo "$SASHIADMIN_GROUP group creation failed." && abort ! set_cpu_info && echo "Fetching CPU info failed" && abort diff --git a/installer/setup.sh b/installer/setup.sh index ace7879..3b02a2d 100755 --- a/installer/setup.sh +++ b/installer/setup.sh @@ -96,6 +96,7 @@ export MIN_OPERATIONAL_COST_PER_MONTH=5 # 3 Month minimum operational duration is considered. export MIN_OPERATIONAL_DURATION=3 + export MIN_REPUTATION_COST_PER_MONTH=7 #export NETWORK="${NETWORK:-mainnet}" export NETWORK="${NETWORK:-devnet}" @@ -1427,7 +1428,7 @@ WantedBy=timers.target" >/etc/systemd/system/$EVERNODE_AUTO_UPDATE_SERVICE.timer ! mkdir -p $REPUTATIOND_DATA && echo "Could not create '$REPUTATIOND_DATA'. Make sure you are running as sudo." && exit 1 # Change ownership to reputationd user. chown -R "$REPUTATIOND_USER":"$REPUTATIOND_USER" $REPUTATIOND_DATA - ! confirm "\nWould you like to opt-in to the Evernode reputation and reward system?" && echomult "Cancelled from opting-in Evernode reputation and reward system.\nYou can opt-in later by using \'evernode reputationd\' command" && exit 0 + ! confirm "\nWould you like to opt-in to the Evernode reputation and reward system?" && echomult "Cancelled from opting-in Evernode reputation and reward system.\nYou can opt-in later by using 'evernode reputationd' command" && exit 0 configure_reputationd_system if [ ! $? -eq 0 ]; then @@ -2010,15 +2011,6 @@ WantedBy=timers.target" >/etc/systemd/system/$EVERNODE_AUTO_UPDATE_SERVICE.timer return 1; fi - #new, wait-for-funds, prepare, wait-for-funds wait_call - ! sudo -u $REPUTATIOND_USER REPUTATIOND_DATA_DIR=$REPUTATIOND_DATA node $REPUTATIOND_BIN new $reputationd_xrpl_address $reputationd_key_file_path && echo "error creating configs" && exit 1 - - ! sudo -u $REPUTATIOND_USER REPUTATIOND_DATA_DIR=$REPUTATIOND_DATA node $REPUTATIOND_BIN wait-for-funds NATIVE 50 && echo "error retrieving funds" && exit 1 - - ! sudo -u $REPUTATIOND_USER REPUTATIOND_DATA_DIR=$REPUTATIOND_DATA node $REPUTATIOND_BIN prepare && echo "error preparing account" && exit 1 - - ! sudo -u $REPUTATIOND_USER REPUTATIOND_DATA_DIR=$REPUTATIOND_DATA node $REPUTATIOND_BIN wait-for-funds NATIVE 50 && echo "'error retrieving funds" && exit 1 - reputationd_user_dir=/home/"$REPUTATIOND_USER" reputationd_user_id=$(id -u "$REPUTATIOND_USER") reputationd_user_runtime_dir="/run/user/$reputationd_user_id" @@ -2027,6 +2019,42 @@ WantedBy=timers.target" >/etc/systemd/system/$EVERNODE_AUTO_UPDATE_SERVICE.timer # NOTE : There can be user id mismatch, as we do not delete REPUTATIOND_USER's home in the uninstallation even though the user is removed. chown -R "$REPUTATIOND_USER":"$SASHIADMIN_GROUP" $reputationd_user_dir + echo -e "\nAccount setup is complete." + + local message="Your host account with the address $reputationd_xrpl_address will be on Xahau $NETWORK. + \nThe secret key of the account is located at $reputationd_key_file_path. + \nNOTE: It is your responsibility to safeguard/backup this file in a secure manner. + \nIf you lose it, you will not be able to access any funds in your Host account. NO ONE else can recover it. + \n\nThis is the account that will represent this host on the Evernode host registry. You need to load up the account with following funds in order to continue with the installation." + + #TODO - min_evr_requirement $lease_amount + local min_reputation_xah_requirement=$(echo "$MIN_REPUTATION_COST_PER_MONTH*$MIN_OPERATIONAL_DURATION + 1.2" | bc) + local lease_amount=$(jq ".xrpl.leaseAmount | select( . != null )" "$MB_XRPL_CONFIG") + local min_evr_requirement=$(($lease_amount*24*30*$MIN_OPERATIONAL_DURATION)) + local need_xah=$(echo "$min_reputation_xah_requirement > 0" | bc -l) + local need_evr=$(echo "$min_evr_requirement > 0" | bc -l) + [[ "$need_xah" -eq 1 ]] && message="$message\n(*) At least $min_reputation_xah_requirement XAH to cover regular transaction fees for the first three months." + [[ "$need_evr" -eq 1 ]] && message="$message\n(*) At least $min_evr_requirement EVR to cover Evernode registration." + + message="$message\n\nYou can scan the following QR code in your wallet app to send funds based on the account condition:\n" + + echomult "$message" + + generate_qrcode "$reputationd_xrpl_address" + + ! sudo -u $REPUTATIOND_USER REPUTATIOND_DATA_DIR=$REPUTATIOND_DATA node $REPUTATIOND_BIN new $reputationd_xrpl_address $reputationd_key_file_path && echo "error creating configs" && exit 1 + + echomult "To set up your reputationd host account, ensure a deposit of $min_reputation_xah_requirement XAH to cover the regular transaction fees for the first three months." + echomult "\nChecking the account condition...\nWaiting for funds" + + ! sudo -u $REPUTATIOND_USER REPUTATIOND_DATA_DIR=$REPUTATIOND_DATA node $REPUTATIOND_BIN wait-for-funds NATIVE $min_reputation_xah_requirement && echo "error retrieving funds" && exit 1 + + ! sudo -u $REPUTATIOND_USER REPUTATIOND_DATA_DIR=$REPUTATIOND_DATA node $REPUTATIOND_BIN prepare && echo "error preparing account" && exit 1 + + echomult "\n\nIn order to register in reputation and reward system you need to have $min_evr_requirement EVR balance in your host account. Please deposit the required registration fee in EVRs. + \nYou can scan the provided QR code in your wallet app to send funds\nWaiting for funds:" + ! sudo -u $REPUTATIOND_USER REPUTATIOND_DATA_DIR=$REPUTATIOND_DATA node $REPUTATIOND_BIN wait-for-funds ISSUED $min_evr_requirement && echo "error retrieving funds" && exit 1 + # Setup env variable for the reputationd user. echo " export XDG_RUNTIME_DIR=$reputationd_user_runtime_dir" >>"$reputationd_user_dir"/.bashrc @@ -2101,6 +2129,9 @@ WantedBy=timers.target" >/etc/systemd/system/$EVERNODE_AUTO_UPDATE_SERVICE.timer download_public_config && set_environment_configs + # Setting up Sashimono admin group. + ! grep -q $SASHIADMIN_GROUP /etc/group && ! groupadd $SASHIADMIN_GROUP && echo "$SASHIADMIN_GROUP group creation failed." && abort + # Create MB_XRPL_USER as we require that user for secret key ownership management. if ! grep -q "^$MB_XRPL_USER:" /etc/passwd; then echomult "Creating Message-board User..."