Skip to content

Commit

Permalink
menu shell formating and new dialogs for install
Browse files Browse the repository at this point in the history
shfmt  Formatted bails_menu.sh

added dialog to explain what IBD is without having to wait for the bitcoin core download to finish. This avoids the Welcome to Bitcoin Core --choosedatadir dialog

Added some additional reading as well to entertain the user while they keep practicing their passphrase.

perf fix: stopped downloading the SHASUMS twice
  • Loading branch information
BenWestgate committed Nov 25, 2022
1 parent fa91437 commit 6bf8342
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
13 changes: 11 additions & 2 deletions bin/bails_menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,24 @@ response=$(zenity --question --window-icon=/usr/local/share/pixmaps/bails128.png
[ "$response" == 'Clone' ] && /usr/local/bin/init --clone
[ "$response" == 'Backup' ] && /usr/local/bin/init --backup
[ "$response" == 'Help' ] && help=$(zenity --window-icon=/usr/local/share/pixmaps/bails128.png --question --icon-name=help-faq-symbolic --title='Help Menu' --text='' --extra-button='Online Help' --extra-button='Donate' --extra-button='Report a Bug' --extra-button='About' --switch)
[ "$help" == 'Donate' ] && xdg-open bitcoin:BC1Q9KYUJH8NRRJ2VWW3MA8TERWCRM9WUA24MH7TU3?label=Donation%20to%20Bitcoin%20Core%20on%20Tails #FIXME change address
[ "$help" == 'Donate' ] && xdg-open bitcoin:BC1Q9KYUJH8NRRJ2VWW3MA8TERWCRM9WUA24MH7TU3?label=Donation%20to%20Bitcoin%20Core%20on%20Tails #FIXME change address
[ "$help" == 'Report a Bug' ] && tor-browser https://github.com/BenWestgate/Bitcoin-Core-on-Tails/issues
[ "$help" == 'About' ] && zenity --info --window-icon=/usr/local/share/pixmaps/bails128.png --title='About Bitcoin Core on Tails' --icon-name=bails128 --text='Bitcoin Core on Tails version v0.1.0\n\nCopyright (C) 2022 Ben Westgate\n\nPlease contribute if you find Bitcoin Core on Tails useful. Visit <a href="https://twitter.com/BenWestgate_">https://twitter.com/BenWestgate_</a> for further information about the software.\nThe source code is available from <a href="https://github.com/BenWestgate/Bitcoin-Core-on-Tails">https://github.com/BenWestgate/Bitcoin-Core-on-Tails</a>.\n\nThis is experimental software.\nDistributed under the MIT software license, see the accompanying file COPYING or <a href="https://opensource.org/licenses/MIT">https://opensource.org/licenses/MIT</a>' --width=650
[ "$help" == 'Online Help' ] && xdg-open https://bitcoin-core-on-tails.slack.com/
[ "$response" == 'Settings' ] && setting=$(zenity --window-icon=/usr/local/share/pixmaps/bails128.png --question --icon-name=org.gnome.Settings --title=Settings --text='Coming soon\n\nConfigure Bitcoin Core on Tails' --extra-button='Update Bitcoin Core' --extra-button='Passphrase' --extra-button='Sync Faster' --extra-button='Erase Device' --switch --width=300)
[ "$setting" == 'Update Bitcoin Core' ] && /usr/local/bin/init --download
[ "$setting" == 'Passphrase' ] && pass_mgmt=$(zenity --window-icon=/usr/local/share/pixmaps/bails128.png --question --icon-name=dialog-password --title='Passphrase Settings' --text='Coming soon\n\n<b>WARNING:</b> <span foreground="red">The only secure way to change or remove a compromised or weak passphrase is to erase the device AND use physical destruction. The old passwords may still be around, potentially for a very long time and can be used to access your bitcoin data with forensic tools.</span>' --extra-button='Add passphrase' --extra-button='Change passphrase' --extra-button='Remove passphrase' --extra-button='Remove forgotten' --switch --width=500)
[ "$setting" == 'Sync Faster' ] && zenity --window-icon=/usr/local/share/pixmaps/bails128.png --title='Sync Faster' --list --text='Coming soon - placeholder.' --column='' --column='Method' --checklist FALSE 'Disable Tor (Increases download speed)' FALSE 'Aggressive pruning (Use more RAM on small storage)' FALSE 'Enable Swap (Frees up RAM)' FALSE 'RAM Sync (Fastest but unsafe shutdown loses progress)' --width=433 --height=210
[ "$sync" == 'Disable Tor (Increases download bandwidth)' ] && sudo --askpass /usr/local/lib/do_not_ever_run_me
# TODO verify that this actually does something, and modify this file to have the box "checked" TRUE if it suceeds, and require a restart for turning it off. Also turn proxy off and restart core w/o wallets.
[ "$sync" == 'RAM Sync (Fastest but unsafe shutdown loses progress)' ] && { mnt_pnt=$(mktemp --directory); mkdir $mnt_pnt/{upper,work}; sudo --askpass mount -t tmpfs -o size=6G $mnt_pnt; sudo mount -t overlay overlay -o lowerdir=$HOME/.bitcoin/chainstate,upperdir=$mnt_pnt/upper,workdir=$mnt_pnt/work $HOME/.bitcoin/chainstate; bitcoin-qt --nodebuglog; sudo umount $HOME/.bitcoin/chainstate; rsync -a --del --verbose --progress $mnt_pnt $HOME/.bitcoin/chainstate; }
[ "$sync" == 'RAM Sync (Fastest but unsafe shutdown loses progress)' ] && {
mnt_pnt=$(mktemp --directory)
mkdir $mnt_pnt/{upper,work}
sudo --askpass mount -t tmpfs -o size=6G $mnt_pnt
sudo mount -t overlay overlay -o lowerdir=$HOME/.bitcoin/chainstate,upperdir=$mnt_pnt/upper,workdir=$mnt_pnt/work $HOME/.bitcoin/chainstate
bitcoin-qt --nodebuglog
sudo umount $HOME/.bitcoin/chainstate
rsync -a --del --verbose --progress $mnt_pnt $HOME/.bitcoin/chainstate
}
[ "$setting" == 'Erase Device' ] && zenity --window-icon=/usr/local/share/pixmaps/bails128.png --title='Confirm before erasing device' --icon-name=dialog-warning --question --ok-label='Delete' --cancel-label='Cancel' --text="<b><big>WARNING\! Persistent volume deletion</big>\n\n\nYour persistent data will be deleted</b>\nAll data on the device will be lost.\n\n\nThe persistent volume $device ($(lsblk --output=SIZE --nodeps --noheading --raw $device)iB), on the <b>$(lsblk --inverse --noheadings --output=VENDOR,MODEL $device | tr -s ' ' | head -1)</b> device, will be deleted and wiped.\n\n<b>Are you sure you want to delete this device?</b>" --width=350 && sudo --askpass bash -c "cryptsetup erase --verbose $device ; shred --verbose $device; shred --verbose $USB; shutdown"
gtk-launch bails.desktop
20 changes: 14 additions & 6 deletions init
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,17 @@ download() {
verify $1 # finds 2 trustworthy attestations from keys.txt for the download checksum
cd -
printf '\033]2;Downloading Bitcoin Core...\a'
prune_MiB=$((($(df --output=avail $HOME/.bitcoin | tail -1) + $(du --summarize $HOME/.bitcoin/blocks | cut -f1)) - 10485760 > 1953125 ? ($(df --output=avail $HOME/.bitcoin | tail -1) + $(du --summarize $HOME/.bitcoin/blocks | cut -f1))/1024 - (4+$assumed_chain_state_size)*1024 : 1908))
prune_GB=$(( (prune_MiB+1)*2**20/10**9))
backup_days=$((prune_MiB/309))
{ until [ "$docs" == 'Continue' ]; do docs=$(zenity --question --title='Setup almost complete' --icon-name=bails128 --window-icon=/usr/local/share/pixmaps/bails128.png --text='Bitcoin Core will finish downloading, install and begin syncing the block chain automatically. You will not have much to do for the next several hours or days. Keep an eye on your PC so no one messes with it.\n\nIt is safer to exit Bitcoin Core (<b>Ctrl+Q</b>) and <a href="file:///usr/share/doc/tails/website/doc/first_steps/shutdown/index.en.html">shutdown Tails</a> and take the USB stick with you or store in a safe place than leave Tails running unattended where people you distrust could tamper with it.\n\nIf you want to learn more about Tails read the documentation. Another excellent use of time would be browsing "security in-a-box" website to improve your physical and digital security.' --extra-button='Documentation' --extra-button='Security Tools & Tactics' --extra-button='Continue' --switch --width=552);
[ "$docs" == 'Documentation' ] && xdg-open file:///usr/share/doc/tails/website/doc.en.html &
[ "$docs" == 'Security Tools & Tactics' ] && xdg-open http://lxjacvxrozjlxd7pqced7dyefnbityrwqjosuuaqponlg3v7esifrzad.onion/en/ & done &
zenity --title='Bitcoin Core info' --icon-name=bails128 --window-icon=/usr/local/share/pixmaps/bitcoin128.png --info --text="<b>Setup</b>
---------------------
Bitcoin Core is the original Bitcoin client and it builds the backbone of the network. It will download and process the entire history of Bitcoin transactions, which currently is a few hundred gigabytes.\n\nDepending on the speed of your computer and network connection, the synchronization process can take anywhere from a few hours to a day or more.\n\nThis initial synchronisation is very demanding, and may expose hardware problems with your computer that had previously gone unnoticed. Each time you run Bitcoin Core, it will continue downloading where it left off.\n\nLimiting block chain storage to $(( (prune+1)*2**20/10**9)) GB (<b>sufficient to restore backups $backup_days days old</b>)" --width=552; } &>/dev/null &
# brings the started in background download to foreground so user can see progress.
ps -p $dl >/dev/null && fg %$(jobs -l | grep $dl | cut -f1 -d' ' | tr -c -d '[:digit:]') || wget --continue --no-host-directories --cut-dirs=1 --recursive --level=1 --accept=x86_64-linux-gnu.tar.gz,SHA256SUMS* --include-directories=bin http://6hasakffvppilxgehrswmffqurlcjjjhd76jgvaqmsg6ul25s7t3rzyd.onion/en/download/
ps -p $dl >/dev/null && fg %$(jobs -l | grep $dl | cut -f1 -d' ' | tr -c -d '[:digit:]') || wget --continue --no-host-directories --cut-dirs=1 --recursive --level=1 --accept=x86_64-linux-gnu.tar.gz --include-directories=bin http://6hasakffvppilxgehrswmffqurlcjjjhd76jgvaqmsg6ul25s7t3rzyd.onion/en/download/
rm -R download ./*.tmp
cd "$(ls -dt bitcoin-core* | head -1)"
sha256sum --ignore-missing --check SHA256SUMS || {
Expand All @@ -555,7 +564,7 @@ download() {
cd -
{
sleep 5
zenity --title=README.md --text-info --filename=/usr/local/README.md --width=560 --height=580 --timeout=30
zenity --title=README.md --text-info --filename=/usr/local/README.md --width=560 --height=580
} & # displays the README.md for 30 seconds.
}

Expand Down Expand Up @@ -679,10 +688,10 @@ if ! test -f $HOME/.bitcoin/debug.log; then
benchmark 1
passphrase 0
download 2
rsync -a --remove-source-files "$BCOT_DIR" "$mnt_pnt"/Persistent
rsync -a --remove-source-files "$BCOT_DIR" $HOME/Persistent
ps -p $get_size >/dev/null && fg %$(jobs -l | grep $get_size | cut -f1 -d' ' | tr -c -d '[:digit:]')
assumed_chain_state_size=$(grep --max-count=1 m_assumed_chain_state_size chainparams.cpp | sed 's/[^0-9]*//g')
rsync -a --remove-source-files --exclude='*log*' . "$mnt_pnt"/Persistent
rsync -a --remove-source-files --exclude='*log*' . $HOME/Persistent
sudo sed 's/electrum/bitcoin-qt/g' /usr/share/applications/mimeinfo.cache | sudo tee /usr/local/share/applications/mimeinfo.cache # changes bitcoin: uri handling to bitcoin-qt
echo '[Desktop Entry]
Type=Application
Expand All @@ -705,6 +714,7 @@ MimeType=x-scheme-handler/bitcoin;
Categories=Office;Finance;P2P;Network;Qt;
StartupWMClass=Bitcoin-qt' | sudo tee /usr/local/share/applications/bitcoin-qt.desktop
gtk-launch bitcoin-qt
sleep 10
gnome-terminal --title='Running bitcoin' -- bash -c "while test -f $HOME/.bitcoin/bitcoin.pid; do tail $HOME/.bitcoin/debug.log; sleep 5; done"
sleep 2
clear -x
Expand Down Expand Up @@ -738,5 +748,3 @@ fi
# TODO we can use tails-backup-rsync or tails-backup for the backup case.
sudo mv /etc/sudoers.d/always-ask-password{.bak,} &>>log & # restores default sudo every command behavior TODO consider making this an exiting function
exit 0
# TODO give this shutdown info to newly setup passphrases.
# https://tails.boum.org/doc/first_steps/shutdown/index.en.html

0 comments on commit 6bf8342

Please sign in to comment.