2020-03-23 16:22:00 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# links:
|
|
|
|
# https://github.com/JoinMarket-Org/joinmarket-clientserver#quickstart---recommended-installation-method-linux-only
|
|
|
|
# https://github.com/openoms/bitcoin-tutorials/tree/master/joinmarket
|
|
|
|
# https://github.com/openoms/joininbox
|
|
|
|
|
2022-07-12 15:41:51 +01:00
|
|
|
JBVERSION="v0.6.8" # installs JoinMarket v0.9.6
|
2020-11-10 23:25:31 +00:00
|
|
|
|
2020-03-23 16:22:00 +00:00
|
|
|
# command info
|
|
|
|
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
|
|
|
echo "JoinMarket install script to switch JoinMarket on or off"
|
|
|
|
echo "sudo /home/admin/config.scrips/bonus.joinmarket.sh on|off"
|
2022-02-18 22:22:47 +00:00
|
|
|
echo "Installs JoininBox $JBVERSION with JoinMarket v0.9.5"
|
2020-03-23 16:22:00 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-03-24 13:07:45 +00:00
|
|
|
# show info menu
|
|
|
|
if [ "$1" = "menu" ]; then
|
2020-09-28 20:32:40 +01:00
|
|
|
whiptail --title " JoinMarket info " --msgbox "
|
2021-03-18 00:50:26 +01:00
|
|
|
Type: 'jm' in the command line to switch to the dedicated user
|
2021-10-01 19:39:44 +01:00
|
|
|
and start the JoininBox menu.
|
|
|
|
Notes on usage:
|
2020-09-28 20:32:40 +01:00
|
|
|
https://github.com/openoms/bitcoin-tutorials/blob/master/joinmarket/README.md
|
2021-10-01 19:39:44 +01:00
|
|
|
" 11 81
|
2020-03-24 13:07:45 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2022-01-05 10:37:25 +00:00
|
|
|
# check if sudo
|
|
|
|
if [ "$EUID" -ne 0 ]
|
|
|
|
then echo "Please run as root (with sudo)"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
PGPsigner="openoms"
|
|
|
|
PGPpubkeyLink="https://github.com/openoms.gpg"
|
|
|
|
PGPpubkeyFingerprint="13C688DB5B9C745DE4D2E4545BFB77609B081B65"
|
|
|
|
|
|
|
|
source /mnt/hdd/raspiblitz.conf
|
|
|
|
|
2020-03-23 16:22:00 +00:00
|
|
|
# switch on
|
|
|
|
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
2021-08-23 17:36:52 +01:00
|
|
|
echo "# INSTALL JOINMARKET"
|
2020-03-23 16:22:00 +00:00
|
|
|
|
2020-03-24 13:07:45 +00:00
|
|
|
# check if running Tor
|
2020-03-23 16:22:00 +00:00
|
|
|
if [ ${runBehindTor} = on ]; then
|
2020-08-25 11:13:41 +01:00
|
|
|
echo "# OK, running behind Tor"
|
2020-03-23 16:22:00 +00:00
|
|
|
else
|
2020-08-25 11:13:41 +01:00
|
|
|
echo "# Not running Tor"
|
|
|
|
echo "# Activate Tor from the SERVICES menu before installing JoinMarket."
|
2020-03-23 16:22:00 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-03-24 13:07:45 +00:00
|
|
|
# make sure the Bitcoin Core wallet is on
|
|
|
|
/home/admin/config.scripts/network.wallet.sh on
|
2022-07-28 15:14:44 +01:00
|
|
|
if [ $(/usr/local/bin/bitcoin-cli -conf=/mnt/hdd/bitcoin/bitcoin.conf listwallets | grep -c wallet.dat) -eq 0 ];then
|
|
|
|
echo "# Create a non-descriptor wallet.dat"
|
|
|
|
/usr/local/bin/bitcoin-cli -conf=/mnt/hdd/bitcoin/bitcoin.conf -named createwallet wallet_name=wallet.dat descriptors=false
|
|
|
|
else
|
|
|
|
isDescriptor=$(/usr/local/bin/bitcoin-cli -conf=/mnt/hdd/bitcoin/bitcoin.conf -rpcwallet=wallet.dat getwalletinfo | grep -c '"descriptors": true,')
|
|
|
|
if [ "$isDescriptor" -gt 0 ]; then
|
|
|
|
# unload
|
|
|
|
bitcoin-cli unloadwallet wallet.dat
|
|
|
|
echo "# Move the wallet.dat with descriptors to /mnt/hdd/bitcoin/descriptors"
|
|
|
|
sudo mv /mnt/hdd/bitcoin/wallet.dat /mnt/hdd/bitcoin/descriptors
|
|
|
|
echo "# Create a non-descriptor wallet.dat"
|
|
|
|
bitcoin-cli -conf=/mnt/hdd/bitcoin/bitcoin.conf -named createwallet wallet_name=wallet.dat descriptors=false
|
|
|
|
else
|
|
|
|
echo "# The non-descriptor wallet.dat is loaded in bitcoind."
|
|
|
|
fi
|
|
|
|
fi
|
2020-03-24 13:07:45 +00:00
|
|
|
|
2020-03-23 16:22:00 +00:00
|
|
|
if [ ! -f "/home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate" ] ; then
|
2020-03-28 06:30:14 +00:00
|
|
|
|
2020-08-25 11:13:41 +01:00
|
|
|
echo "# cleaning before install"
|
2020-03-28 06:30:14 +00:00
|
|
|
sudo userdel -rf joinmarket 2>/dev/null
|
|
|
|
|
2020-08-25 11:13:41 +01:00
|
|
|
echo "# add the 'joinmarket' user"
|
2020-03-23 16:22:00 +00:00
|
|
|
adduser --disabled-password --gecos "" joinmarket
|
|
|
|
|
2020-08-25 11:13:41 +01:00
|
|
|
echo "# setting PASSWORD_B as the password for the 'joinmarket' user"
|
2020-03-23 16:22:00 +00:00
|
|
|
PASSWORD_B=$(sudo cat /mnt/hdd/${network}/${network}.conf | grep rpcpassword | cut -c 13-)
|
|
|
|
echo "joinmarket:$PASSWORD_B" | sudo chpasswd
|
|
|
|
# add to sudo group (required for installation)
|
|
|
|
adduser joinmarket sudo
|
|
|
|
# configure sudo for usage without password entry for the joinmarket user
|
|
|
|
echo 'joinmarket ALL=(ALL) NOPASSWD:ALL' | EDITOR='tee -a' visudo
|
2022-02-18 22:22:47 +00:00
|
|
|
|
|
|
|
# make a folder for authorized keys
|
2020-03-23 16:22:00 +00:00
|
|
|
sudo -u joinmarket mkdir -p /home/joinmarket/.ssh
|
|
|
|
chmod -R 700 /home/joinmarket/.ssh
|
|
|
|
|
|
|
|
# install the command-line fuzzy finder (https://github.com/junegunn/fzf)
|
|
|
|
bash -c "echo 'source /usr/share/doc/fzf/examples/key-bindings.bash' >> /home/joinmarket/.bashrc"
|
|
|
|
|
|
|
|
# store JoinMarket data on HDD
|
|
|
|
mkdir /mnt/hdd/app-data/.joinmarket 2>/dev/null
|
|
|
|
|
|
|
|
# copy old JoinMarket data to app-data
|
2020-03-27 22:10:51 +00:00
|
|
|
cp -rf /home/admin/joinmarket-clientserver/scripts/wallets /mnt/hdd/app-data/.joinmarket/ 2>/dev/null
|
2020-03-23 16:22:00 +00:00
|
|
|
chown -R joinmarket:joinmarket /mnt/hdd/app-data/.joinmarket
|
|
|
|
ln -s /mnt/hdd/app-data/.joinmarket /home/joinmarket/ 2>/dev/null
|
|
|
|
chown -R joinmarket:joinmarket /home/joinmarket/.joinmarket
|
2020-06-30 13:46:42 +01:00
|
|
|
# specify wallet.dat in old config for multiwallet for multiwallet support
|
|
|
|
if [ -f "/home/joinmarket/.joinmarket/joinmarket.cfg" ] ; then
|
2020-09-28 12:05:15 +01:00
|
|
|
sudo -u joinmarket sed -i "s/^rpc_wallet_file =.*/rpc_wallet_file = wallet.dat/g" \
|
|
|
|
/home/joinmarket/.joinmarket/joinmarket.cfg
|
2020-08-25 11:13:41 +01:00
|
|
|
echo "# specified to use wallet.dat in the recovered joinmarket.cfg"
|
2020-06-30 13:46:42 +01:00
|
|
|
fi
|
2020-03-23 16:22:00 +00:00
|
|
|
|
2021-10-01 19:39:44 +01:00
|
|
|
echo "# adding JoininBox"
|
2020-06-19 11:45:46 +01:00
|
|
|
sudo rm -rf /home/joinmarket/joininbox
|
|
|
|
sudo -u joinmarket git clone https://github.com/openoms/joininbox.git /home/joinmarket/joininbox
|
2020-07-16 15:15:27 +01:00
|
|
|
# check the latest at:
|
2021-04-01 14:54:34 +01:00
|
|
|
cd /home/joinmarket/joininbox || exit 1
|
2020-07-16 15:15:27 +01:00
|
|
|
# https://github.com/openoms/joininbox/releases/
|
2021-03-16 22:49:13 +00:00
|
|
|
sudo -u joinmarket git reset --hard $JBVERSION
|
2021-11-30 11:43:52 +00:00
|
|
|
sudo -u joinmarket /home/admin/config.scripts/blitz.git-verify.sh \
|
|
|
|
"${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" || exit 1
|
2021-10-01 19:39:44 +01:00
|
|
|
|
|
|
|
# copy the scripts in place
|
2020-06-19 11:45:46 +01:00
|
|
|
sudo -u joinmarket cp /home/joinmarket/joininbox/scripts/* /home/joinmarket/
|
|
|
|
sudo -u joinmarket cp /home/joinmarket/joininbox/scripts/.* /home/joinmarket/ 2>/dev/null
|
|
|
|
sudo chmod +x /home/joinmarket/*.sh
|
|
|
|
|
2021-10-01 19:39:44 +01:00
|
|
|
echo "# Set ssh access off with the joinmarket user"
|
|
|
|
sudo /home/joinmarket/set.ssh.sh off
|
|
|
|
|
2020-10-14 09:11:30 +01:00
|
|
|
# Tor config
|
|
|
|
# add the joinmarket user to the Tor group
|
|
|
|
usermod -a -G debian-tor joinmarket
|
|
|
|
# fix Tor config
|
|
|
|
sudo sed -i "s:^CookieAuthFile*:#CookieAuthFile:g" /etc/tor/torrc
|
|
|
|
if ! grep -Eq "^CookieAuthentication 1" /etc/tor/torrc; then
|
|
|
|
echo "CookieAuthentication 1" | sudo tee -a /etc/tor/torrc
|
2021-09-28 17:15:42 +01:00
|
|
|
sudo systemctl reload tor@default
|
2020-06-19 11:45:46 +01:00
|
|
|
fi
|
2022-02-18 22:22:47 +00:00
|
|
|
if ! grep -Eq "^AllowOutboundLocalhost 1" /etc/tor/torsocks.conf; then
|
2020-06-19 11:45:46 +01:00
|
|
|
echo "AllowOutboundLocalhost 1" | sudo tee -a /etc/tor/torsocks.conf
|
2021-09-28 17:15:42 +01:00
|
|
|
sudo systemctl reload tor@default
|
2020-06-19 11:45:46 +01:00
|
|
|
fi
|
2020-10-14 09:11:30 +01:00
|
|
|
# joinin.conf settings
|
|
|
|
sudo -u joinmarket touch /home/joinmarket/joinin.conf
|
|
|
|
# add default Tor value to joinin.conf if needed
|
|
|
|
if ! grep -Eq "^runBehindTor" /home/joinmarket/joinin.conf; then
|
|
|
|
echo "runBehindTor=off" | sudo -u joinmarket tee -a /home/joinmarket/joinin.conf
|
|
|
|
fi
|
|
|
|
# setting Tor value in joinin config
|
|
|
|
if grep -Eq "^runBehindTor=on" /mnt/hdd/raspiblitz.conf; then
|
2020-06-19 11:45:46 +01:00
|
|
|
sudo -u joinmarket sed -i "s/^runBehindTor=.*/runBehindTor=on/g" /home/joinmarket/joinin.conf
|
|
|
|
fi
|
2022-01-05 11:21:06 +00:00
|
|
|
|
2022-02-18 22:22:47 +00:00
|
|
|
echo
|
2021-10-01 19:39:44 +01:00
|
|
|
echo "##########"
|
|
|
|
echo "# Extras #"
|
|
|
|
echo "##########"
|
2022-02-18 22:22:47 +00:00
|
|
|
echo
|
2021-10-01 19:39:44 +01:00
|
|
|
# install a command-line fuzzy finder (https://github.com/junegunn/fzf)
|
|
|
|
apt -y install fzf
|
|
|
|
bash -c "echo 'source /usr/share/doc/fzf/examples/key-bindings.bash' >> \
|
|
|
|
/home/joinmarket/.bashrc"
|
2022-02-18 22:22:47 +00:00
|
|
|
|
2021-10-01 19:39:44 +01:00
|
|
|
# install tmux
|
|
|
|
apt -y install tmux
|
2022-02-18 22:22:47 +00:00
|
|
|
|
|
|
|
echo
|
2021-10-01 19:39:44 +01:00
|
|
|
echo "#############"
|
|
|
|
echo "# Autostart #"
|
|
|
|
echo "#############"
|
2020-06-19 11:45:46 +01:00
|
|
|
echo "
|
2021-10-01 19:39:44 +01:00
|
|
|
if [ -f \"/home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate\" ]; then
|
|
|
|
. /home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate
|
|
|
|
/home/joinmarket/joinmarket-clientserver/jmvenv/bin/python -c \"import PySide2\"
|
|
|
|
cd /home/joinmarket/joinmarket-clientserver/scripts/
|
2020-06-19 11:45:46 +01:00
|
|
|
fi
|
|
|
|
# shortcut commands
|
|
|
|
source /home/joinmarket/_commands.sh
|
|
|
|
# automatically start main menu for joinmarket unless
|
|
|
|
# when running in a tmux session
|
|
|
|
if [ -z \"\$TMUX\" ]; then
|
|
|
|
/home/joinmarket/menu.sh
|
|
|
|
fi
|
2021-10-01 19:39:44 +01:00
|
|
|
" | sudo -u joinmarket tee -a /home/joinmarket/.bashrc
|
|
|
|
|
2022-01-05 11:21:06 +00:00
|
|
|
echo "##############################################"
|
|
|
|
echo "# Install JoinMarket and configure JoininBox #"
|
|
|
|
echo "##############################################"
|
|
|
|
echo
|
|
|
|
sudo -u joinmarket /home/joinmarket/start.joininbox.sh
|
2020-03-23 16:22:00 +00:00
|
|
|
|
|
|
|
else
|
2020-04-11 23:47:21 +01:00
|
|
|
echo "JoinMarket is already installed"
|
2021-08-23 17:36:52 +01:00
|
|
|
echo
|
2022-02-18 22:22:47 +00:00
|
|
|
fi
|
|
|
|
|
2020-03-23 16:22:00 +00:00
|
|
|
if [ -f "/home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate" ] ; then
|
2020-03-24 21:42:49 -07:00
|
|
|
# setting value in raspi blitz config
|
2021-12-14 23:34:35 +01:00
|
|
|
/home/admin/config.scripts/blitz.conf.sh set joinmarket "on"
|
2020-03-24 21:42:49 -07:00
|
|
|
# starting info
|
2021-10-01 19:39:44 +01:00
|
|
|
echo
|
2021-08-23 17:36:52 +01:00
|
|
|
echo "# Start to use by logging in to the 'joinmarket' user with:"
|
|
|
|
echo "# 'sudo su joinmarket' or use the shortcut 'jm'"
|
|
|
|
echo
|
2022-02-18 22:22:47 +00:00
|
|
|
|
2020-03-23 16:22:00 +00:00
|
|
|
else
|
|
|
|
echo " Failed to install JoinMarket"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-06-19 11:45:46 +01:00
|
|
|
exit 0
|
2020-03-23 16:22:00 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# switch off
|
|
|
|
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
|
|
|
|
|
|
|
# setting value in raspi blitz config
|
2021-12-14 23:34:35 +01:00
|
|
|
/home/admin/config.scripts/blitz.conf.sh set joinmarket "off"
|
2020-03-23 16:22:00 +00:00
|
|
|
|
|
|
|
if [ -f "/home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate" ] ; then
|
2021-08-23 17:36:52 +01:00
|
|
|
echo "# REMOVING JOINMARKET"
|
2020-03-23 16:22:00 +00:00
|
|
|
sudo userdel -rf joinmarket 2>/dev/null
|
2020-08-25 11:13:41 +01:00
|
|
|
echo "# OK JoinMarket is removed"
|
2022-02-18 22:22:47 +00:00
|
|
|
else
|
2020-03-23 16:22:00 +00:00
|
|
|
echo "JoinMarket is not installed."
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "FAIL - Unknown Parameter $1"
|
2020-09-28 12:05:15 +01:00
|
|
|
echo "may need reboot to run"
|
2020-03-28 10:53:58 +00:00
|
|
|
exit 1
|