mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-11-18 09:57:17 +01:00
Compare commits
9 Commits
v1.12.0
...
v1.11-alby
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef2a86d2aa | ||
|
|
59157c2874 | ||
|
|
c0418499e2 | ||
|
|
3da6db91d0 | ||
|
|
2ac7b19151 | ||
|
|
083c33317e | ||
|
|
5bb31130b8 | ||
|
|
e4adac1e67 | ||
|
|
d24feeade5 |
@@ -180,6 +180,9 @@ fi
|
|||||||
if [ "${telegraf}" == "on" ]; then
|
if [ "${telegraf}" == "on" ]; then
|
||||||
OPTIONS+=(TELEGRAF "Telegraf InfluxDB/Grafana Metrics")
|
OPTIONS+=(TELEGRAF "Telegraf InfluxDB/Grafana Metrics")
|
||||||
fi
|
fi
|
||||||
|
if [ "${albyhub}" == "on" ]; then
|
||||||
|
OPTIONS+=(ALBYHUB "AlbyHub")
|
||||||
|
fi
|
||||||
|
|
||||||
# dont offer to switch to "testnet view for now" - so no wswitch back to mainnet needed
|
# dont offer to switch to "testnet view for now" - so no wswitch back to mainnet needed
|
||||||
#if [ ${chain} != "main" ]; then
|
#if [ ${chain} != "main" ]; then
|
||||||
@@ -355,6 +358,9 @@ case $CHOICE in
|
|||||||
FINTS)
|
FINTS)
|
||||||
sudo /home/admin/config.scripts/bonus.fints.sh menu
|
sudo /home/admin/config.scripts/bonus.fints.sh menu
|
||||||
;;
|
;;
|
||||||
|
ALBYHUB)
|
||||||
|
/home/admin/config.scripts/bonus.albyhub.sh menu
|
||||||
|
;;
|
||||||
TESTNETS)
|
TESTNETS)
|
||||||
/home/admin/00parallelChainsMenu.sh
|
/home/admin/00parallelChainsMenu.sh
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ if [ ${#fints} -eq 0 ]; then fints="off"; fi
|
|||||||
if [ ${#lndk} -eq 0 ]; then lndk="off"; fi
|
if [ ${#lndk} -eq 0 ]; then lndk="off"; fi
|
||||||
if [ ${#labelbase} -eq 0 ]; then labelbase="off"; fi
|
if [ ${#labelbase} -eq 0 ]; then labelbase="off"; fi
|
||||||
if [ ${#publicpool} -eq 0 ]; then publicpool="off"; fi
|
if [ ${#publicpool} -eq 0 ]; then publicpool="off"; fi
|
||||||
|
if [ ${#albyhub} -eq 0 ]; then albyhub="off"; fi
|
||||||
|
if [ "${albyhub}" == "on" ] && [ $(sudo ls /etc/systemd/system/albyhub.service 2>/dev/null | grep -c 'albyhub.service') -lt 1 ]; then albyhub="off"; fi
|
||||||
|
|
||||||
# show select dialog
|
# show select dialog
|
||||||
echo "run dialog ..."
|
echo "run dialog ..."
|
||||||
@@ -63,6 +65,7 @@ if [ "${lightning}" == "lnd" ] || [ "${lnd}" == "on" ]; then
|
|||||||
OPTIONS+=(ra 'LND RTL Webinterface' ${rtlWebinterface})
|
OPTIONS+=(ra 'LND RTL Webinterface' ${rtlWebinterface})
|
||||||
OPTIONS+=(ta 'LND ThunderHub' ${thunderhub})
|
OPTIONS+=(ta 'LND ThunderHub' ${thunderhub})
|
||||||
OPTIONS+=(la 'LND LIT (loop, pool, faraday)' ${lit})
|
OPTIONS+=(la 'LND LIT (loop, pool, faraday)' ${lit})
|
||||||
|
OPTIONS+=(ah 'LND AlbyHub (early access)' ${albyhub})
|
||||||
OPTIONS+=(gb 'LND LNDg (auto-rebalance, auto-fees)' ${lndg})
|
OPTIONS+=(gb 'LND LNDg (auto-rebalance, auto-fees)' ${lndg})
|
||||||
OPTIONS+=(oa 'LND Balance of Satoshis' ${bos})
|
OPTIONS+=(oa 'LND Balance of Satoshis' ${bos})
|
||||||
OPTIONS+=(ya 'LND PyBLOCK' ${pyblock})
|
OPTIONS+=(ya 'LND PyBLOCK' ${pyblock})
|
||||||
@@ -624,6 +627,31 @@ else
|
|||||||
echo "Publicpool setting unchanged."
|
echo "Publicpool setting unchanged."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# publicpool process choice
|
||||||
|
choice="off"; check=$(echo "${CHOICES}" | grep -c "ah")
|
||||||
|
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||||
|
if [ "${albyhub}" != "${choice}" ]; then
|
||||||
|
echo "AlbyHub setting changed .."
|
||||||
|
anychange=1
|
||||||
|
if [ "${choice}" = "on" ]; then
|
||||||
|
sudo -u admin /home/admin/config.scripts/bonus.albyhub.sh on
|
||||||
|
sudo -u admin /home/admin/config.scripts/bonus.albyhub.sh menu
|
||||||
|
else
|
||||||
|
whiptail --title "Delete Database?" \
|
||||||
|
--yes-button "Keep Database" \
|
||||||
|
--no-button "Delete Database" \
|
||||||
|
--yesno "AlbyHub is getting uninstalled. If you keep the database, you will be able to reuse the data should you choose to re-install. Do you wish to keep the database?" 10 80
|
||||||
|
if [ $? -eq 1 ]; then
|
||||||
|
echo "# Uninstalling AlbyHub AND DELETING DATA ..."
|
||||||
|
sudo -u admin /home/admin/config.scripts/bonus.albyhub.sh off delete-data
|
||||||
|
else
|
||||||
|
echo "# Uninstalling AlbyHub but keeping data ..."
|
||||||
|
sudo -u admin /home/admin/config.scripts/bonus.albyhub.sh off
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "AlbyHub setting unchanged."
|
||||||
|
fi
|
||||||
|
|
||||||
# fints process choice
|
# fints process choice
|
||||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "fn")
|
choice="off"; check=$(echo "${CHOICES}" | grep -c "fn")
|
||||||
|
|||||||
@@ -752,6 +752,15 @@ else
|
|||||||
echo "Provisioning Publicpool - keep default" >> ${logFile}
|
echo "Provisioning Publicpool - keep default" >> ${logFile}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# AlbyHub
|
||||||
|
if [ "${albyhub}" = "on" ]; then
|
||||||
|
echo "Provisioning AlbyHub - run config script" >> ${logFile}
|
||||||
|
/home/admin/_cache.sh set message "Setup AlbyHub"
|
||||||
|
sudo -u admin /home/admin/config.scripts/bonus.albyhub.sh on >> ${logFile} 2>&1
|
||||||
|
else
|
||||||
|
echo "Provisioning AlbyHub - keep default" >> ${logFile}
|
||||||
|
fi
|
||||||
|
|
||||||
# custom install script from user
|
# custom install script from user
|
||||||
customInstallAvailable=$(ls /mnt/hdd/app-data/custom-installs.sh 2>/dev/null | grep -c "custom-installs.sh")
|
customInstallAvailable=$(ls /mnt/hdd/app-data/custom-installs.sh 2>/dev/null | grep -c "custom-installs.sh")
|
||||||
if [ ${customInstallAvailable} -gt 0 ]; then
|
if [ ${customInstallAvailable} -gt 0 ]; then
|
||||||
|
|||||||
@@ -35,17 +35,6 @@ elif [ -d /boot ]; then
|
|||||||
fi
|
fi
|
||||||
echo "# raspi_bootdir(${raspi_bootdir})"
|
echo "# raspi_bootdir(${raspi_bootdir})"
|
||||||
|
|
||||||
# install BTRFS if needed
|
|
||||||
btrfsInstalled=$(btrfs --version 2>/dev/null | grep -c "btrfs-progs")
|
|
||||||
if [ ${btrfsInstalled} -eq 0 ]; then
|
|
||||||
>&2 echo "# Installing BTRFS ..."
|
|
||||||
apt-get install -y btrfs-progs 1>/dev/null
|
|
||||||
fi
|
|
||||||
btrfsInstalled=$(btrfs --version 2>/dev/null | grep -c "btrfs-progs")
|
|
||||||
if [ ${btrfsInstalled} -eq 0 ]; then
|
|
||||||
echo "error='missing btrfs package'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# install smartmontools if needed
|
# install smartmontools if needed
|
||||||
smartmontoolsInstalled=$(apt-cache policy smartmontools | grep -c 'Installed: (none)' | grep -c "0")
|
smartmontoolsInstalled=$(apt-cache policy smartmontools | grep -c 'Installed: (none)' | grep -c "0")
|
||||||
@@ -66,14 +55,41 @@ fi
|
|||||||
# gathering system info
|
# gathering system info
|
||||||
# is global so that also other parts of this script can use this
|
# is global so that also other parts of this script can use this
|
||||||
|
|
||||||
|
# check if a btrfs filesystem is available
|
||||||
# basics
|
# basics
|
||||||
isMounted=$(df | grep -c /mnt/hdd)
|
isMounted=$(df | grep -c /mnt/hdd)
|
||||||
isBTRFS=$(btrfs filesystem show 2>/dev/null| grep -c 'BLITZSTORAGE')
|
isBTRFS="0"
|
||||||
isRaid=$(btrfs filesystem df /mnt/hdd 2>/dev/null | grep -c "Data, RAID1")
|
isRaid="0"
|
||||||
isZFS=$(zfs list 2>/dev/null | grep -c "/mnt/hdd")
|
isZFS="0"
|
||||||
isSSD="0"
|
isSSD="0"
|
||||||
isSMART="0"
|
isSMART="0"
|
||||||
|
|
||||||
|
# BTRFS extras
|
||||||
|
btrfsConnected=$(lsblk -f | grep -c btrfs)
|
||||||
|
if [ ${btrfsConnected} -gt 0 ]; then
|
||||||
|
|
||||||
|
# install BTRFS if needed
|
||||||
|
btrfsInstalled=$(btrfs --version 2>/dev/null | grep -c "btrfs-progs")
|
||||||
|
if [ ${btrfsInstalled} -eq 0 ]; then
|
||||||
|
>&2 echo "# Installing BTRFS ..."
|
||||||
|
apt-get install -y btrfs-progs 1>/dev/null
|
||||||
|
fi
|
||||||
|
btrfsInstalled=$(btrfs --version 2>/dev/null | grep -c "btrfs-progs")
|
||||||
|
if [ ${btrfsInstalled} -eq 0 ]; then
|
||||||
|
echo "error='missing btrfs package'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
isBTRFS=$(btrfs filesystem show 2>/dev/null| grep -c 'BLITZSTORAGE')
|
||||||
|
isRaid=$(btrfs filesystem df /mnt/hdd 2>/dev/null | grep -c "Data, RAID1")
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ZFS extras
|
||||||
|
zfsConnected=$(lsblk -f | grep -c zfs)
|
||||||
|
if [ ${zfsConnected} -gt 0 ]; then
|
||||||
|
isZFS=$(zfs list 2>/dev/null | grep -c "/mnt/hdd")
|
||||||
|
fi
|
||||||
|
|
||||||
# determine if swap is external on or not
|
# determine if swap is external on or not
|
||||||
externalSwapPath="/mnt/hdd/swapfile"
|
externalSwapPath="/mnt/hdd/swapfile"
|
||||||
if [ ${isBTRFS} -eq 1 ]; then
|
if [ ${isBTRFS} -eq 1 ]; then
|
||||||
@@ -656,6 +672,8 @@ if [ "$1" = "format" ]; then
|
|||||||
# check valid format
|
# check valid format
|
||||||
if [ "$2" = "btrfs" ]; then
|
if [ "$2" = "btrfs" ]; then
|
||||||
>&2 echo "# DATA DRIVE - FORMATTING to BTRFS layout (new)"
|
>&2 echo "# DATA DRIVE - FORMATTING to BTRFS layout (new)"
|
||||||
|
# check if btrfs-tools are installed
|
||||||
|
apt-get install -y btrfs-progs 1>/dev/null
|
||||||
elif [ "$2" = "ext4" ]; then
|
elif [ "$2" = "ext4" ]; then
|
||||||
>&2 echo "# DATA DRIVE - FORMATTING to EXT4 layout (old)"
|
>&2 echo "# DATA DRIVE - FORMATTING to EXT4 layout (old)"
|
||||||
else
|
else
|
||||||
|
|||||||
376
home.admin/config.scripts/bonus.albyhub.sh
Normal file
376
home.admin/config.scripts/bonus.albyhub.sh
Normal file
@@ -0,0 +1,376 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This script installs Alby Hub on RaspiBlitz.
|
||||||
|
# Rename it as `bonus.albyhub.sh` and place it in `/home/admin/config.scripts`.
|
||||||
|
|
||||||
|
# id string of your app (short single string unique in raspiblitz)
|
||||||
|
APPID="albyhub" # one-word lower-case no-specials
|
||||||
|
|
||||||
|
# https://github.com/getAlby/hub/releases
|
||||||
|
VERSION="1.10.4"
|
||||||
|
|
||||||
|
# port numbers the app should run on
|
||||||
|
# delete if not an web app
|
||||||
|
PORT_CLEAR="8029"
|
||||||
|
PORT_SSL="8030"
|
||||||
|
PORT_TOR_CLEAR="8031"
|
||||||
|
PORT_TOR_SSL="8032"
|
||||||
|
|
||||||
|
# BASIC COMMANDLINE OPTIONS
|
||||||
|
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||||
|
echo "# bonus.${APPID}.sh status -> status information (key=value)"
|
||||||
|
echo "# bonus.${APPID}.sh on -> install the app"
|
||||||
|
echo "# bonus.${APPID}.sh off [delete-data] -> uninstall the app"
|
||||||
|
echo "# bonus.${APPID}.sh menu -> SSH menu dialog"
|
||||||
|
echo "# bonus.${APPID}.sh prestart -> prestart used by systemd"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
ENVFILE="/home/${APPID}/config.env"
|
||||||
|
|
||||||
|
##########################
|
||||||
|
# PRESTART
|
||||||
|
##########################
|
||||||
|
|
||||||
|
# background is that this script will be called with `prestart` on every start & restart
|
||||||
|
if [ "$1" = "prestart" ]; then
|
||||||
|
|
||||||
|
# needs to be run as the app user - stop if not run as the app user
|
||||||
|
# keep in mind that in the prestart section you cannot use `sudo` command
|
||||||
|
if [ "$USER" != "${APPID}" ]; then
|
||||||
|
echo "# FAIL: run as user ${APPID}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# see: https://github.com/getAlby/hub/blob/master/.env.example
|
||||||
|
|
||||||
|
echo "## PRESTART CONFIG START for ${APPID} (called by systemd prestart)"
|
||||||
|
echo "# creating dynamic env file --> ${ENVFILE}"
|
||||||
|
touch ${ENVFILE}
|
||||||
|
chmod 770 ${ENVFILE}
|
||||||
|
echo "PORT=${PORT_CLEAR}" > ${ENVFILE}
|
||||||
|
echo "WORK_DIR=/mnt/hdd/app-data/${APPID}" >> ${ENVFILE}
|
||||||
|
echo "LN_BACKEND_TYPE=LND" >> ${ENVFILE}
|
||||||
|
echo "LND_ADDRESS=127.0.0.1:10009" >> ${ENVFILE}
|
||||||
|
echo "LND_CERT_FILE=/mnt/hdd/app-data/lnd/tls.cert" >> ${ENVFILE}
|
||||||
|
echo "LND_MACAROON_FILE=/mnt/hdd/app-data/lnd/data/chain/bitcoin/mainnet/admin.macaroon" >> ${ENVFILE}
|
||||||
|
echo >> ${ENVFILE}
|
||||||
|
|
||||||
|
echo "## PRESTART CONFIG DONE for ${APPID}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# echoing comments is useful for logs - but start output with # when not a key=value
|
||||||
|
echo "# Running: 'bonus.${APPID}.sh $*'"
|
||||||
|
|
||||||
|
source /home/admin/raspiblitz.info
|
||||||
|
source /mnt/hdd/raspiblitz.conf
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# INFO
|
||||||
|
#########################
|
||||||
|
|
||||||
|
# this section is always executed to gather status information that
|
||||||
|
# all the following commands can use & execute on
|
||||||
|
|
||||||
|
# check if app is already installed
|
||||||
|
isInstalled=$(sudo ls /etc/systemd/system/${APPID}.service 2>/dev/null | grep -c "${APPID}.service")
|
||||||
|
|
||||||
|
# check if service is running
|
||||||
|
isRunning=$(systemctl status ${APPID} 2>/dev/null | grep -c 'active (running)')
|
||||||
|
|
||||||
|
if [ "${isInstalled}" == "1" ]; then
|
||||||
|
# gather address info (whats needed to call the app)
|
||||||
|
localIP=$(hostname -I | awk '{print $1}')
|
||||||
|
toraddress=$(sudo cat /mnt/hdd/tor/${APPID}/hostname 2>/dev/null)
|
||||||
|
fingerprint=$(openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout | cut -d"=" -f2)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if the action parameter `status` was called - just stop here and output all
|
||||||
|
# status information as a key=value list
|
||||||
|
if [ "$1" = "status" ]; then
|
||||||
|
echo "appID='${APPID}'"
|
||||||
|
echo "version='${VERSION}'"
|
||||||
|
echo "isInstalled=${isInstalled}"
|
||||||
|
echo "isRunning=${isRunning}"
|
||||||
|
if [ "${isInstalled}" == "1" ]; then
|
||||||
|
echo "localIP='${localIP}'"
|
||||||
|
echo "portCLEAR=${PORT_CLEAR}"
|
||||||
|
echo "portSSL=${PORT_SSL}"
|
||||||
|
echo "localIP='${localIP}'"
|
||||||
|
echo "toraddress='${toraddress}'"
|
||||||
|
echo "fingerprint='${fingerprint}'"
|
||||||
|
fi
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
##########################
|
||||||
|
# MENU
|
||||||
|
#########################
|
||||||
|
|
||||||
|
# show info menu
|
||||||
|
if [ "$1" = "menu" ]; then
|
||||||
|
|
||||||
|
if [ ${isInstalled} -eq 0 ] && [ "${albyhub}" == "on" ]; then
|
||||||
|
clear
|
||||||
|
echo "# AlbyHub needs re-install ..."
|
||||||
|
/home/admin/config.scripts/bonus.albyhub.sh on
|
||||||
|
elif [ ${isInstalled} -lt 1 ]; then
|
||||||
|
echo "error='App not installed'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set the title for the dialog
|
||||||
|
dialogTitle=" ${APPID} "
|
||||||
|
localIP=$(hostname -I | awk '{print $1}')
|
||||||
|
fingerprint=$(openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout | cut -d"=" -f2)
|
||||||
|
|
||||||
|
# basic info text - for a web app how to call with http
|
||||||
|
dialogText="Open in your local web browser:
|
||||||
|
http://${localIP}:${PORT_CLEAR}\n
|
||||||
|
https://${localIP}:${PORT_SSL} with Fingerprint:
|
||||||
|
${fingerprint}\n
|
||||||
|
The Alby Hub password is managed seperate from RaspiBlitz - make sure to manage it safely.\n
|
||||||
|
"
|
||||||
|
|
||||||
|
# use whiptail to show SSH dialog & exit
|
||||||
|
whiptail --title "${dialogTitle}" --msgbox "${dialogText}" 15 67
|
||||||
|
echo "please wait ..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
##########################
|
||||||
|
# ON / INSTALL
|
||||||
|
##########################
|
||||||
|
|
||||||
|
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
||||||
|
|
||||||
|
# dont run install if already installed
|
||||||
|
if [ ${isInstalled} -eq 1 ]; then
|
||||||
|
echo "# ${APPID}.service is already installed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if lnd service is installed
|
||||||
|
if [ $(sudo ls /etc/systemd/system/lnd.service 2>/dev/null | grep -c 'lnd.service') -eq 0 ]; then
|
||||||
|
echo "error='LND needs to be installed'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "# Installing ${APPID} ..."
|
||||||
|
|
||||||
|
echo "# create user"
|
||||||
|
sudo adduser --system --group --shell /bin/bash --home /home/${APPID} ${APPID} || exit 1
|
||||||
|
sudo -u ${APPID} cp -r /etc/skel/. /home/${APPID}/
|
||||||
|
|
||||||
|
echo "# add use to special groups"
|
||||||
|
sudo /usr/sbin/usermod --append --groups lndadmin ${APPID}
|
||||||
|
|
||||||
|
# use new app user home as install directory
|
||||||
|
cd /home/${APPID}
|
||||||
|
|
||||||
|
# download Alby Hub
|
||||||
|
if [ ${cpu} == "aarch64" ]; then
|
||||||
|
echo "# Downloading Alby Hub for aarch64"
|
||||||
|
sudo wget -O albyhub-server.tar.bz2 https://github.com/getAlby/hub/releases/download/v$VERSION/albyhub-Server-Linux-aarch64.tar.bz2
|
||||||
|
else
|
||||||
|
echo "# Downloading Alby Hub for x86"
|
||||||
|
sudo wget -O albyhub-server.tar.bz2 https://github.com/getAlby/hub/releases/download/v$VERSION/albyhub-Server-Linux-x86_64.tar.bz2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# extract archives
|
||||||
|
sudo tar -xvf albyhub-server.tar.bz2
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo "# Failed to download & unpack Alby Hub"
|
||||||
|
echo "error='download & unpack failed'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# cleanup
|
||||||
|
rm -f albyhub-server.tar.bz2
|
||||||
|
|
||||||
|
# Setze die Berechtigungen für das Verzeichnis und die Dateien
|
||||||
|
sudo chmod -R 755 /home/${APPID}/lib
|
||||||
|
sudo chown -R root:root /home/${APPID}/lib
|
||||||
|
|
||||||
|
# make libs available
|
||||||
|
echo "/home/${APPID}/lib" | sudo tee /etc/ld.so.conf.d/${APPID}.conf
|
||||||
|
sudo ldconfig
|
||||||
|
|
||||||
|
# prepare data directory
|
||||||
|
sudo mkdir -p /mnt/hdd/app-data/${APPID}
|
||||||
|
sudo chown -R ${APPID}:${APPID} /mnt/hdd/app-data/${APPID}
|
||||||
|
|
||||||
|
# open the ports in the firewall
|
||||||
|
echo "# updating Firewall"
|
||||||
|
sudo ufw allow ${PORT_CLEAR} comment "${APPID} HTTP"
|
||||||
|
sudo ufw allow ${PORT_SSL} comment "${APPID} HTTPS"
|
||||||
|
|
||||||
|
# prepare env file
|
||||||
|
echo "# prepare env file --> ${ENVFILE}"
|
||||||
|
sudo touch ${ENVFILE}
|
||||||
|
sudo chown ${APPID}:${APPID} ${ENVFILE}
|
||||||
|
sudo chmod 770 ${ENVFILE}
|
||||||
|
|
||||||
|
# create systemd service
|
||||||
|
echo "# create systemd service: ${APPID}.service"
|
||||||
|
echo "
|
||||||
|
[Unit]
|
||||||
|
Description=AlbyHub
|
||||||
|
Wants=lnd.service
|
||||||
|
After=lnd.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Restart=always
|
||||||
|
RestartSec=1
|
||||||
|
User=${APPID}
|
||||||
|
ExecStartPre=-/home/admin/config.scripts/bonus.${APPID}.sh prestart
|
||||||
|
EnvironmentFile=${ENVFILE}
|
||||||
|
ExecStart=/home/${APPID}/bin/${APPID}
|
||||||
|
# Hack to ensure Alby Hub never uses more than 90% CPU
|
||||||
|
CPUQuota=90%sudo
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
" | sudo tee /etc/systemd/system/${APPID}.service
|
||||||
|
sudo chown root:root /etc/systemd/system/${APPID}.service
|
||||||
|
|
||||||
|
# when tor is set on also install the hidden service
|
||||||
|
if [ "${runBehindTor}" = "on" ]; then
|
||||||
|
# activating tor hidden service
|
||||||
|
/home/admin/config.scripts/tor.onion-service.sh ${APPID} 80 ${PORT_TOR_CLEAR} 443 ${PORT_TOR_SSL}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# nginx configuration
|
||||||
|
# BACKGROUND is that the plain HTTP is served by your web app, but thru the nginx proxy it will be available
|
||||||
|
# with (self-signed) HTTPS and with separate configs for Tor & Tor+HTTPS.
|
||||||
|
|
||||||
|
echo "# setup nginx confing"
|
||||||
|
|
||||||
|
# write the HTTPS config
|
||||||
|
echo "
|
||||||
|
server {
|
||||||
|
listen ${PORT_SSL} ssl;
|
||||||
|
listen [::]:${PORT_SSL} 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_${APPID}.log;
|
||||||
|
error_log /var/log/nginx/error_${APPID}.log;
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:${PORT_CLEAR};
|
||||||
|
include /etc/nginx/snippets/ssl-proxy-params.conf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
" | sudo tee /etc/nginx/sites-available/${APPID}_ssl.conf
|
||||||
|
sudo ln -sf /etc/nginx/sites-available/${APPID}_ssl.conf /etc/nginx/sites-enabled/
|
||||||
|
|
||||||
|
# write the Tor config
|
||||||
|
echo "
|
||||||
|
server {
|
||||||
|
listen ${PORT_TOR_CLEAR};
|
||||||
|
server_name _;
|
||||||
|
access_log /var/log/nginx/access_${APPID}.log;
|
||||||
|
error_log /var/log/nginx/error_${APPID}.log;
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:${PORT_CLEAR};
|
||||||
|
include /etc/nginx/snippets/ssl-proxy-params.conf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
" | sudo tee /etc/nginx/sites-available/${APPID}_tor.conf
|
||||||
|
sudo ln -sf /etc/nginx/sites-available/${APPID}_tor.conf /etc/nginx/sites-enabled/
|
||||||
|
|
||||||
|
# write the Tor+HTTPS config
|
||||||
|
echo "
|
||||||
|
server {
|
||||||
|
listen ${PORT_TOR_SSL} ssl;
|
||||||
|
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_${APPID}.log;
|
||||||
|
error_log /var/log/nginx/error_${APPID}.log;
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:${PORT_CLEAR};
|
||||||
|
include /etc/nginx/snippets/ssl-proxy-params.conf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
" | sudo tee /etc/nginx/sites-available/${APPID}_tor_ssl.conf
|
||||||
|
sudo ln -sf /etc/nginx/sites-available/${APPID}_tor_ssl.conf /etc/nginx/sites-enabled/
|
||||||
|
|
||||||
|
# test nginx config & activate thru reload
|
||||||
|
sudo nginx -t
|
||||||
|
sudo systemctl reload nginx
|
||||||
|
|
||||||
|
# enable app up thru systemd
|
||||||
|
sudo systemctl enable ${APPID}
|
||||||
|
echo "# OK - the ${APPID}.service is now enabled"
|
||||||
|
|
||||||
|
# start app (only when blitz is ready)
|
||||||
|
source <(/home/admin/_cache.sh get state)
|
||||||
|
if [ "${state}" == "ready" ]; then
|
||||||
|
sudo systemctl start ${APPID}
|
||||||
|
echo "# OK - the ${APPID}.service is now started"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "# mark app as installed in raspiblitz config"
|
||||||
|
/home/admin/config.scripts/blitz.conf.sh set ${APPID} "on"
|
||||||
|
|
||||||
|
echo "# Monitor with: sudo journalctl -f -u ${APPID}"
|
||||||
|
echo "# OK install done"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
###########################################
|
||||||
|
# OFF / UNINSTALL
|
||||||
|
# call with parameter `delete-data` to also
|
||||||
|
# delete the persistent data directory
|
||||||
|
###########################################
|
||||||
|
|
||||||
|
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
||||||
|
|
||||||
|
echo "# stop & remove systemd service"
|
||||||
|
sudo systemctl stop ${APPID} 2>/dev/null
|
||||||
|
sudo systemctl disable ${APPID}.service
|
||||||
|
sudo rm /etc/systemd/system/${APPID}.service
|
||||||
|
|
||||||
|
echo "# remove nginx symlinks"
|
||||||
|
sudo rm -f /etc/nginx/sites-enabled/${APPID}_ssl.conf 2>/dev/null
|
||||||
|
sudo rm -f /etc/nginx/sites-enabled/${APPID}_tor.conf 2>/dev/null
|
||||||
|
sudo rm -f /etc/nginx/sites-enabled/${APPID}_tor_ssl.conf 2>/dev/null
|
||||||
|
sudo rm -f /etc/nginx/sites-available/${APPID}_ssl.conf 2>/dev/null
|
||||||
|
sudo rm -f /etc/nginx/sites-available/${APPID}_tor.conf 2>/dev/null
|
||||||
|
sudo rm -f /etc/nginx/sites-available/${APPID}_tor_ssl.conf 2>/dev/null
|
||||||
|
sudo nginx -t
|
||||||
|
sudo systemctl reload nginx
|
||||||
|
|
||||||
|
echo "# close ports on firewall"
|
||||||
|
sudo ufw deny "${PORT_CLEAR}"
|
||||||
|
sudo ufw deny "${PORT_SSL}"
|
||||||
|
|
||||||
|
# remove libraries again
|
||||||
|
sudo rm /etc/ld.so.conf.d/albyhub.conf
|
||||||
|
sudo ldconfig
|
||||||
|
|
||||||
|
echo "# delete user and directories"
|
||||||
|
sudo userdel -rf ${APPID}
|
||||||
|
|
||||||
|
echo "# removing Tor hidden service (if active)"
|
||||||
|
/home/admin/config.scripts/tor.onion-service.sh off ${APPID}
|
||||||
|
|
||||||
|
echo "# mark app as uninstalled in raspiblitz config"
|
||||||
|
/home/admin/config.scripts/blitz.conf.sh set ${APPID} "off"
|
||||||
|
|
||||||
|
# only if 'delete-data' is an additional parameter then also the data directory gets deleted
|
||||||
|
if [ "$(echo "$@" | grep -c delete-data)" -gt 0 ]; then
|
||||||
|
echo "# found 'delete-data' parameter --> also deleting the app-data"
|
||||||
|
sudo rm -r /mnt/hdd/app-data/${APPID}
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "# OK - app should be uninstalled now"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# just a basic error message when unknown action parameter was given
|
||||||
|
echo "# FAIL - Unknown Parameter $1"
|
||||||
|
exit 1
|
||||||
@@ -487,9 +487,23 @@ if [ "$1" = "install" ]; then
|
|||||||
echo "# Install NBXplorer $NBXplorerVersion"
|
echo "# Install NBXplorer $NBXplorerVersion"
|
||||||
cd /home/btcpay || exit 1
|
cd /home/btcpay || exit 1
|
||||||
echo "# Download the NBXplorer source code $NBXplorerVersion"
|
echo "# Download the NBXplorer source code $NBXplorerVersion"
|
||||||
sudo -u btcpay git clone https://github.com/dgarage/NBXplorer.git 2>/dev/null
|
sudo -u btcpay git clone https://github.com/dgarage/NBXplorer.git
|
||||||
cd NBXplorer || exit 1
|
if [ ! -d "/home/btcpay/NBXplorer" ]; then
|
||||||
sudo -u btcpay git reset --hard $NBXplorerVersion
|
echo "# FAIL! on first git clone - retrying with snapshot download."
|
||||||
|
sudo -u btcpay curl -L https://github.com/dgarage/NBXplorer/archive/refs/tags/$NBXplorerVersion.tar.gz -o NBXplorer.tar.gz
|
||||||
|
sudo -u btcpay tar -xzvf NBXplorer.tar.gz
|
||||||
|
sudo -u btcpay mv NBXplorer-* NBXplorer
|
||||||
|
if [ ! -d "/home/btcpay/NBXplorer" ]; then
|
||||||
|
echo "# FAIL! also on second git clone of NBXplorer - uninstall & exiting."
|
||||||
|
/home/admin/config.scripts/bonus.btcpayserver.sh uninstall
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
cd NBXplorer
|
||||||
|
else
|
||||||
|
echo "# OK - git clone of NBXplorer successful."
|
||||||
|
cd NBXplorer
|
||||||
|
sudo -u btcpay git reset --hard $NBXplorerVersion
|
||||||
|
fi
|
||||||
# PGP verify
|
# PGP verify
|
||||||
NBXPGPsigner="nicolasdorier"
|
NBXPGPsigner="nicolasdorier"
|
||||||
NBXPGPpubkeyLink="https://keybase.io/nicolasdorier/pgp_keys.asc"
|
NBXPGPpubkeyLink="https://keybase.io/nicolasdorier/pgp_keys.asc"
|
||||||
@@ -515,7 +529,6 @@ if [ "$1" = "install" ]; then
|
|||||||
# from the build.sh with path
|
# from the build.sh with path
|
||||||
sudo -u btcpay /home/btcpay/dotnet/dotnet build -c Release \
|
sudo -u btcpay /home/btcpay/dotnet/dotnet build -c Release \
|
||||||
/home/btcpay/btcpayserver/BTCPayServer/BTCPayServer.csproj || exit 1
|
/home/btcpay/btcpayserver/BTCPayServer/BTCPayServer.csproj || exit 1
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
|||||||
# check that the repos were cloned
|
# check that the repos were cloned
|
||||||
if [ ! -d "/home/${APPID}/${APPID}" ] || [ ! -d "/home/${APPID}/${APPID}-ui" ]; then
|
if [ ! -d "/home/${APPID}/${APPID}" ] || [ ! -d "/home/${APPID}/${APPID}-ui" ]; then
|
||||||
echo "# FAIL - Was not able to clone the GitHub repos."
|
echo "# FAIL - Was not able to clone the GitHub repos."
|
||||||
|
echo "# running uninstall script to clean up"
|
||||||
|
/home/admin/config.scripts/bonus.publicpool.sh off
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -163,8 +165,8 @@ API_SECURE=false
|
|||||||
echo "
|
echo "
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=${APPID}
|
Description=${APPID}
|
||||||
Wants=bitcoind
|
Wants=bitcoind.service
|
||||||
After=bitcoind
|
After=bitcoind.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
WorkingDirectory=/home/${APPID}/${APPID}
|
WorkingDirectory=/home/${APPID}/${APPID}
|
||||||
|
|||||||
@@ -7,14 +7,14 @@
|
|||||||
lndVersion="0.17.5-beta"
|
lndVersion="0.17.5-beta"
|
||||||
|
|
||||||
# olaoluwa
|
# olaoluwa
|
||||||
PGPauthor="roasbeef"
|
# PGPauthor="roasbeef"
|
||||||
PGPpkeys="https://keybase.io/roasbeef/pgp_keys.asc"
|
# PGPpkeys="https://raw.githubusercontent.com/lightningnetwork/lnd/master/scripts/keys/roasbeef.asc"
|
||||||
PGPcheck="E4D85299674B2D31FAA1892E372CBD7633C61696"
|
# PGPcheck="A5B61896952D9FDA83BC054CDC42612E89237182"
|
||||||
|
|
||||||
# guggero
|
# guggero
|
||||||
# PGPauthor="guggero"
|
PGPauthor="guggero"
|
||||||
# PGPpkeys="https://keybase.io/guggero/pgp_keys.asc"
|
PGPpkeys="https://keybase.io/guggero/pgp_keys.asc"
|
||||||
# PGPcheck="F4FC70F07310028424EFC20A8E4256593F177720"
|
PGPcheck="F4FC70F07310028424EFC20A8E4256593F177720"
|
||||||
|
|
||||||
# bitconner
|
# bitconner
|
||||||
#PGPauthor="bitconner"
|
#PGPauthor="bitconner"
|
||||||
|
|||||||
Reference in New Issue
Block a user