mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-30 14:06:08 +02:00
lndk update to v0.2.0 and refactor (#4726)
lndk update to v0.2.0 and refactor
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
## What's new in Version 1.11.3 of RaspiBlitz?
|
## What's new in Version 1.11.3 of RaspiBlitz?
|
||||||
|
|
||||||
- New: Tailscale (basic install script) [details](https://en.wikipedia.org/wiki/Tailscale)
|
- New: Tailscale (basic install script) [details](https://en.wikipedia.org/wiki/Tailscale)
|
||||||
|
- Update: LNDK 0.2.0 (Pay BOLT12 offers with LND) [details](https://github.com/lndk-org/lndk/releases/tag/v0.2.0)
|
||||||
- Update: Helipad (Podcasting 2.0 Boostagram reader) v0.2.0 [details](https://github.com/Podcastindex-org/helipad/releases/tag/v0.2.0)
|
- Update: Helipad (Podcasting 2.0 Boostagram reader) v0.2.0 [details](https://github.com/Podcastindex-org/helipad/releases/tag/v0.2.0)
|
||||||
|
|
||||||
## What's new in Version 1.11.2 of RaspiBlitz?
|
## What's new in Version 1.11.2 of RaspiBlitz?
|
||||||
|
@@ -1,64 +1,129 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# https://github.com/lndk-org/lndk/releases/tag/v0.0.1
|
# https://github.com/lndk-org/lndk/releases
|
||||||
LNDKVERSION="v0.1.1"
|
LNDKVERSION="v0.2.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 switch the LNDK Service on or off"
|
echo "config script to switch the LNDK Service on or off"
|
||||||
echo "installs the version $LNDKVERSION"
|
echo "installs the version $LNDKVERSION"
|
||||||
echo "bonus.lndk.sh [on|off|menu]"
|
echo "bonus.lndk.sh [on|menu]"
|
||||||
|
echo "bonus.lndk.sh off <--delete-data|--keep-data>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
source /home/admin/raspiblitz.info
|
||||||
|
source <(/home/admin/_cache.sh get state)
|
||||||
|
|
||||||
# Switch on
|
# Switch on
|
||||||
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
||||||
echo "# INSTALL LNDK"
|
|
||||||
|
|
||||||
lndkServicePath="/etc/systemd/system/lndk.service"
|
lndkServicePath="/etc/systemd/system/lndk.service"
|
||||||
isInstalled=$(sudo ls $lndkServicePath 2>/dev/null | grep -c 'lndk.service')
|
isInstalled=$(sudo ls $lndkServicePath 2>/dev/null | grep -c 'lndk.service')
|
||||||
if [ ${isInstalled} -eq 0 ]; then
|
if [ ${isInstalled} -eq 0 ]; then
|
||||||
|
echo "# INSTALL LNDK"
|
||||||
|
|
||||||
|
USERNAME=lndk
|
||||||
|
echo "# add the user: ${USERNAME}"
|
||||||
|
sudo adduser --system --group --shell /bin/bash --home /home/${USERNAME} ${USERNAME}
|
||||||
|
echo "Copy the skeleton files for login"
|
||||||
|
sudo -u ${USERNAME} cp -r /etc/skel/. /home/${USERNAME}/
|
||||||
|
|
||||||
|
sudo apt-get install -y protobuf-compiler
|
||||||
|
|
||||||
# Install Rust for lndk, includes rustfmt
|
# Install Rust for lndk, includes rustfmt
|
||||||
sudo -u bitcoin curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
|
sudo -u lndk curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs |
|
||||||
sudo -u bitcoin sh -s -- -y
|
sudo -u lndk sh -s -- -y
|
||||||
|
|
||||||
# Clone and compile lndk onto Raspiblitz.
|
# Clone and compile lndk onto Raspiblitz.
|
||||||
if [ ! -d "/home/bitcoin/lndk" ]; then
|
if [ ! -f "/usr/local/bin/lndk" ] || [ ! -f "/usr/local/bin/lndk-cli" ]; then
|
||||||
cd /home/bitcoin || exit 1
|
cd /home/lndk || exit 1
|
||||||
sudo -u bitcoin git clone https://github.com/lndk-org/lndk
|
sudo -u lndk git clone https://github.com/lndk-org/lndk
|
||||||
cd /home/bitcoin/lndk || exit 1
|
cd /home/lndk/lndk || exit 1
|
||||||
sudo -u bitcoin git checkout tags/$LNDKVERSION -b $LNDKVERSION
|
sudo -u lndk git reset --hard $LNDKVERSION
|
||||||
sudo -u bitcoin /home/bitcoin/.cargo/bin/cargo build # Lndk bin will be built to /home/bitcoin/lndk/target/debug/lndk
|
sudo -u lndk /home/lndk/.cargo/bin/cargo build # Lndk bin will be built to /home/lndk/lndk/target/debug/lndk
|
||||||
|
sudo install -m 0755 -o root -g root -t /usr/local/bin /home/lndk/lndk/target/debug/lndk
|
||||||
|
sudo install -m 0755 -o root -g root -t /usr/local/bin /home/lndk/lndk/target/debug/lndk-cli
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# LND needs the following configuration settings so lndk can run.
|
# LND needs the following configuration settings so lndk can run.
|
||||||
protocol=protocol
|
lnd_conf_file="/home/bitcoin/.lnd/lnd.conf"
|
||||||
lnd_conf_file=/home/bitcoin/.lnd/lnd.conf
|
lines=(
|
||||||
if grep $protocol $lnd_conf_file; then
|
"protocol.custom-message=513"
|
||||||
echo "[protocol]
|
"protocol.custom-nodeann=39"
|
||||||
protocol.custom-message=513
|
"protocol.custom-init=39"
|
||||||
protocol.custom-nodeann=39
|
)
|
||||||
protocol.custom-init=39
|
|
||||||
" | sudo tee -a $lnd_conf_file
|
# Check if the [protocol] section exists
|
||||||
|
needsLNDrestart=0
|
||||||
|
if grep -q "\[protocol\]" "$lnd_conf_file"; then
|
||||||
|
# Loop through each line to append after the [protocol] section
|
||||||
|
for line in "${lines[@]}"; do
|
||||||
|
# Check if the line already exists in the configuration file
|
||||||
|
if ! grep -q "$line" "$lnd_conf_file"; then
|
||||||
|
# Append the line after the [protocol] section
|
||||||
|
echo $line
|
||||||
|
sudo sed -i "/^\[protocol\]$/a $line" "$lnd_conf_file"
|
||||||
|
needsLNDrestart=1
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
# If the [protocol] section does not exist, create it and append the lines
|
||||||
|
{
|
||||||
|
echo "[protocol]"
|
||||||
|
for line in "${lines[@]}"; do
|
||||||
|
echo "$line"
|
||||||
|
done
|
||||||
|
} | sudo tee -a "$lnd_conf_file" >/dev/null
|
||||||
|
needsLNDrestart=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ${needsLNDrestart} -eq 1 ]; then
|
||||||
|
if [ "${state}" == "ready" ]; then
|
||||||
|
sudo systemctl restart lnd
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#config
|
||||||
|
sudo mkdir -p /mnt/hdd/app-data/.lndk
|
||||||
|
sudo chown -R lndk:lndk /mnt/hdd/app-data/.lndk
|
||||||
|
sudo chmod 755 /mnt/hdd/app-data/.lndk
|
||||||
|
|
||||||
|
cat <<EOF | sudo tee /mnt/hdd/app-data/.lndk/lndk.conf
|
||||||
|
address="https://localhost:10009"
|
||||||
|
cert_path="/mnt/hdd/lnd/tls.cert"
|
||||||
|
macaroon_path="/home/lndk/.lnd/data/chain/bitcoin/mainnet/admin.macaroon"
|
||||||
|
grpc_port=5635
|
||||||
|
log_level="debug"
|
||||||
|
response_invoice_timeout=15
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# symlink data dir for lndk and admin users
|
||||||
|
sudo rm -rf /home/lndk/.lndk
|
||||||
|
sudo ln -s /mnt/hdd/app-data/.lndk /home/lndk/
|
||||||
|
sudo rm -rf /home/admin/.lndk
|
||||||
|
sudo ln -s /mnt/hdd/app-data/.lndk /home/admin/
|
||||||
|
|
||||||
|
# create symlink
|
||||||
|
sudo ln -s "/mnt/hdd/app-data/lnd/" "/home/lndk/.lnd"
|
||||||
|
|
||||||
|
# add user to group with admin access to lnd
|
||||||
|
sudo /usr/sbin/usermod --append --groups lndadmin lndk
|
||||||
|
|
||||||
echo "[Unit]
|
echo "[Unit]
|
||||||
Description=lndk Service
|
Description=lndk Service
|
||||||
After=lnd.service
|
After=lnd.service
|
||||||
PartOf=lnd.service
|
BindsTo=lnd.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/home/bitcoin/lndk/target/debug/lndk --address=https://localhost:10009 --cert=/mnt/hdd/lnd/tls.cert --macaroon=/mnt/hdd/lnd/data/chain/bitcoin/mainnet/admin.macaroon
|
ExecStart=/usr/local/bin/lndk --conf=/mnt/hdd/app-data/.lndk/lndk.conf
|
||||||
User=bitcoin
|
User=lndk
|
||||||
Group=bitcoin
|
Group=lndk
|
||||||
Type=simple
|
Type=simple
|
||||||
TimeoutSec=60
|
TimeoutSec=60
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=60
|
RestartSec=60
|
||||||
StandardOutput=journal
|
StandardOutput=journal
|
||||||
StandardError=journal
|
StandardError=journal
|
||||||
LogLevelMax=4
|
|
||||||
|
|
||||||
# Hardening measures
|
# Hardening measures
|
||||||
PrivateTmp=true
|
PrivateTmp=true
|
||||||
@@ -68,13 +133,25 @@ PrivateDevices=true
|
|||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
" | sudo tee -a $lndkServicePath
|
" | sudo tee $lndkServicePath
|
||||||
sudo systemctl enable lndk
|
sudo systemctl enable lndk
|
||||||
|
echo "# Enabled the lndk.service"
|
||||||
|
if [ "${state}" == "ready" ]; then
|
||||||
sudo systemctl start lndk
|
sudo systemctl start lndk
|
||||||
echo "OK - we've now started the LNDK service"
|
echo "# Started the lndk.service"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "# Add alias for lndk-cli"
|
||||||
|
sudo -u admin touch /home/admin/_aliases
|
||||||
|
if [ $(grep -c "alias lndk-cli" </home/admin/_aliases) -eq 0 ]; then
|
||||||
|
echo 'alias lndk-cli="lndk-cli -n mainnet --grpc-port=5635"' | sudo tee -a /home/admin/_aliases
|
||||||
|
fi
|
||||||
|
|
||||||
# Set value in raspiblitz config
|
# Set value in raspiblitz config
|
||||||
/home/admin/config.scripts/blitz.conf.sh set lndk "on"
|
/home/admin/config.scripts/blitz.conf.sh set lndk "on"
|
||||||
|
else
|
||||||
|
echo "# LNDK is already installed."
|
||||||
|
sudo systemctl status lndk
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
@@ -82,9 +159,13 @@ fi
|
|||||||
|
|
||||||
# Show info menu
|
# Show info menu
|
||||||
if [ "$1" = "menu" ]; then
|
if [ "$1" = "menu" ]; then
|
||||||
whiptail --title " LNDK " --msgbox "Your node is now forwarding onion messages!\n
|
whiptail --title " LNDK " --msgbox "Your node is now able to pay BOLT12 offers and is forwarding onion messages!
|
||||||
Check 'sudo systemctl status lndk' to see if it's running properly.\n
|
|
||||||
See more information about LNDK v0.0.1 here: https://github.com/lndk-org/lndk" 14 63
|
Use the 'lndk-cli' command to get started.
|
||||||
|
|
||||||
|
Check 'sudo systemctl status lndk' to see if it's running properly.
|
||||||
|
|
||||||
|
Find more information about LNDK here: https://github.com/lndk-org/lndk" 16 63
|
||||||
|
|
||||||
echo "please wait ..."
|
echo "please wait ..."
|
||||||
exit 0
|
exit 0
|
||||||
@@ -100,11 +181,42 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
|||||||
sudo systemctl disable lndk
|
sudo systemctl disable lndk
|
||||||
sudo rm /etc/systemd/system/lndk.service
|
sudo rm /etc/systemd/system/lndk.service
|
||||||
|
|
||||||
sudo rm /home/bitcoin/lndk/target/debug/lndk
|
|
||||||
else
|
else
|
||||||
echo "# LNDK is not installed."
|
echo "# LNDK is not installed."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# remove the binaries
|
||||||
|
sudo rm -f /usr/local/bin/lndk
|
||||||
|
sudo rm -f /usr/local/bin/lndk-cli
|
||||||
|
sudo rm -f /home/lndk/lndk/target/debug/lndk
|
||||||
|
|
||||||
|
# remove the user and home dirlndl
|
||||||
|
sudo userdel -rf lndk
|
||||||
|
sudo rm -rf /home/admin/.lndk
|
||||||
|
|
||||||
|
# get delete data status - either by parameter or if not set by user dialog
|
||||||
|
deleteData=""
|
||||||
|
if [ "$2" == "--delete-data" ]; then
|
||||||
|
deleteData="1"
|
||||||
|
fi
|
||||||
|
if [ "$2" == "--keep-data" ]; then
|
||||||
|
deleteData="0"
|
||||||
|
fi
|
||||||
|
if [ "${deleteData}" == "" ]; then
|
||||||
|
if (whiptail --title "Delete Data?" --yes-button "Keep Data" --no-button "Delete Data" --yesno "Do you want to delete all data related to LNDK?" 0 0); then
|
||||||
|
deleteData="0"
|
||||||
|
else
|
||||||
|
deleteData="1"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${deleteData}" == "1" ]; then
|
||||||
|
echo "# Deleting LNDK data ..."
|
||||||
|
sudo rm -rf /mnt/hdd/app-data/.lndk
|
||||||
|
else
|
||||||
|
echo "# LNDK data is kept on the disk"
|
||||||
|
fi
|
||||||
|
|
||||||
# Set value in raspi blitz config
|
# Set value in raspi blitz config
|
||||||
/home/admin/config.scripts/blitz.conf.sh set lndk "off"
|
/home/admin/config.scripts/blitz.conf.sh set lndk "off"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user