Skip to content

Commit 266f54f

Browse files
authored
117 sed prints an error in the terminal during install (#119)
* add missing file to sed command * always install to /share/bails * rename destination_dir to DOWNLOAD_DIR * remove unneeded comment
1 parent b22f191 commit 266f54f

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

bin/install-core

+17-17
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export DATA_DIR=$SOURCE/Persistent/.bitcoin
3636
export DOTFILES=$SOURCE/dotfiles
3737
export LOCAL_DIR=$DOTFILES/.local
3838

39+
readonly DOWNLOAD_DIR=$HOME/.local/share/bitcoin-core
40+
41+
3942
link_dotfiles() {
4043
( # runs in subshell to preserve current directory
4144
cd $DOTFILES
@@ -54,7 +57,7 @@ check_sigs() {
5457
good_sig=$(gpg --verify SHA256SUMS.asc SHA256SUMS 2>&1 | grep --count 'Good signature')
5558
if (( good_sig < $1 )); then
5659
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)"
5861
for key in $keys; do
5962
search_key
6063
(( good_sig >= $1 )) && { type=info; break; }
@@ -106,30 +109,27 @@ pkill tca &>/dev/null
106109
# enables job control so background downloads can be foregrounded to show progress while user waits
107110
set -m
108111

109-
# Set the destination directory for the download
110-
destination_dir=$HOME/.local/share/bitcoin-core
111-
112112
# 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)
114114

115115
# Installs Bails to tmpfs
116116
rsync --recursive $BAILS_DIR/{bin,lib,share,state} $HOME/.local/
117117

118118
# Create the destination directory if it doesn't exist
119-
mkdir -p "$destination_dir"
119+
mkdir -p "$DOWNLOAD_DIR"
120120

121121
# TODO uncomment the downloads when done testing other things
122122
# Download Bitcoin core checksums and signatures in background
123123

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/ ||
125125
wget --no-host-directories --cut-dirs=1 --recursive --level=1 --accept=SHA256SUMS* --include-directories=bin https://bitcoincore.org/en/download/; ) & sig_dl=$!
126126
# TODO FIXME uncomment the onion service when bitcoincore.org fixes their service.
127127
# 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/ ||
129129
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=$!
130130

131131
# 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=$!
133133

134134
# clear the terminal
135135
clear -x
@@ -145,14 +145,14 @@ printf '\033]2;Getting Bitcoin Core signatures...\a'
145145
ps -p $sig_dl &>/dev/null && fg %$(jobs -l | grep $sig_dl | cut -f1 -d' ' | tr -c -d '[:digit:]')
146146

147147
# 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)" || {
149149
zenity --warning --title="Download failure" --text="Click OK to try downloading Bitcoin Core again." --ellipsize $ICON &&
150150
sleep 5
151151
install-core # launch this script again
152152
exit 1
153153
}
154154

155-
versions=$(ls -d $destination_dir/bitcoin-core-* | wc --lines)
155+
versions=$(ls -d $DOWNLOAD_DIR/bitcoin-core-* | wc --lines)
156156

157157
if (( old_versions != versions )) || [ ! -f $LOCAL_DIR/bin/bitcoind ]; then
158158
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
166166
fi
167167
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=$!
168168
printf '\033]2;Getting Bitcoin Core builder keys...\a'
169-
( cd $destination_dir
169+
( cd $DOWNLOAD_DIR
170170
[ -d "guix.sigs" ] || git clone https://github.com/bitcoin-core/guix.sigs --depth=1 && \
171171
gpg --show-keys guix.sigs/builder-keys/*.gpg > show-keys )
172172
(( versions > 1 )) && gpg --refresh-keys # refresh keys in keyring to see if any were revoked since last install
@@ -178,8 +178,8 @@ fi
178178

179179
# Bring chainparams.cpp download to foreground then set assumed chainstate & blockchain size
180180
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')
183183

184184
# Display information about pruning and initial block download while user waits for download
185185
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'
192192
ps -p $core_download &>/dev/null && fg %$(jobs -l | grep $core_download | cut -f1 -d' ' | tr -c -d '[:digit:]')
193193

194194
# 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/
196196
link_dotfiles
197197

198198
# 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
245245
}' > $DATA_DIR/settings.json
246246

247247
# 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
250250
rm -rf $BAILS_DIR
251251
link_dotfiles
252252

0 commit comments

Comments
 (0)