From 742da1b9d776aced61b6c32a1b8eeb6b344e64d1 Mon Sep 17 00:00:00 2001 From: /rootzoll Date: Tue, 1 Aug 2023 22:38:32 +0200 Subject: [PATCH] LNbits Admin Page to allow install extensions (#4054) * add user id to status * activate Admin page on install --- home.admin/config.scripts/bonus.lnbits.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/home.admin/config.scripts/bonus.lnbits.sh b/home.admin/config.scripts/bonus.lnbits.sh index 52577012a..2f2565756 100644 --- a/home.admin/config.scripts/bonus.lnbits.sh +++ b/home.admin/config.scripts/bonus.lnbits.sh @@ -145,7 +145,7 @@ if [ "$1" = "menu" ]; then fundinginfo="on CLN " fi - text="Local Web Browser: https://${localIP}:${httpsPort}" + text="https://${localIP}:${httpsPort}${authMethod}" if [ ${#publicDomain} -gt 0 ]; then text="${text} @@ -180,7 +180,7 @@ To enable easy reachability with normal browser from the outside Consider adding a IP2TOR Bridge under OPTIONS." fi - whiptail --title " LNbits ${fundinginfo}" --yes-button "OK" --no-button "OPTIONS" --yesno "${text}" 18 69 + whiptail --title " LNbits ${fundinginfo}" --yes-button "OK" --no-button "OPTIONS" --yesno "${text}" 18 78 result=$? sudo /home/admin/config.scripts/blitz.display.sh hide echo "option (${result}) - please wait ..." @@ -377,9 +377,12 @@ if [ "$1" = "status" ]; then echo "httpsPort='5001'" echo "httpsForced='1'" echo "httpsSelfsigned='1'" # TODO: change later if IP2Tor+LetsEncrypt is active - echo "authMethod='none'" echo "publicIP='${publicIP}'" + # auth method is to call with a certain useer id + admin_userid=$(sudo cat /home/lnbits/lnbits/.super_user) + echo "authMethod='/wallet?usr=${admin_userid}'" + # check funding source if [ "${LNBitsFunding}" == "" ]; then LNBitsFunding="lnd" @@ -528,6 +531,9 @@ if [ "$1" = "prestart" ]; then exit 1 fi + # protect the admin user id if exists + chmod 640 /home/lnbits/lnbits/.super_user 2>/dev/null + echo "# OK: prestart finished" exit 0 # exit with clean code fi @@ -752,6 +758,10 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then sudo rm /home/lnbits/lnbits/.env 2>/dev/null sudo -u lnbits touch /home/lnbits/lnbits/.env + # activate admin user + sudo sed -i "/^LNBITS_ADMIN_UI=/d" /home/lnbits/lnbits/.env + sudo bash -c "echo 'LNBITS_ADMIN_UI=true' >> /home/lnbits/lnbits/.env" + if [ ! -e /mnt/hdd/app-data/LNBits/database.sqlite3 ]; then echo "# install database: PostgreSQL" # POSTGRES