From b66a18c0e7e3624e27dafab476df16325005b064 Mon Sep 17 00:00:00 2001 From: deicidus Date: Thu, 8 Jun 2023 12:10:36 -0700 Subject: [PATCH] fixed question --- spells/cantrips/ask_yn | 2 +- spells/menu/configure-bitcoin | 28 ++++++++++------------------ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/spells/cantrips/ask_yn b/spells/cantrips/ask_yn index fb6ef29..b2d9d8b 100755 --- a/spells/cantrips/ask_yn +++ b/spells/cantrips/ask_yn @@ -26,7 +26,7 @@ if [ -z "$answer" ]; then fi # Print the answer and return appropriate exit code -printf "%s\n" "$answer" +printf "%s\n" "$(echo $answer | tr a-z A-Z)" if [ "$answer" = "Y" -o "$answer" = "y" ]; then exit 0 else diff --git a/spells/menu/configure-bitcoin b/spells/menu/configure-bitcoin index 80df4c3..13b7657 100755 --- a/spells/menu/configure-bitcoin +++ b/spells/menu/configure-bitcoin @@ -12,9 +12,6 @@ retry_with_sudo() { fi } -# Source ask_yn script -. ask_yn - # Create bitcoin directory and configuration file if they do not exist mkdir -p "$HOME/.bitcoin" touch "$HOME/.bitcoin/bitcoin.conf" @@ -35,7 +32,7 @@ if [ ! -s "$bitcoin_conf" ]; then echo "$defaults" > "$bitcoin_conf" else reset_conf=$(ask_yn "Would you like to reset the bitcoin.conf file to defaults?" "n") - if [ $reset_conf -eq 1 ]; then + if [ "$reset_conf" = "Y" ]; then echo "$defaults" > "$bitcoin_conf" fi fi @@ -47,22 +44,21 @@ modify_bitcoin_conf() { awk -v key="$key" -v value="$value" 'BEGIN {found=0} !/^#/ && $1==key {found=1; print key"="value; next} {print} END {if (!found) print key"="value}' "$bitcoin_conf" > "$bitcoin_conf.tmp" && mv "$bitcoin_conf.tmp" "$bitcoin_conf" || retry_with_sudo mv "$bitcoin_conf.tmp" "$bitcoin_conf" } -# Storage amount and pruning question -printf "What is the maximum memory thou art willing to dedicate to Bitcoin in MB? (Type a number) [default: 300]: " -read -r max_mem -max_mem=${max_mem:-300} -modify_bitcoin_conf "dbcache" "$max_mem" - +# Pruning question and storage amount prune=$(ask_yn "Wouldst thou like to enable pruning? Pruning allows thee to reduce disk usage by discarding some transaction history." "y") -if [ $prune -eq 1 ]; then +if [ "$prune" = "Y" ]; then modify_bitcoin_conf "prune" "1" + printf "What is the maximum memory thou art willing to dedicate to Bitcoin in MB? (Type a number) [default: 300]: " + read -r max_mem + max_mem=${max_mem:-300} + modify_bitcoin_conf "dbcache" "$max_mem" else modify_bitcoin_conf "prune" "0" fi # Network selection mainnet=$(ask_yn "Art thou operating on the main Bitcoin network?" "y") -if [ $mainnet -eq 1 ]; then +if [ "$mainnet" = "Y" ]; then modify_bitcoin_conf "testnet" "0" else modify_bitcoin_conf "testnet" "1" @@ -72,14 +68,10 @@ fi default_data_dir="$HOME/.bitcoin/blocks" modify_bitcoin_conf "datadir" "$default_data_dir" alt_storage=$(ask_yn "Wouldst thou like to store the blockchain in the default location ($default_data_dir)?" "y") -if [ $alt_storage -eq 0 ]; then +if [ "$alt_storage" = "N" ]; then printf "Please type the alternate path thou wouldst like to use for blockchain storage: " read -r alt_path modify_bitcoin_conf "datadir" "$alt_path" fi -# Final confirmation and start -confirm=$(ask_yn "Dost thou wish to initiate Bitcoin with the specified configurations?" "y") -if [ $confirm -eq 1 ]; then - bitcoind -daemon -fi \ No newline at end of file +printf "Bitcoin configuration has been updated.\n" \ No newline at end of file