joininbox/scripts/menu.config.sh

161 lines
4.3 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
source /home/joinmarket/joinin.conf
source /home/joinmarket/_functions.sh
2021-11-30 19:37:02 +00:00
if [ ${#network} -eq 0 ] || [ "${network}" = "unknown" ] ;then
if [ "${runningEnv}" = standalone ]; then
source /home/joinmarket/standalone/_functions.standalone.sh
network=mainnet
elif [ "${runningEnv}" = mynode ];then
network=mainnet
elif [ "${runningEnv}" = raspiblitz ];then
source /mnt/hdd/raspiblitz.conf
if [ $network = bitcoin ];then
network=${chain}net
else
network=unsupported
fi
2021-03-02 10:23:13 +00:00
fi
fi
if [ "$runningEnv" = "standalone" ] && [ "$setupStep" -lt 100 ]; then
2021-03-21 00:31:58 +00:00
echo "# Open the startup menu on the first start"
sudo sed -i "s#setupStep=.*#setupStep=100#g" $joininConfPath
2021-03-21 00:31:58 +00:00
# BASIC MENU INFO
2021-03-22 12:11:27 +00:00
HEIGHT=16
WIDTH=68
CHOICE_HEIGHT=24
2021-03-21 00:31:58 +00:00
TITLE="Startup options"
MENU="
2021-03-22 12:11:27 +00:00
Welcome to JoininBox $currentJBcommit
Choose from the options:"
2021-03-21 00:31:58 +00:00
OPTIONS=()
BACKTITLE="JoininBox GUI"
CANCELLABEL="Main menu"
2021-03-21 00:31:58 +00:00
OPTIONS+=(
CONNECT "Connect to a remote bitcoin node on mainnet"
SIGNET "Start on signet with a local Bitcoin Core"
PRUNED "Start a pruned node from pruned.host4coins.net/blocks")
2021-03-21 00:31:58 +00:00
if [ -f /home/bitcoin/.bitcoin/bitcoin.conf ];then
OPTIONS+=(
2021-11-30 19:37:02 +00:00
LOCAL "Connect to the local Bitcoin Core on mainnet")
2021-03-21 00:31:58 +00:00
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi
OPTIONS+=(
"" ""
JMCONF "Edit the joinmarket.cfg manually"
"" ""
UPDATE "Update JoininBox or JoinMarket")
2021-03-02 10:23:13 +00:00
2021-03-21 00:31:58 +00:00
else
# BASIC MENU INFO
HEIGHT=12
WIDTH=68
2021-03-21 00:31:58 +00:00
CHOICE_HEIGHT=20
TITLE="Configuration options"
MENU=""
OPTIONS=()
BACKTITLE="JoininBox GUI"
CANCELLABEL="Back"
2021-03-21 00:31:58 +00:00
# Basic Options
OPTIONS+=(
JMCONF "Edit the joinmarket.cfg manually"
"" ""
CONNECT "Connect to a remote bitcoin node on mainnet"
SIGNET "Switch to signet with a local Bitcoin Core")
if [ "${runningEnv}" = standalone ]; then
OPTIONS+=(
PRUNED "Start a pruned node from pruned.host4coins.net/blocks")
2021-03-21 00:31:58 +00:00
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi
if [ -f /home/bitcoin/.bitcoin/bitcoin.conf ];then
OPTIONS+=(
LOCAL "Connect to the local Bitcoin Core on mainnet"
2021-03-21 00:31:58 +00:00
"" ""
BTCCONF "Edit the local bitcoin.conf")
HEIGHT=$((HEIGHT+3))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+3))
fi
OPTIONS+=(
"" ""
RESET "Reset the joinmarket.cfg to the defaults")
fi
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--ok-label "Select" \
--cancel-label "$CANCELLABEL" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
case $CHOICE in
JMCONF)
/home/joinmarket/install.joinmarket.sh -i config
echo "Returning to the menu..."
sleep 1
2021-03-21 00:31:58 +00:00
/home/joinmarket/menu.sh;;
RESET)
echo "# Removing the joinmarket.cfg"
2021-03-02 10:23:13 +00:00
rm -f $JMcfgPath
generateJMconfig
echo
echo "Press ENTER to return to the menu..."
2021-03-21 00:31:58 +00:00
read key;;
CONNECT)
2021-02-13 13:56:33 +00:00
/home/joinmarket/install.bitcoincore.sh signetOff
/home/joinmarket/menu.bitcoinrpc.sh
# set joinin.conf value
/home/joinmarket/set.value.sh set network mainnet ${joininConfPath}
echo
echo "Press ENTER to return to the menu..."
2021-03-21 00:31:58 +00:00
read key;;
SIGNET)
/home/joinmarket/install.bitcoincore.sh signetOn
echo
echo "Press ENTER to return to the menu..."
2021-03-21 00:31:58 +00:00
read key;;
2021-03-02 10:23:13 +00:00
PRUNED)
installBitcoinCoreStandalone
echo
downloadSnapShot
installMainnet
connectLocalNode
showBitcoinLogs
echo
2021-03-02 10:23:13 +00:00
echo "Press ENTER to return to the menu..."
2021-03-21 00:31:58 +00:00
read key;;
2021-03-02 10:23:13 +00:00
LOCAL)
2021-11-30 19:37:02 +00:00
connectLocalNode mainnet
2021-03-02 14:53:57 +00:00
sudo systemctl start bitcoind
showBitcoinLogs
echo
2021-03-02 10:23:13 +00:00
echo "Press ENTER to return to the menu..."
2021-03-21 00:31:58 +00:00
read key;;
BTCCONF)
if [ ${#network} -eq 0 ] || [ ${network} = "mainnet" ] || [ "${runningEnv}" = "raspiblitz" ]; then
bitcoinUser="bitcoin"
elif [ ${network} = "signet" ]; then
bitcoinUser="joinmarket"
fi
if /home/joinmarket/set.conf.sh "/home/${bitcoinUser}/.bitcoin/bitcoin.conf" "${bitcoinUser}"
2021-03-21 00:31:58 +00:00
then
echo "# Restarting bitcoind"
sudo systemctl restart bitcoind
showBitcoinLogs
else
echo "# No change made"
fi;;
UPDATE)
/home/joinmarket/menu.update.sh
/home/joinmarket/menu.sh;;
esac