@@ -36,6 +36,9 @@ export DATA_DIR=$SOURCE/Persistent/.bitcoin
36
36
export DOTFILES=$SOURCE /dotfiles
37
37
export LOCAL_DIR=$DOTFILES /.local
38
38
39
+ readonly DOWNLOAD_DIR=$HOME /.local/share/bitcoin-core
40
+
41
+
39
42
link_dotfiles () {
40
43
( # runs in subshell to preserve current directory
41
44
cd $DOTFILES
@@ -54,7 +57,7 @@ check_sigs() {
54
57
good_sig=$( gpg --verify SHA256SUMS.asc SHA256SUMS 2>&1 | grep --count ' Good signature' )
55
58
if (( good_sig < $1 )) ; then
56
59
type=warning
57
- keys=" $( grep fingerprint $destination_dir /show-keys | sed ' s/ //g' | cut -f2 -d= | shuf) "
60
+ keys=" $( grep fingerprint $DOWNLOAD_DIR /show-keys | sed ' s/ //g' | cut -f2 -d= | shuf) "
58
61
for key in $keys ; do
59
62
search_key
60
63
(( good_sig >= $1 )) && { type=info; break ; }
@@ -106,30 +109,27 @@ pkill tca &>/dev/null
106
109
# enables job control so background downloads can be foregrounded to show progress while user waits
107
110
set -m
108
111
109
- # Set the destination directory for the download
110
- destination_dir=$HOME /.local/share/bitcoin-core
111
-
112
112
# Checks for existing Bitcoin Core versions
113
- old_versions=$( ls -d $destination_dir /bitcoin-core-* | wc --lines)
113
+ old_versions=$( ls -d $DOWNLOAD_DIR /bitcoin-core-* | wc --lines)
114
114
115
115
# Installs Bails to tmpfs
116
116
rsync --recursive $BAILS_DIR /{bin,lib,share,state} $HOME /.local/
117
117
118
118
# Create the destination directory if it doesn't exist
119
- mkdir -p " $destination_dir "
119
+ mkdir -p " $DOWNLOAD_DIR "
120
120
121
121
# TODO uncomment the downloads when done testing other things
122
122
# Download Bitcoin core checksums and signatures in background
123
123
124
- ( cd " $destination_dir " ; # wget --tries=1 --no-host-directories --cut-dirs=1 --recursive --level=1 --accept=SHA256SUMS* --include-directories=bin http://6hasakffvppilxgehrswmffqurlcjjjhd76jgvaqmsg6ul25s7t3rzyd.onion/en/download/ ||
124
+ ( cd " $DOWNLOAD_DIR " ; # wget --tries=1 --no-host-directories --cut-dirs=1 --recursive --level=1 --accept=SHA256SUMS* --include-directories=bin http://6hasakffvppilxgehrswmffqurlcjjjhd76jgvaqmsg6ul25s7t3rzyd.onion/en/download/ ||
125
125
wget --no-host-directories --cut-dirs=1 --recursive --level=1 --accept=SHA256SUMS* --include-directories=bin https://bitcoincore.org/en/download/; ) & sig_dl=$!
126
126
# TODO FIXME uncomment the onion service when bitcoincore.org fixes their service.
127
127
# Download Bitcoin Core in background to the destination directory
128
- ( sleep 1; while pgrep wget & > /dev/null; do sleep 1; done ; cd " $destination_dir " ; # wget --continue --tries=1 --no-host-directories --cut-dirs=1 --recursive --level=1 --accept=x86_64-linux-gnu.tar.gz --include-directories=bin http://6hasakffvppilxgehrswmffqurlcjjjhd76jgvaqmsg6ul25s7t3rzyd.onion/en/download/ ||
128
+ ( sleep 1; while pgrep wget & > /dev/null; do sleep 1; done ; cd " $DOWNLOAD_DIR " ; # wget --continue --tries=1 --no-host-directories --cut-dirs=1 --recursive --level=1 --accept=x86_64-linux-gnu.tar.gz --include-directories=bin http://6hasakffvppilxgehrswmffqurlcjjjhd76jgvaqmsg6ul25s7t3rzyd.onion/en/download/ ||
129
129
wget --continue --no-host-directories --cut-dirs=1 --recursive --level=1 --accept=x86_64-linux-gnu.tar.gz --include-directories=bin https://bitcoincore.org/en/download/; ) & core_download=$!
130
130
131
131
# Download chain parameters in background
132
- ( cd $destination_dir ; wget -O chainparams.cpp https://raw.githubusercontent.com/bitcoin/bitcoin/master/src/kernel/chainparams.cpp ) & get_size=$!
132
+ ( cd $DOWNLOAD_DIR ; wget -O chainparams.cpp https://raw.githubusercontent.com/bitcoin/bitcoin/master/src/kernel/chainparams.cpp ) & get_size=$!
133
133
134
134
# clear the terminal
135
135
clear -x
@@ -145,14 +145,14 @@ printf '\033]2;Getting Bitcoin Core signatures...\a'
145
145
ps -p $sig_dl & > /dev/null && fg %$( jobs -l | grep $sig_dl | cut -f1 -d' ' | tr -c -d ' [:digit:]' )
146
146
147
147
# Switch into latest bitcoin-core directory
148
- cd " $( ls -dt $destination_dir /bitcoin-core-* | head -1) " || {
148
+ cd " $( ls -dt " $DOWNLOAD_DIR " /bitcoin-core-* | head -1) " || {
149
149
zenity --warning --title=" Download failure" --text=" Click OK to try downloading Bitcoin Core again." --ellipsize $ICON &&
150
150
sleep 5
151
151
install-core # launch this script again
152
152
exit 1
153
153
}
154
154
155
- versions=$( ls -d $destination_dir /bitcoin-core-* | wc --lines)
155
+ versions=$( ls -d $DOWNLOAD_DIR /bitcoin-core-* | wc --lines)
156
156
157
157
if (( old_versions != versions )) || [ ! -f $LOCAL_DIR /bin/bitcoind ]; then
158
158
if zenity --question --title=' Verify Bitcoin Core download' --text=' Download verification is optional but highly recommended. It requires around 5 to 10 minutes.\n\nPerforming the verification steps ensures that you have not downloaded an unexpected or tampered version of Bitcoin, which may result in loss of funds.' --cancel-label=' Skip' --ok-label=' Verify' --width=610 $ICON --icon-name=gtk-dialog-authentication; then
@@ -166,7 +166,7 @@ if (( old_versions != versions )) || [ ! -f $LOCAL_DIR/bin/bitcoind ]; then
166
166
fi
167
167
zenity --info --title=" Trustworthy individuals" --text=" Bitcoin releases are signed by a number of individuals, each with a unique public key. In order to recognize the validity of signatures, you will choose a few individuals who you find trustworthy. Their keys will be used to check the signature attesting to the validity of your download." --width=620 $ICON --icon-name=security-high & understood=$!
168
168
printf ' \033]2;Getting Bitcoin Core builder keys...\a'
169
- ( cd $destination_dir
169
+ ( cd $DOWNLOAD_DIR
170
170
[ -d " guix.sigs" ] || git clone https://github.com/bitcoin-core/guix.sigs --depth=1 && \
171
171
gpg --show-keys guix.sigs/builder-keys/* .gpg > show-keys )
172
172
(( versions > 1 )) && gpg --refresh-keys # refresh keys in keyring to see if any were revoked since last install
178
178
179
179
# Bring chainparams.cpp download to foreground then set assumed chainstate & blockchain size
180
180
ps -p $get_size & > /dev/null && fg %$( jobs -l | grep $get_size | cut -f1 -d' ' | tr -c -d ' [:digit:]' )
181
- assumed_chain_state_size=$( grep --max-count=1 m_assumed_chain_state_size $destination_dir /chainparams.cpp | sed ' s/[^0-9]*//g' )
182
- assumed_blockchain_size=$( grep --max-count=1 m_assumed_blockchain_size $destination_dir /chainparams.cpp | sed ' s/[^0-9]*//g' )
181
+ assumed_chain_state_size=$( grep --max-count=1 m_assumed_chain_state_size $DOWNLOAD_DIR /chainparams.cpp | sed ' s/[^0-9]*//g' )
182
+ assumed_blockchain_size=$( grep --max-count=1 m_assumed_blockchain_size $DOWNLOAD_DIR /chainparams.cpp | sed ' s/[^0-9]*//g' )
183
183
184
184
# Display information about pruning and initial block download while user waits for download
185
185
space=$(( $(df -- output= size $SOURCE | tail - 1 )/ 1024 - ( assumed_chain_state_size+ 10 )* 1024 ))
@@ -192,7 +192,7 @@ printf '\033]2;Downloading Bitcoin Core...\a'
192
192
ps -p $core_download & > /dev/null && fg %$( jobs -l | grep $core_download | cut -f1 -d' ' | tr -c -d ' [:digit:]' )
193
193
194
194
# Move completed download to persistent storage
195
- rsync --remove-source-files --recursive $destination_dir $LOCAL_DIR /share/
195
+ rsync --remove-source-files --recursive $DOWNLOAD_DIR $LOCAL_DIR /share/
196
196
link_dotfiles
197
197
198
198
# Verify download integrity # TODO make sure they can actually retry the download by re-running the script, that everything gets skipped that needs to be skipped.
@@ -245,8 +245,8 @@ rsync --remove-source-files -recursive "$BAILS_DIR"/config/ $DOTFILES/.config
245
245
}' > $DATA_DIR /settings.json
246
246
247
247
# Cleanup
248
- rm -Rf ${BAILS_DIR:? } /{bin,lib,share,state,config} " $destination_dir " /{download,* .tmp,wget-log* }
249
- rsync -r --remove-source-files $BAILS_DIR $LOCAL_DIR /share/
248
+ rm -Rf ${BAILS_DIR:? } /{bin,lib,share,state,config} " $DOWNLOAD_DIR " /{download,* .tmp,wget-log* }
249
+ rsync -r --remove-source-files $BAILS_DIR / $LOCAL_DIR /share/bails
250
250
rm -rf $BAILS_DIR
251
251
link_dotfiles
252
252
0 commit comments