add scripts for updating, adding coins and upgrading nodes

This commit is contained in:
nahuhh 2024-01-22 17:06:38 -05:00
parent 118b4f84e0
commit 2f0c57e6c9
9 changed files with 93 additions and 9 deletions

View file

@ -1,12 +1,18 @@
# basicswap-bash
A BasicSwapDEX bash installer for Debian/Ubuntu
# Installation
### Installation
```bash
wget https://github.com/nahuhh/basicswap-bash/releases/latest/download/basicswap-bash.tar.gz
tar xvf basicswap-bash.tar.gz
cd basicswap-bash && ./install.sh
```
# Running BasicSwapDEX
### Running BasicSwapDEX
`basicswap-bash`
### Add coins
`bsx-addcoin`
### Update BSX core
`bsx-update`
### Update blockchains
`bsx-upgrade-coins`

4
bsx-addcoin Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
./dep/addcoin.sh

4
bsx-update Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
./dep/update.sh

4
bsx-upgrade-coins Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
./dep/upgradecoins.sh

28
dep/addcoin.sh Executable file
View file

@ -0,0 +1,28 @@
#!/bin/bash
## Prompt for user input
echo -e "\n\nThe following coins can be added (case sensitive)\nbitcoin\ndash\nfiro\nlitecoin\nparticl\nPIVX\n"
read -p 'Full name of coin to add [example: litecoin] ' addcoin
## Confirm
echo -e "\nAdd $addcoin to your BasicSwap install, correct? Press any key to continue. CTRL-C to exit"
read
## Add the coin
if [ $addcoin = bitcoin ]; then
read -p 'Use --usebtcfastsync for bitcoin? [Y/n] ' btcfastsync
case $btcfastsync in
n | N) confirmed=no;;
*) confirmed=yes;;
esac
if [ $confirmed = yes ]; then
echo using btcfastsync
basicswap-prepare --usebtcfastsync --datadir=/$SWAP_DATADIR --addcoin=$addcoin
else
echo "not using btcfastsync"
basicswap-prepare --datadir=/$SWAP_DATADIR --addcoin=$addcoin
fi
else
echo "not using bitcoin, using $addcoin"
basicswap-prepare --datadir=/$SWAP_DATADIR --addcoin=$addcoin
fi

View file

@ -12,15 +12,19 @@ pip3 install .
cd $SWAP_DATADIR
git clone https://github.com/tecnovert/basicswap.git
cd $SWAP_DATADIR/basicswap
## Install basicswap
protoc -I=basicswap --python_out=basicswap basicswap/messages.proto
pip3 install .
mv basicswap-bash dep/startup.sh /usr/local/bin
# Move scripts to /usr/local/bin
cd $SWAP_DATADIR
sudo mv -f -t /usr/local/bin/ basicswap-bash bsx* dep
## Run basicswap-prepare with particl and monero
CURRENT_XMR_HEIGHT=$(curl "http://$monerod_addr:$monerod_port/get_info" | jq .height)
XMR_RPC_HOST=$monerod_addr BASE_XMR_RPC_PORT=$monerod_port basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero --xmrrestoreheight=$CURRENT_XMR_HEIGHT
echo -e "\n\nMake note of your seed above\n"
$red; echo -e "\n\nMake note of your seed above\n"; $nocolor
echo 'Install complete.
Use `basicswap-bash` to run, `update.sh` to update, and `addcoin.sh` to add a coin'
Use `basicswap-bash` to run, `bsx-update` to update, and `bsx-addcoin` to add a coin'

4
dep/update.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
cd $SWAP_DATADIR/basicswap
git pull
pip3 install .

13
dep/upgradecoins.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
## Prompt for user input
echo "You can only update coins which you have already added to your install"
echo -e "\n\nList of coins supported by BasicSwapDEX (case sensitive):\nbitcoin\ndash\nfiro\nlitecoin\nparticl\nPIVX\n"
read -p 'Full name of coin to update [example: litecoin] ' updatecoin
## Confirm
read -p $'\nUpdating $updatecoin, correct? Press any key to continue. CTRL-C to exit'
## Update the coin
basicswap-prepare --datadir=$SWAP_DATADIR -preparebinonly --withcoins=$updatecoin
echo "updating $updatecoin"

View file

@ -1,14 +1,31 @@
#/bin/bash
# Colors
cyan="echo -e -n \e[36;1m"
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
# Title Bar
$green
echo -e "\n"
title="BasicSwapDEX installer"
COLUMNS=$(tput cols)
title_size=${#title}
span=$(((COLUMNS + title_size) / 2))
printf "%${COLUMNS}s" " " | tr " " "*"
printf "%${span}s\n" "$title"
printf "%${COLUMNS}s" " " | tr " " "*"
$nocolor
## Configure Monero node
read -p 'Enter Address of Monero node [example: http://192.168.1.123] ' monerod_addr
read -p $'\n\nEnter Address of Monero node [example: http://192.168.1.123] ' monerod_addr
read -p 'Enter RPC Port for the Monero node [example: 18081] ' monerod_port
printf $monerod_addr:$monerod_port
echo -e "\nPress anykey to continue, or CTRL-C to exit." && read
$green; printf $monerod_addr:$monerod_port; $nocolor
echo -e "\nPress any key to continue, or CTRL-C to exit." && read
## Update & Install dependencies
sudo apt update
echo "Installing" && sleep 2
sudo apt install -y git wget python3-full python3-pip gnupg unzip protobuf-compiler automake libtool pkg-config curl jq
## Make venv