You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
2.0 KiB
44 lines
2.0 KiB
2 years ago
|
#!/bin/sh
|
||
|
|
||
|
# This script is a magical tome of sorcery, commanding the elusive entity known as Bitcoin.
|
||
|
|
||
|
. colors
|
||
|
|
||
|
# Displays the menu
|
||
|
display_menu() {
|
||
|
title="${BOLD}${CYAN}Bitcoin: $(bitcoin-status)"
|
||
|
blockchain_info="Display Blockchain Info%bitcoin-cli getblockchaininfo"
|
||
|
set_config="Configure Bitcoin%configure-bitcoin"
|
||
|
change_directory="Change Bitcoin Directory%change-bitcoin-directory"
|
||
|
clear_cache="Clear Bitcoin Cache%# coming soon"
|
||
|
repair_permissions="Repair Permissions%repair-bitcoin-permissions # Sometimes necessary"
|
||
|
exit_option="Exit%kill -2 $$" # Commands are run with 'eval' by the menu script, so we can't simply say 'exit'. The keyword $$ gets this scripts PID and the -2 code is SIGINT aka Ctrl-C
|
||
|
|
||
|
if is-bitcoin-installed; then
|
||
|
install_bitcoin_option="Uninstall Bitcoin%uninstall-bitcoin"
|
||
|
if is-service-installed bitcoin; then
|
||
|
install_service_option="Uninstall Bitcoin Service%remove-service bitcoin"
|
||
|
if is-bitcoin-running; then
|
||
|
bitcoin_server_option="Stop Bitcoin Service%sudo systemctl stop bitcoind"
|
||
|
menu "$title" "$blockchain_info" "$set_config" "$change_directory" "$clear_cache" "$repair_permissions" "$bitcoin_server_option" "$install_service_option" "$install_bitcoin_option" "$exit_option"
|
||
|
else
|
||
|
bitcoin_server_option="Start Bitcoin Service%sudo systemctl start bitcoind"
|
||
|
menu "$title" "$set_config" "$change_directory" "$clear_cache" "$repair_permissions" "$bitcoin_server_option" "$install_service_option" "$install_bitcoin_option" "$exit_option"
|
||
|
fi
|
||
|
else
|
||
|
install_service_option="Install Bitcoin Service%install-service-template ./bitcoin.service \"BITCOIND=`which bitcoind`\""
|
||
|
menu "$title" "$set_config" "$change_directory" "$clear_cache" "$repair_permissions" "$install_service_option" "$install_bitcoin_option" "$exit_option"
|
||
|
fi
|
||
|
else
|
||
|
install_bitcoin_option="Install Bitcoin%install-bitcoin"
|
||
|
menu "$title" "$install_bitcoin_option" "$exit_option"
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# Catch Ctrl-C and exit
|
||
|
trap 'echo exiting; exit' INT
|
||
|
|
||
|
# Main execution loop
|
||
|
while true; do
|
||
|
display_menu
|
||
|
done
|