Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions bails/.local/bin/link-dotfiles
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,25 @@ find . -type d | while read -r dir; do mkdir --parents "$HOME${dir:1}"; done
find . -type f | while read -r file; do ln --symbolic --force "$PWD${file:1}" "$HOME${file:1}"; done

# Bitcoin Core invokes link-dotfiles through -startupnotify once startup has
# completed. If that invocation still has no peers after 30 seconds, remind the
# user that Tails may still be waiting for them to connect to Tor. Other calls
# only refresh dotfile links and must not start duplicate reminder timers.
# completed. Over Tor, finding the first peer often takes a minute or two, so
# only remind the user that Tails may still be waiting for them to connect to
# Tor if Core has had no peers for the whole grace period. Stop watching as
# soon as a peer connects or Core stops answering. Other calls only refresh
# dotfile links and must not start duplicate reminder timers.
if [ "${1:-}" = "--core-startup" ]; then
(
sleep 30
network_info="$(bitcoin-cli getnetworkinfo 2>/dev/null)" || exit 0
connections="$(awk '/^[[:space:]]*"connections":/ { gsub(/[^0-9]/, "", $2); print $2; exit }' <<<"$network_info")"
if [[ "$connections" =~ ^[0-9]+$ ]] && ((connections == 0)); then
if zenity --question --title='Bitcoin Core has no peers' \
--icon-name=tor-disconnected-symbolic \
--text='Bitcoin Core still has no peers. If Tails is waiting for you to connect to Tor, open Tor Connection now.' \
--ok-label='Open Tor Connection' --cancel-label='Not Now'; then
gtk-launch tca
fi
grace=180 interval=15
for ((waited = 0; waited < grace; waited += interval)); do
sleep "$interval"
network_info="$(bitcoin-cli getnetworkinfo 2>/dev/null)" || exit 0
connections="$(awk '/^[[:space:]]*"connections":/ { gsub(/[^0-9]/, "", $2); print $2; exit }' <<<"$network_info")"
[[ "$connections" =~ ^[0-9]+$ ]] && ((connections == 0)) || exit 0
done
if zenity --question --title='Bitcoin Core has no peers' \
--icon-name=tor-disconnected-symbolic \
--text='Bitcoin Core still has no peers. If Tails is waiting for you to connect to Tor, open Tor Connection now.' \
--ok-label='Open Tor Connection' --cancel-label='Not Now'; then
gtk-launch tca
fi
) &
fi
Loading