joininbox/scripts/menu.yg.sh

124 lines
4 KiB
Bash
Raw Normal View History

2020-06-15 15:35:18 +01:00
#!/bin/bash
# add default value to joinin config if needed
if ! grep -Eq "^YGwallet=" /home/joinmarket/joinin.conf; then
echo "YGwallet=nil" >> /home/joinmarket/joinin.conf
fi
2020-06-15 15:35:18 +01:00
# YG menu options
source /home/joinmarket/_functions.sh
2020-06-15 15:35:18 +01:00
source /home/joinmarket/joinin.conf
# BASIC MENU INFO
2020-10-14 09:39:28 +01:00
HEIGHT=13
2020-06-15 15:35:18 +01:00
WIDTH=52
CHOICE_HEIGHT=20
2020-10-14 09:39:28 +01:00
TITLE="Yield Generator options"
MENU=""
2020-06-15 15:35:18 +01:00
OPTIONS=()
BACKTITLE="JoininBox GUI"
# Basic Options
OPTIONS+=(\
MAKER "Run the Yield Generator" \
YGCONF "Configure the Yield Generator" \
YGLIST "List the past YG activity" \
NICKNAME "Show the last used counterparty name" \
2020-06-18 15:02:17 +01:00
SERVICE "Monitor the YG service (INFO)" \
LOGS "View the last YG logfile (DEBUG)" \
2020-06-15 15:35:18 +01:00
STOP "Stop the YG service" \
)
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
case $CHOICE in
MAKER)
2020-06-22 15:15:28 +01:00
# wallet
chooseWallet
# save wallet in conf
2020-07-01 15:03:11 +01:00
sudo sed -i "s#^YGwallet=.*#YGwallet=$(cat $wallet)#g" /home/joinmarket/joinin.conf
2020-06-22 15:33:40 +01:00
# get password
passwordToFile
2020-06-22 15:15:28 +01:00
echo "Using the wallet: $(cat $wallet)"
/home/joinmarket/start.service.sh yg-privacyenhanced $(cat $wallet)
2020-06-15 15:35:18 +01:00
echo ""
2020-09-09 11:52:35 +01:00
echo "# started the Yield Generator in the background"
2020-06-15 15:35:18 +01:00
echo ""
2020-09-09 11:52:35 +01:00
echo "# showing the systemd status ..."
2020-06-15 15:35:18 +01:00
sleep 3
dialog \
--title "Monitoring the Yield Generator - press CTRL+C to exit" \
2020-09-30 14:31:34 +01:00
--prgbox "sudo journalctl -fn20 -u yg-privacyenhanced" 30 200
2020-09-09 11:52:35 +01:00
echo "# returning to the menu..."
2020-06-17 11:07:02 +01:00
sleep 1
2020-06-19 11:20:58 +01:00
/home/joinmarket/menu.yg.sh
2020-06-15 15:35:18 +01:00
;;
YGCONF)
/home/joinmarket/set.conf.sh /home/joinmarket/joinmarket-clientserver/scripts/yg-privacyenhanced.py
2020-09-09 11:52:35 +01:00
echo "# returning to the menu..."
2020-06-19 11:20:58 +01:00
/home/joinmarket/menu.yg.sh
2020-06-15 15:35:18 +01:00
;;
YGLIST)
dialog \
--title "timestamp cj amount/satoshi my input count my input value/satoshi cjfee/satoshi earned/satoshi confirm time/min notes" \
2020-10-28 14:06:38 +00:00
--prgbox "column /home/joinmarket/.joinmarket/logs/yigen-statement.csv -t -s ","" 100 140
2020-09-09 11:52:35 +01:00
echo "# returning to the menu..."
2020-06-17 11:07:02 +01:00
sleep 1
2020-06-19 11:20:58 +01:00
/home/joinmarket/menu.yg.sh
2020-06-15 15:35:18 +01:00
;;
NICKNAME)
name=$(ls -t /home/joinmarket/.joinmarket/logs | grep J5 | head -n 1 | cut -c -16)
whiptail \
--title "Counterparty name" \
2020-10-27 15:07:16 +00:00
--msgbox "The last used counterparty name for the Order Book:\n
$name\n
2021-01-19 22:38:00 +00:00
Check if active in: https://nixbitcoin.org/obwatcher/
2020-10-27 15:07:16 +00:00
or use the local Order Book" 12 55
2020-06-18 17:33:57 +01:00
echo "Returning to the menu..."
sleep 1
2020-06-19 11:20:58 +01:00
/home/joinmarket/menu.yg.sh
2020-06-18 15:02:17 +01:00
;;
SERVICE)
dialog \
--title "Monitoring the Yield Generator" \
--msgbox "
Shows the service status with INFO logs using:
2020-06-18 15:02:17 +01:00
sudo systemctl status yg-privacyenhanced
2020-06-18 15:02:17 +01:00
2020-06-19 11:20:58 +01:00
Press CTRL+C to exit to the command line.
Use: 'menu' for the JoininBox options." 11 50
sudo systemctl status yg-privacyenhanced
2020-06-18 15:02:17 +01:00
;;
LOGS)
dialog \
--title "Monitoring the Yield Generator" \
--msgbox "
Will tail the latest YG logfile from:
/home/joinmarket/.joinmarket/logs/
Press CTRL+C to exit and return to the menu." 10 50
cd /home/joinmarket/.joinmarket/logs
ls -t | grep J5 | head -n 1 | xargs tail -fn1000
echo ""
echo "Press ENTER to return to menu"
read key
cd /home/joinmarket/joinmarket-clientserver/scripts/
2020-06-19 11:20:58 +01:00
/home/joinmarket/menu.yg.sh
;;
2020-06-15 15:35:18 +01:00
STOP)
stopYG
echo ""
echo "Press ENTER to return to the menu..."
read key
2020-06-15 15:35:18 +01:00
;;
2020-06-18 15:02:17 +01:00
esac