Adding #2152 Homer Dashboard (#2541)

This commit is contained in:
/rootzoll 2022-05-17 22:08:25 +02:00 committed by GitHub
parent 60d357d753
commit d19271d41c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 351 additions and 0 deletions

View file

@ -6,6 +6,7 @@
- New: BackendAPI
- New: ZRAM - compressed swap in memory [details](https://github.com/rootzoll/raspiblitz/issues/2905)
- New: Core Lightning GRPC plugin [details](https://github.com/rootzoll/raspiblitz/pull/3109)
- New: Homer Dashboard [details](https://github.com/bastienwirtz/homer#readme)
- Update: Bitcoin Core v23.0 [details](https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-23.0.md)
- Update: Core Lightning (CLN - formerly C-lightning) v0.11.0.1 [details](https://github.com/ElementsProject/lightning/releases/tag/v0.11.0.1)
- Update: LND v0.14.3 [details](https://github.com/lightningnetwork/lnd/releases/tag/v0.14.3-beta)

View file

@ -159,6 +159,7 @@ There are further Services that can be switched on:
* **Chantools** (Fund Rescue) [details](https://github.com/guggero/chantools/blob/master/README.md)
* **Suez** (Channel Visualization for LND & CL) [details](https://github.com/prusnak/suez#suez)
* **Helipad** (Podcasting 2.0 Boostagram reader) [details](https://github.com/Podcastindex-org/helipad)
* **Homer** (Web Dashboard) [details](https://github.com/bastienwirtz/homer#readme)
* **CL Spark Wallet** (WalletUI with BOLT12 offers) [details](https://github.com/shesek/spark-wallet#progressive-web-app)
* **CL plugin: Sparko** (WalletUI & HTTP-RPC bridge) [details](https://github.com/fiatjaf/sparko#the-sparko-plugin)
* **CL plugin: CLBOSS** (Automated Node Manager) [details](https://github.com/ZmnSCPxj/clboss#clboss-the-c-lightning-node-manager)

View file

@ -147,6 +147,10 @@ fi
if [ "${chantools}" == "on" ]; then
OPTIONS+=(CHANTOOLS "ChannelTools (Fund Rescue)")
fi
if [ "${homer}" == "on" ]; then
OPTIONS+=(HOMER "Homer Dashboard")
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi
if [ "${circuitbreaker}" == "on" ]; then
OPTIONS+=(CIRCUIT "Circuitbreaker (LND firewall)")
fi
@ -315,6 +319,9 @@ case $CHOICE in
SUBSCRIBE)
/home/admin/config.scripts/blitz.subscriptions.py
;;
HOMER)
sudo /home/admin/config.scripts/bonus.homer.sh menu
;;
SERVICES)
/home/admin/00settingsMenuServices.sh
;;

View file

@ -24,6 +24,7 @@ if [ ${#sphinxrelay} -eq 0 ]; then sphinxrelay="off"; fi
if [ ${#lit} -eq 0 ]; then lit="off"; fi
if [ ${#whitepaper} -eq 0 ]; then whitepaper="off"; fi
if [ ${#chantools} -eq 0 ]; then chantools="off"; fi
if [ ${#homer} -eq 0 ]; then homer="off"; fi
if [ ${#sparko} -eq 0 ]; then sparko="off"; fi
if [ ${#spark} -eq 0 ]; then spark="off"; fi
if [ ${#tallycoinConnect} -eq 0 ]; then tallycoinConnect="off"; fi
@ -73,6 +74,8 @@ if [ "${lightning}" == "cl" ] || [ "${cl}" == "on" ]; then
OPTIONS+=(n 'C-Lightning Spark Wallet' ${spark})
fi
OPTIONS+=(m 'Homer Dashboard' ${homer})
CHOICES=$(dialog --title ' Additional Mainnet Services ' \
--checklist ' use spacebar to activate/de-activate ' \
27 55 20 "${OPTIONS[@]}" 2>&1 >/dev/tty)
@ -519,6 +522,24 @@ else
echo "Whitepaper setting unchanged."
fi
# Homer process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "m")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${homer}" != "${choice}" ]; then
echo "Homer settings changed .."
anychange=1
/home/admin/config.scripts/bonus.homer.sh ${choice}
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
whiptail --title " Installed Homer" --msgbox "\
Homer was installed.\n
Use the new 'Homer' entry in Main Menu for more info.\n
" 10 35
fi
else
echo "Homer Setting unchanged."
fi
# BitcoinMinds process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "v")
if [ ${check} -eq 1 ]; then choice="on"; fi

View file

@ -481,6 +481,10 @@ if [ "${sphinxrelay}" == "on" ]; then
OPTIONS+=(SPHINX "Update Sphinx Server Relay")
fi
if [ "${homer}" == "on" ]; then
OPTIONS+=(HOMER "Update Homer")
fi
if [ "${mempoolExplorer}" == "on" ]; then
OPTIONS+=(MEMPOOL "Update Mempool Explorer")
fi
@ -535,6 +539,9 @@ case $CHOICE in
TOR)
sudo /home/admin/config.scripts/tor.network.sh update
;;
HOMER)
/home/admin/config.scripts/bonus.homer.sh update
;;
MEMPOOL)
/home/admin/config.scripts/bonus.mempool.sh update
;;

View file

@ -700,6 +700,15 @@ else
echo "Provisioning CircuitBreaker - keep default" >> ${logFile}
fi
# homer
if [ "${homer}" = "on" ]; then
echo "Provisioning Homer - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup Homer'/g" ${infoFile}
sudo -u admin /home/admin/config.scripts/bonus.homer.sh on >> ${logFile} 2>&1
else
echo "Provisioning Homer - keep default" >> ${logFile}
fi
# tallycoin_connect
if [ "${tallycoinConnect}" = "on" ]; then
echo "Provisioning Tallycoin Connect - run config script" >> ${logFile}

View file

@ -0,0 +1,18 @@
## homer_ssl.conf
server {
listen 4091 ssl;
listen [::]:4091 ssl;
server_name _;
include /etc/nginx/snippets/ssl-params.conf;
include /etc/nginx/snippets/ssl-certificate-app-data.conf;
access_log /var/log/nginx/access_homer.log;
error_log /var/log/nginx/error_homer.log;
root /var/www/homer;
index index.html;
}

View file

@ -0,0 +1,14 @@
## homer_tor.conf
server {
listen localhost:4092;
listen [::1]:4092;
server_name _;
access_log /var/log/nginx/access_homer.log;
error_log /var/log/nginx/error_homer.log;
root /var/www/homer;
index index.html;
}

View file

@ -0,0 +1,17 @@
## homer_tor_ssl.conf
server {
listen localhost:4093;
listen [::1]:4093;
server_name _;
include /etc/nginx/snippets/ssl-params.conf;
include /etc/nginx/snippets/ssl-certificate-app-data-tor.conf;
access_log /var/log/nginx/access_homer.log;
error_log /var/log/nginx/error_homer.log;
root /var/www/homer;
index index.html;
}

View file

@ -0,0 +1,256 @@
#!/bin/bash
# https://github.com/bastienwirtz/homer
installVersion="v21.03.2"
remoteVersion=$(curl -s https://api.github.com/repos/bastienwirtz/homer/releases/latest|grep tag_name|head -1|cut -d '"' -f4)
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "# small config script to switch Homer on or off"
echo "# installs the $installVersion by default"
echo "# bonus.homer.sh [status|on|off|update]"
exit 1
fi
source /mnt/hdd/raspiblitz.conf
# show info menu
if [ "$1" = "menu" ]; then
# get status
echo "# collecting status info ... (please wait)"
source <(sudo /home/admin/config.scripts/bonus.homer.sh status)
# get network info
localip=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0' | grep 'eth0\|wlan0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
toraddress=$(sudo cat /mnt/hdd/tor/homer/hostname 2>/dev/null)
fingerprint=$(openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout | cut -d"=" -f2)
if [ "${runBehindTor}" = "on" ] && [ ${#toraddress} -gt 0 ]; then
# TOR
/home/admin/config.scripts/blitz.display.sh qr "${toraddress}"
whiptail --title " Homer " --msgbox "Open in your local web browser & accept self-signed cert:
https://${localip}:4091\n
SHA1 Thumb/Fingerprint:
${fingerprint}\n
Hidden Service address for TOR Browser (QR see LCD):
${toraddress}
" 16 67
/home/admin/config.scripts/blitz.display.sh hide
else
# IP + Domain
whiptail --title " Homer " --msgbox "Open in your local web browser & accept self-signed cert:
https://${localip}:4091\n
SHA1 Thumb/Fingerprint:
${fingerprint}\n
Activate TOR to access the web block explorer from outside your local network.
" 16 54
fi
echo "please wait ..."
exit 0
fi
# add default value to raspi config if needed
if ! grep -Eq "^homer=" /mnt/hdd/raspiblitz.conf; then
echo "homer=off" >> /mnt/hdd/raspiblitz.conf
fi
# status
if [ "$1" = "status" ]; then
if [ "${homer}" = "on" ]; then
echo "configured=1"
else
echo "configured=0"
fi
exit 0
fi
# Update (quick hack)
# Stores configuration and assets found in /var/www/homer
if [ "$1" = "update" ]; then
cd /home/homer/homer
sudo -u homer git fetch
# Comment out until official release that fixes issue #206
# sudo -u homer git reset --hard $remoteVersion
# Save config file
sudo cp /var/www/homer/assets/config.yml /mnt/hdd/app-data/homer/config.yml
# Save any icons
sudo rsync -av /var/www/homer/assets/icons/ /mnt/hdd/app-data/homer/icons
# Install Homer
sudo -u homer NG_CLI_ANALYTICS=false npm install
if ! [ $? -eq 0 ]; then
echo "FAIL - npm install did not run correctly, aborting"
exit 1
fi
sudo -u homer NG_CLI_ANALYTICS=false npm run build
if ! [ $? -eq 0 ]; then
echo "FAIL - npm run build did not run correctly, aborting"
exit 1
fi
# remove conf link
sudo rm /var/www/homer/assets/config.yml
# copy new dist over to nginx
sudo rsync -av --delete dist/ /var/www/homer/
# link config again
sudo -u www-data ln -s /mnt/hdd/app-data/homer/config.yml /var/www/homer/assets/config.yml
#restore saved icons
sudo rsync -av /mnt/hdd/app-data/homer/icons/ /var/www/homer/assets/icons/
sudo chown -R www-data:www-data /var/www/homer/
echo "# OK - Homer should now be serving latest code from Version $remoteVersion"
exit 0
fi
# switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "# *** INSTALL Homer ***"
isInstalled=$(sudo ls /var/www/homer/assets/config.yml.dist 2>/dev/null | grep -c 'config.yml.dist')
if [ ${isInstalled} -eq 0 ]; then
# add homer user
sudo adduser --disabled-password --gecos "" homer
# install homer
cd /home/homer
sudo -u homer git clone https://github.com/bastienwirtz/homer.git
cd homer
# sudo -u homer git reset --hard $installVersion
sudo -u homer NG_CLI_ANALYTICS=false npm install
if ! [ $? -eq 0 ]; then
echo "FAIL - npm install did not run correctly, aborting"
exit 1
fi
sudo -u homer NG_CLI_ANALYTICS=false npm run build
if ! [ $? -eq 0 ]; then
echo "FAIL - npm run build did not run correctly, aborting"
exit 1
fi
sudo mkdir -p /var/www/homer
sudo rsync -av --delete dist/ /var/www/homer/
sudo chown -R www-data:www-data /var/www/homer
# if no persistent data exists - create data dir & use standard config
oldConfigExists=$(ls /mnt/hdd/app-data/homer/config.yml 2>/dev/null | grep -c 'config.yml')
if [ "${oldConfigExists}" == "0" ]; then
sudo -u homer cp /home/homer/homer/dist/assets/config.yml.dist /home/homer/homer/dist/assets/config.yml
sudo mkdir -p /mnt/hdd/app-data/homer
sudo cp /home/homer/homer/dist/assets/config.yml.dist /mnt/hdd/app-data/homer/config.yml
fi
# link config into nginx directory
sudo chown www-data:www-data /mnt/hdd/app-data/homer/config.yml
sudo -u www-data ln -s /mnt/hdd/app-data/homer/config.yml /var/www/homer/assets/config.yml
##################
# NGINX
##################
if ! [ -f /etc/nginx/sites-available/homer_ssl.conf ]; then
sudo cp /home/admin/assets/nginx/sites-available/homer_ssl.conf /etc/nginx/sites-available/homer_ssl.conf
fi
if ! [ -f /etc/nginx/sites-available/homer_tor.conf ]; then
sudo cp /home/admin/assets/nginx/sites-available/homer_tor.conf /etc/nginx/sites-available/homer_tor.conf
fi
if ! [ -f /etc/nginx/sites-available/homer_tor_ssl.conf ]; then
sudo cp /home/admin/assets/nginx/sites-available/homer_tor_ssl.conf /etc/nginx/sites-available/homer_tor_ssl.conf
fi
sudo ln -sf /etc/nginx/sites-available/homer_ssl.conf /etc/nginx/sites-enabled/
sudo ln -sf /etc/nginx/sites-available/homer_tor.conf /etc/nginx/sites-enabled/
sudo ln -sf /etc/nginx/sites-available/homer_tor_ssl.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
# open the firewall
echo "*** Updating Firewall ***"
sudo ufw allow from any to any port 4090 comment 'allow homer HTTP'
sudo ufw allow from any to any port 4091 comment 'allow homer HTTPS'
echo ""
else
echo "# homer is already installed."
fi
# start the service if ready
source /home/admin/raspiblitz.info
# setting value in raspi blitz config
sudo sed -i "s/^homer=.*/homer=on/g" /mnt/hdd/raspiblitz.conf
# Hidden Service for Mempool if Tor is active
source /mnt/hdd/raspiblitz.conf
if [ "${runBehindTor}" = "on" ]; then
# make sure to keep in sync with internet.tor.sh script
/home/admin/config.scripts/internet.hiddenservice.sh homer 80 4092 443 4093
fi
exit 0
fi
# switch off
# Stores configuration on persistent disk for quick restore
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspi blitz config
sudo sed -i "s/^homer=.*/homer=off/g" /mnt/hdd/raspiblitz.conf
isInstalled=$(sudo ls /var/www/homer/assets/config.yml.dist 2>/dev/null | grep -c 'config.yml.dist')
if [ ${isInstalled} -eq 1 ]; then
echo "Saving assets to external drive. If you no longer require these files, it is safe delete from persistent disk at /mnt/hdd/app-data/homer."
sudo cp /var/www/homer/assets/config.yml /mnt/hdd/app-data/homer/config.yml
sudo rsync -av --delete /var/www/homer/assets/icons/ /mnt/hdd/app-data/homer/icons/
echo "# *** REMOVING homer ***"
# delete user and home directory
sudo userdel -rf homer
sudo rm -rf /var/www/homer
# remove nginx symlinks
sudo rm -f /etc/nginx/sites-enabled/homer_ssl.conf
sudo rm -f /etc/nginx/sites-enabled/homer_tor.conf
sudo rm -f /etc/nginx/sites-enabled/homer_tor_ssl.conf
sudo rm -f /etc/nginx/sites-available/homer_ssl.conf
sudo rm -f /etc/nginx/sites-available/homer_tor.conf
sudo rm -f /etc/nginx/sites-available/homer_tor_ssl.conf
sudo nginx -t
sudo systemctl reload nginx
# Hidden Service if Tor is active
if [ "${runBehindTor}" = "on" ]; then
# make sure to keep in sync with internet.tor.sh script
/home/admin/config.scripts/internet.hiddenservice.sh off homer
fi
echo "# OK Homer removed."
else
echo "# Homer is not installed."
fi
exit 0
fi
echo "error='unknown parameter'"
exit 1