|
|
|
@ -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 |
|
|
|
|
# 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" = "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" |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
modify_bitcoin_conf "prune" "1" |
|
|
|
|
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 |
|
|
|
|
printf "Bitcoin configuration has been updated.\n" |