|
|
|
@ -45,7 +45,7 @@ modify_bitcoin_conf() {
|
|
|
|
|
local key=$1 |
|
|
|
|
local value=$2 |
|
|
|
|
printf "%s\n" >> "$bitcoin_conf" # Ensure a newline exists at the end of the file |
|
|
|
|
awk -v key="$key" -v value="$value" 'BEGIN {OFS=FS="="; found=0} {gsub(/^[ \t]+|[ \t]+$/, "", $1)} !/^#/ && $1==key {found=1; print key"="value; next} {print $1"="$2} 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 {OFS=FS="="; found=0} {gsub(/^[ \t]+|[ \t]+$/, "", $1)} !/^#/ && $1==key {found=1; print key"="value; next} {if(NF>1) print $1"="$2; else if(NF==1) print $1} 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 '/./' "$bitcoin_conf" > "$bitcoin_conf.tmp" && mv "$bitcoin_conf.tmp" "$bitcoin_conf" || retry_with_sudo mv "$bitcoin_conf.tmp" "$bitcoin_conf" # Remove trailing newlines |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|