mirror of
https://github.com/openoms/joininbox.git
synced 2026-08-19 13:18:11 +02:00
offers: add the offer book and improve logic
fixes: https://github.com/rootzoll/raspiblitz/issues/1425
This commit is contained in:
parent
099d87b82a
commit
7c9d0f694a
3 changed files with 115 additions and 64 deletions
110
scripts/menu.offerbook.sh
Executable file
110
scripts/menu.offerbook.sh
Executable file
|
|
@ -0,0 +1,110 @@
|
|||
#!/bin/bash
|
||||
|
||||
source /home/joinmarket/joinin.conf
|
||||
source /home/joinmarket/menu.functions.sh
|
||||
|
||||
function stopOfferBook() {
|
||||
echo "Stopping the ob-watcher background service"
|
||||
pkill -sigint -f "python ob-watcher.py"
|
||||
sudo systemctl stop ob-watcher
|
||||
sudo systemctl disable ob-watcher 2>/dev/null
|
||||
}
|
||||
|
||||
function showOfferBookAddress() {
|
||||
running=$(ps $(pidof python) | grep -c "python ob-watcher.py")
|
||||
if [ $running -gt 0 ]; then
|
||||
TOR_ADDRESS=$(sudo cat $HiddenServiceDir/ob-watcher/hostname)
|
||||
whiptail --title "Started the ob-watcher service" \
|
||||
--msgbox "\nVisit the address in the Tor Browser:\n$TOR_ADDRESS" 9 66
|
||||
else
|
||||
startOfferBook
|
||||
showOfferBookAddress
|
||||
fi
|
||||
}
|
||||
|
||||
function startOfferBook() {
|
||||
echo "# Checking matplotlib"
|
||||
. /home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate
|
||||
depend=$(pip show matplotlib | grep -c "matplotlib")
|
||||
if [ $depend -lt 1 ]; then
|
||||
pip install matplotlib
|
||||
else
|
||||
echo "matplotlib is installed"
|
||||
fi
|
||||
|
||||
stopOfferBook
|
||||
|
||||
echo "
|
||||
[Unit]
|
||||
Description=ob-watcher
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/home/joinmarket/joinmarket-clientserver/scripts/obwatch
|
||||
ExecStart=/bin/sh -c \
|
||||
'. /home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate && \
|
||||
python ob-watcher.py'
|
||||
User=joinmarket
|
||||
Group=joinmarket
|
||||
Type=simple
|
||||
KillMode=process
|
||||
TimeoutSec=600
|
||||
Restart=no
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
" | sudo tee /etc/systemd/system/ob-watcher.service 1>/dev/null
|
||||
sudo systemctl enable ob-watcher 2>/dev/null
|
||||
sudo systemctl start ob-watcher
|
||||
|
||||
# create the Hidden Service
|
||||
/home/joinmarket/install.hiddenservice.sh ob-watcher 80 62601
|
||||
|
||||
echo ""
|
||||
echo "Started watching the Offer Book in the background"
|
||||
echo ""
|
||||
echo "Showing the systemd status ..."
|
||||
sleep 3
|
||||
dialog \
|
||||
--title "Monitoring the ob-watcher - press CTRL+C to exit" \
|
||||
--prgbox "sudo journalctl -fn20 -u ob-watcher" 30 140
|
||||
|
||||
}
|
||||
|
||||
# BASIC MENU INFO
|
||||
HEIGHT=11
|
||||
WIDTH=48
|
||||
CHOICE_HEIGHT=20
|
||||
TITLE="JoininBox"
|
||||
MENU="
|
||||
Offer Book options:"
|
||||
OPTIONS=()
|
||||
BACKTITLE="JoininBox GUI"
|
||||
|
||||
# Basic Options
|
||||
OPTIONS+=(\
|
||||
START "Start watching locally" \
|
||||
SHOW "Show the local Offer Book address" \
|
||||
STOP "Stop the background process"
|
||||
)
|
||||
|
||||
CHOICE=$(dialog --clear \
|
||||
--backtitle "$BACKTITLE" \
|
||||
--title "$TITLE" \
|
||||
--menu "$MENU" \
|
||||
$HEIGHT $WIDTH $CHOICE_HEIGHT \
|
||||
"${OPTIONS[@]}" \
|
||||
2>&1 >/dev/tty)
|
||||
|
||||
case $CHOICE in
|
||||
START)
|
||||
startOfferBook
|
||||
;;
|
||||
SHOW)
|
||||
showOfferBookAddress
|
||||
;;
|
||||
STOP)
|
||||
stopOfferBook
|
||||
echo "Press ENTER to return to the menu..."
|
||||
read key
|
||||
;;
|
||||
esac
|
||||
|
|
@ -45,7 +45,7 @@ OPTIONS+=(\
|
|||
FREEZE "Exercise coin control within a mixdepth" \
|
||||
PAYJOIN "Send/Receive between JoinMarket wallets"
|
||||
"" ""
|
||||
OFFERS "Watch the offer book locally" \
|
||||
OFFERS "Watch the Offer Book locally" \
|
||||
"" ""
|
||||
CONFIG "Edit the joinmarket.cfg" \
|
||||
UPDATE "Update the JoininBox scripts and menu" \
|
||||
|
|
@ -87,8 +87,6 @@ Leave the box empty to show the addresses in all five" 10 64 2> $mixdepth
|
|||
;;
|
||||
QTGUI)
|
||||
/home/joinmarket/info.qtgui.sh
|
||||
echo "Returning to the menu..."
|
||||
sleep 1
|
||||
/home/joinmarket/menu.sh
|
||||
;;
|
||||
MAKER)
|
||||
|
|
@ -97,35 +95,18 @@ Leave the box empty to show the addresses in all five" 10 64 2> $mixdepth
|
|||
;;
|
||||
SEND)
|
||||
/home/joinmarket/menu.send.sh
|
||||
/home/joinmarket/menu.sh
|
||||
;;
|
||||
FREEZE)
|
||||
/home/joinmarket/menu.freeze.sh
|
||||
/home/joinmarket/menu.sh
|
||||
;;
|
||||
PAYJOIN)
|
||||
/home/joinmarket/menu.payjoin.sh
|
||||
/home/joinmarket/menu.sh
|
||||
;;
|
||||
OFFERS)
|
||||
#TODO show hidden service only if already running
|
||||
/home/joinmarket/start.ob-watcher.sh
|
||||
errorOnInstall=$?
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
TOR_ADDRESS=$(sudo cat $HiddenServiceDir/ob-watcher/hostname)
|
||||
whiptail --title "Started the ob-watcher service" \
|
||||
--msgbox "\nVisit the address in the Tor Browser:\n$TOR_ADDRESS" 9 66
|
||||
else
|
||||
DIALOGRC=.dialogrc.onerror dialog --title "Error during install" \
|
||||
--msgbox "\nPlease search or report at:\n https://github.com/openoms/joininbox/issues" 7 56
|
||||
fi
|
||||
echo ""
|
||||
echo "Started watching the Offer Book in the background"
|
||||
echo ""
|
||||
echo "Showing the systemd status ..."
|
||||
sleep 3
|
||||
dialog \
|
||||
--title "Monitoring the ob-watcher - press CTRL+C to exit" \
|
||||
--prgbox "sudo journalctl -fn20 -u ob-watcher" 30 140
|
||||
echo "Returning to the menu..."
|
||||
sleep 1
|
||||
/home/joinmarket/menu.offerbook.sh
|
||||
/home/joinmarket/menu.sh
|
||||
;;
|
||||
CONFIG)
|
||||
|
|
@ -143,8 +124,6 @@ Leave the box empty to show the addresses in all five" 10 64 2> $mixdepth
|
|||
;;
|
||||
UPDATE)
|
||||
/home/joinmarket/update.joininbox.sh
|
||||
echo "Returning to the menu..."
|
||||
sleep 1
|
||||
/home/joinmarket/menu.sh
|
||||
;;
|
||||
X)
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#install dependency
|
||||
. /home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate
|
||||
|
||||
echo "installing matplotlib"
|
||||
pip install matplotlib
|
||||
|
||||
SCRIPT="ob-watcher"
|
||||
|
||||
sudo systemctl stop $SCRIPT
|
||||
sudo systemctl disable $SCRIPT 2>/dev/null
|
||||
sleep 5
|
||||
|
||||
echo "
|
||||
[Unit]
|
||||
Description=$SCRIPT
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/home/joinmarket/joinmarket-clientserver/scripts/obwatch
|
||||
ExecStart=/bin/sh -c \
|
||||
'. /home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate && \
|
||||
python ob-watcher.py'
|
||||
User=joinmarket
|
||||
Group=joinmarket
|
||||
Type=simple
|
||||
KillMode=process
|
||||
TimeoutSec=600
|
||||
Restart=no
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
" | sudo tee /etc/systemd/system/$SCRIPT.service 1>/dev/null
|
||||
sudo systemctl enable $SCRIPT 2>/dev/null
|
||||
sudo systemctl start $SCRIPT
|
||||
|
||||
#create Hidden Service
|
||||
/home/joinmarket/install.hiddenservice.sh ob-watcher 80 62601
|
||||
Loading…
Add table
Add a link
Reference in a new issue