|
|
@ -12,9 +12,6 @@ retry_with_sudo() { |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Source ask_yn script |
|
|
|
|
|
|
|
. ask_yn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Create bitcoin directory and configuration file if they do not exist |
|
|
|
# Create bitcoin directory and configuration file if they do not exist |
|
|
|
mkdir -p "$HOME/.bitcoin" |
|
|
|
mkdir -p "$HOME/.bitcoin" |
|
|
|
touch "$HOME/.bitcoin/bitcoin.conf" |
|
|
|
touch "$HOME/.bitcoin/bitcoin.conf" |
|
|
@ -35,7 +32,7 @@ if [ ! -s "$bitcoin_conf" ]; then |
|
|
|
echo "$defaults" > "$bitcoin_conf" |
|
|
|
echo "$defaults" > "$bitcoin_conf" |
|
|
|
else |
|
|
|
else |
|
|
|
reset_conf=$(ask_yn "Would you like to reset the bitcoin.conf file to defaults?" "n") |
|
|
|
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" |
|
|
|
echo "$defaults" > "$bitcoin_conf" |
|
|
|
fi |
|
|
|
fi |
|
|
|
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" |
|
|
|
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 |
|
|
|
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") |
|
|
|
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" |
|
|
|
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 |
|
|
|
else |
|
|
|
modify_bitcoin_conf "prune" "0" |
|
|
|
modify_bitcoin_conf "prune" "0" |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# Network selection |
|
|
|
# Network selection |
|
|
|
mainnet=$(ask_yn "Art thou operating on the main Bitcoin network?" "y") |
|
|
|
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" |
|
|
|
modify_bitcoin_conf "testnet" "0" |
|
|
|
else |
|
|
|
else |
|
|
|
modify_bitcoin_conf "testnet" "1" |
|
|
|
modify_bitcoin_conf "testnet" "1" |
|
|
@ -72,14 +68,10 @@ fi |
|
|
|
default_data_dir="$HOME/.bitcoin/blocks" |
|
|
|
default_data_dir="$HOME/.bitcoin/blocks" |
|
|
|
modify_bitcoin_conf "datadir" "$default_data_dir" |
|
|
|
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") |
|
|
|
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: " |
|
|
|
printf "Please type the alternate path thou wouldst like to use for blockchain storage: " |
|
|
|
read -r alt_path |
|
|
|
read -r alt_path |
|
|
|
modify_bitcoin_conf "datadir" "$alt_path" |
|
|
|
modify_bitcoin_conf "datadir" "$alt_path" |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# Final confirmation and start |
|
|
|
printf "Bitcoin configuration has been updated.\n" |
|
|
|
confirm=$(ask_yn "Dost thou wish to initiate Bitcoin with the specified configurations?" "y") |
|
|
|
|
|
|
|
if [ $confirm -eq 1 ]; then |
|
|
|
|
|
|
|
bitcoind -daemon |
|
|
|
|
|
|
|
fi |
|
|
|
|