mirror of
https://github.com/rootzoll/raspiblitz.git
synced 2024-11-20 02:09:15 +01:00
bos-telegram as service (#3446)
* bos-telegram as service Add OPTIONS menu for balance of satoshi to setup telegram. Asks for the connect code and installs service file * improve first time setup need to start bos telegram manually once to enter HTTP API token from telegram bot creation * Rework BoS telegram menu Improve setup experience invoke bos telegram command from menu and make service install optional * add changes Co-authored-by: rootzoll <christian@geektank.de>
This commit is contained in:
parent
4fd3247386
commit
72eac9e9c3
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
- New: CL Watchtower (The Eye of Satoshi) [details](https://github.com/talaia-labs/rust-teos/tree/master/watchtower-plugin)
|
- New: CL Watchtower (The Eye of Satoshi) [details](https://github.com/talaia-labs/rust-teos/tree/master/watchtower-plugin)
|
||||||
- New: Support of X708 UPS HAT [details](https://github.com/rootzoll/raspiblitz/pull/3087)
|
- New: Support of X708 UPS HAT [details](https://github.com/rootzoll/raspiblitz/pull/3087)
|
||||||
|
- New: BOS Telegram Bot Support (see OPTIONS on LND Balance of Satoshis menu entry)
|
||||||
- New: LightningTipBot v0.5 [details](https://github.com/LightningTipBot/LightningTipBot)
|
- New: LightningTipBot v0.5 [details](https://github.com/LightningTipBot/LightningTipBot)
|
||||||
- Update: Bitcoin Core v24.0 [details](https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-24.0.md)
|
- Update: Bitcoin Core v24.0 [details](https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-24.0.md)
|
||||||
- Update: LND v0.15.5 [details](https://github.com/lightningnetwork/lnd/releases/tag/v0.15.5-beta
|
- Update: LND v0.15.5 [details](https://github.com/lightningnetwork/lnd/releases/tag/v0.15.5-beta
|
||||||
|
@ -6,7 +6,7 @@ BOSVERSION="13.6.0"
|
|||||||
# command info
|
# command info
|
||||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||||
echo "config script to install, update or uninstall Balance of Satoshis"
|
echo "config script to install, update or uninstall Balance of Satoshis"
|
||||||
echo "bonus.bos.sh [on|off|menu|update]"
|
echo "bonus.bos.sh [on|off|menu|update|telegram]"
|
||||||
echo "installs the version $BOSVERSION by default"
|
echo "installs the version $BOSVERSION by default"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -15,15 +15,167 @@ source /mnt/hdd/raspiblitz.conf
|
|||||||
|
|
||||||
# show info menu
|
# show info menu
|
||||||
if [ "$1" = "menu" ]; then
|
if [ "$1" = "menu" ]; then
|
||||||
dialog --title " Info Balance of Satoshis " --msgbox "
|
|
||||||
|
text="
|
||||||
Balance of Satoshis is a command line tool.
|
Balance of Satoshis is a command line tool.
|
||||||
Type: 'bos' in the command line to switch to the dedicated user.
|
Type: 'bos' in the command line to switch to the dedicated user.
|
||||||
Then see 'bos help' for the options. Usage:
|
Then see 'bos help' for the options. Usage:
|
||||||
https://github.com/alexbosworth/balanceofsatoshis/blob/master/README.md
|
https://github.com/alexbosworth/balanceofsatoshis/blob/master/README.md
|
||||||
" 10 75
|
"
|
||||||
|
|
||||||
|
whiptail --title " Info Balance of Satoshis" --yes-button "OK" --no-button "OPTIONS" --yesno "${text}" 10 75
|
||||||
|
result=$?
|
||||||
|
sudo /home/admin/config.scripts/blitz.display.sh hide
|
||||||
|
echo "option (${result}) - please wait ..."
|
||||||
|
|
||||||
|
# exit when user presses OK to close menu
|
||||||
|
if [ ${result} -eq 0 ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Balance of Satoshis OPTIONS menu
|
||||||
|
OPTIONS=()
|
||||||
|
OPTIONS+=(TELEGRAM-SETUP "Setup or renew BoS telegram bot")
|
||||||
|
if [ -e /etc/systemd/system/bos-telegram.service ]; then
|
||||||
|
OPTIONS+=(TELEGRAM-DISABLE "Remove BoS telegram bot service")
|
||||||
|
else
|
||||||
|
OPTIONS+=(TELEGRAM-SERVICE "Install BoS telegram bot as a service")
|
||||||
|
fi
|
||||||
|
|
||||||
|
WIDTH=66
|
||||||
|
CHOICE_HEIGHT=$(("${#OPTIONS[@]}/2+1"))
|
||||||
|
HEIGHT=$((CHOICE_HEIGHT+7))
|
||||||
|
CHOICE=$(dialog --clear \
|
||||||
|
--title " BoS - Options" \
|
||||||
|
--ok-label "Select" \
|
||||||
|
--cancel-label "Back" \
|
||||||
|
--menu "Choose one of the following options:" \
|
||||||
|
$HEIGHT $WIDTH $CHOICE_HEIGHT \
|
||||||
|
"${OPTIONS[@]}" \
|
||||||
|
2>&1 >/dev/tty)
|
||||||
|
|
||||||
|
case $CHOICE in
|
||||||
|
TELEGRAM-DISABLE)
|
||||||
|
clear
|
||||||
|
/home/admin/config.scripts/bonus.bos.sh telegram off
|
||||||
|
echo
|
||||||
|
echo "OK telegram disabled."
|
||||||
|
echo "PRESS ENTER to continue"
|
||||||
|
read key
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
TELEGRAM-SETUP)
|
||||||
|
clear
|
||||||
|
whiptail --title " First time setup instructions " \
|
||||||
|
--yes-button "Back" \
|
||||||
|
--no-button "Setup" \
|
||||||
|
--yesno "1. Create your telegram bot: https://t.me/botfather\n
|
||||||
|
2. BoS asks for HTTP API Token given from telegram.\n
|
||||||
|
3. BoS asks for your connection code (Bot command: /connect)\n
|
||||||
|
Start BoS telegram setup now?" 14 72
|
||||||
|
if [ "$?" != "1" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
sudo bash /home/admin/config.scripts/bonus.bos.sh telegram setup
|
||||||
|
echo
|
||||||
|
echo "OK Balance of Satoshis telegram setup done."
|
||||||
|
echo "PRESS ENTER to continue"
|
||||||
|
read key
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
TELEGRAM-SERVICE)
|
||||||
|
clear
|
||||||
|
connectMsg="
|
||||||
|
Start chatting with the bot for connect code (/connect)\n
|
||||||
|
Please enter the CONNECT CODE from your telegram bot
|
||||||
|
"
|
||||||
|
connectCode=$(whiptail --inputbox "$connectMsg" 14 62 --title "Connect Telegram Bot" 3>&1 1>&2 2>&3)
|
||||||
|
exitstatus=$?
|
||||||
|
if [ $exitstatus = 0 ]; then
|
||||||
|
connectCode=$(echo "${connectCode}" | cut -d " " -f1)
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
/home/admin/config.scripts/bonus.bos.sh telegram on ${connectCode}
|
||||||
|
echo
|
||||||
|
echo "OK BoS telegram service active."
|
||||||
|
echo "PRESS ENTER to continue"
|
||||||
|
read key
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
clear
|
||||||
|
exit 0
|
||||||
|
esac
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# telegram on
|
||||||
|
if [ "$1" = "telegram" ] && [ "$2" = "on" ] && [ "$3" != "" ] ; then
|
||||||
|
sudo rm /etc/systemd/system/bos-telegram.service 2>/dev/null
|
||||||
|
|
||||||
|
# install service
|
||||||
|
echo "*** INSTALL BoS Telegram ***"
|
||||||
|
cat <<EOF | sudo tee /etc/systemd/system/bos-telegram.service >/dev/null
|
||||||
|
# systemd unit for bos telegram
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Balance of Satoshis Telegram Bot
|
||||||
|
Wants=network-online.target
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
WorkingDirectory=/home/bos/balanceofsatoshis
|
||||||
|
ExecStart=/home/bos/.npm-global/bin/bos telegram --connect $3 -v
|
||||||
|
User=bos
|
||||||
|
Group=bos
|
||||||
|
Restart=always
|
||||||
|
TimeoutSec=120
|
||||||
|
RestartSec=15
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sudo systemctl enable bos-telegram
|
||||||
|
sudo systemctl start bos-telegram
|
||||||
|
|
||||||
|
# check for error
|
||||||
|
isDead=$(sudo systemctl status bos-telegram | grep -c 'inactive (dead)')
|
||||||
|
if [ ${isDead} -eq 1 ]; then
|
||||||
|
echo "error='Service Failed'"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# telegram off
|
||||||
|
if [ "$1" = "telegram" ] && [ "$2" = "off" ]; then
|
||||||
|
echo "*** DISABLE BoS Telegram ***"
|
||||||
|
isInstalled=$(sudo ls /etc/systemd/system/bos-telegram.service 2>/dev/null | grep -c 'bos-telegram.service')
|
||||||
|
if [ ${isInstalled} -eq 1 ]; then
|
||||||
|
sudo systemctl stop bos-telegram
|
||||||
|
sudo systemctl disable bos-telegram
|
||||||
|
sudo rm /etc/systemd/system/bos-telegram.service
|
||||||
|
echo "OK bos-telegram.service removed."
|
||||||
|
else
|
||||||
|
echo "bos-telegram.service is not installed."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "result='OK'"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# telegram bot setup
|
||||||
|
if [ "$1" = "telegram" ] && [ "$2" = "setup" ]; then
|
||||||
|
/home/admin/config.scripts/bonus.bos.sh telegram off
|
||||||
|
echo "*** SETUP BoS Telegram ***"
|
||||||
|
echo "Wait to start 'bos telegram --reset-api-key' (CTRL + C when done) ..."
|
||||||
|
sudo -u bos /home/bos/.npm-global/bin/bos telegram --reset-api-key
|
||||||
|
fi
|
||||||
|
|
||||||
# install
|
# install
|
||||||
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user