cln: load plugins from ${netprefix}cln-plugins-enabled

changed the config paths to $lightning-dir/config or /networkname/config

plugins are downloaded to the SDcard:
/home/bitcoin/cln-plugins-available/
symlinked and loaded automatically from:
/home/bitcoin/${netprefix}cln-plugins-enabled

Related: #2295
This commit is contained in:
openoms
2021-07-20 14:05:58 +01:00
parent 626b07400e
commit bcc5ba502a
5 changed files with 65 additions and 47 deletions

View File

@@ -40,8 +40,8 @@ function install() {
fi fi
sudo chmod +x ${plugindir}/${plugin}/${plugin}.py sudo chmod +x ${plugindir}/${plugin}/${plugin}.py
# symlink to the default plugin dir # symlink to the default plugin dir
if [ ! -L /home/bitcoin/${netprefix}cln-plugins-enabled/backup ];then if [ ! -L /home/bitcoin/${netprefix}cln-plugins-enabled/backup.py ];then
sudo ln -s ${plugindir}/backup \ sudo ln -s ${plugindir}/backup/backup.py \
/home/bitcoin/${netprefix}cln-plugins-enabled/ /home/bitcoin/${netprefix}cln-plugins-enabled/
fi fi
fi fi
@@ -51,6 +51,9 @@ if [ $1 = on ];then
install install
echo "# Stop the ${netprefix}lightningd.service"
sudo systemctl stop ${netprefix}lightningd
# don't overwrite old backup # don't overwrite old backup
if [ -f /home/bitcoin/${netprefix}lightningd.sqlite3.backup ];then if [ -f /home/bitcoin/${netprefix}lightningd.sqlite3.backup ];then
echo "# Backup the existing old backup on the SDcard" echo "# Backup the existing old backup on the SDcard"
@@ -68,6 +71,12 @@ if [ $1 = on ];then
file:///home/bitcoin/${netprefix}lightningd.sqlite3.backup file:///home/bitcoin/${netprefix}lightningd.sqlite3.backup
fi fi
source /home/admin/raspiblitz.info
if [ "${state}" == "ready" ]; then
sudo systemctl start ${netprefix}lightningd
echo "# Started the ${netprefix}lightningd.service"
fi
elif [ $1 = off ];then elif [ $1 = off ];then
echo "# Removing the backup plugin" echo "# Removing the backup plugin"
sudo rm -f /home/bitcoin/${netprefix}cln-plugins-enabled/backup sudo rm -f /home/bitcoin/${netprefix}cln-plugins-enabled/backup

View File

@@ -139,11 +139,6 @@ sparko-keys=${masterkeythatcandoeverything}; ${secretaccesskeythatcanreadstuff}:
echo "# Sparko is already configured in the /home/bitcoin/.lightning/${netprefix}config" echo "# Sparko is already configured in the /home/bitcoin/.lightning/${netprefix}config"
fi fi
###################
# Systemd service #
###################
/home/admin/config.scripts/cln.install-service.sh $CHAIN
echo "# Allowing port ${portprefix}9000 through the firewall" echo "# Allowing port ${portprefix}9000 through the firewall"
sudo ufw allow "${portprefix}9000" comment "${netprefix}sparko" sudo ufw allow "${portprefix}9000" comment "${netprefix}sparko"
@@ -153,10 +148,15 @@ sparko-keys=${masterkeythatcandoeverything}; ${secretaccesskeythatcanreadstuff}:
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^${netprefix}sparko=.*/${netprefix}sparko=on/g" /mnt/hdd/raspiblitz.conf sudo sed -i "s/^${netprefix}sparko=.*/${netprefix}sparko=on/g" /mnt/hdd/raspiblitz.conf
sleep 5 source /home/admin/raspiblitz.info
# show some logs if [ "${state}" == "ready" ]; then
sudo tail -n100 /home/bitcoin/.lightning/${CLNETWORK}/cl.log | grep sparko echo "# Restart the ${netprefix}lightningd.service to activate Sparko"
netstat -tulpn | grep "${portprefix}9000" sudo systemctl restart ${netprefix}lightningd
sleep 5
# show some logs
sudo tail -n100 /home/bitcoin/.lightning/${CLNETWORK}/cl.log | grep sparko
netstat -tulpn | grep "${portprefix}9000"
fi
echo "# Sparko was installed" echo "# Sparko was installed"
echo "# Monitor with:" echo "# Monitor with:"
@@ -172,9 +172,8 @@ if [ $1 = off ];then
echo "# Editing /home/bitcoin/.lightning/${netprefix}config" echo "# Editing /home/bitcoin/.lightning/${netprefix}config"
sudo sed -i "/^sparko/d" /home/bitcoin/.lightning/${netprefix}config sudo sed -i "/^sparko/d" /home/bitcoin/.lightning/${netprefix}config
if [ -f /etc/systemd/system/multi-user.target.wants/slightningd.service ];then echo "# Restart the ${netprefix}lightningd.service to deactivate Sparko"
/home/admin/config.scripts/cln.install-service.sh $CHAIN sudo systemctl restart ${netprefix}lightningd
fi
echo "# Deny port ${portprefix}9000 through the firewall" echo "# Deny port ${portprefix}9000 through the firewall"
sudo ufw deny "${portprefix}9000" sudo ufw deny "${portprefix}9000"
@@ -189,4 +188,5 @@ if [ $1 = off ];then
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^${netprefix}sparko=.*/${netprefix}sparko=off/g" /mnt/hdd/raspiblitz.conf sudo sed -i "s/^${netprefix}sparko=.*/${netprefix}sparko=off/g" /mnt/hdd/raspiblitz.conf
echo "# Sparko was uninstalled" echo "# Sparko was uninstalled"
fi fi

View File

@@ -10,12 +10,11 @@ source /home/admin/raspiblitz.info
# source <(/home/admin/config.scripts/network.aliases.sh getvars cln <mainnet|testnet|signet>) # source <(/home/admin/config.scripts/network.aliases.sh getvars cln <mainnet|testnet|signet>)
source <(/home/admin/config.scripts/network.aliases.sh getvars cln $1) source <(/home/admin/config.scripts/network.aliases.sh getvars cln $1)
if [ $(grep -c "^sparko" < /home/bitcoin/.lightning/${netprefix}config) -gt 0 ];then if [ $(sudo -u bitcoin cat ${CLNCONF} | grep -c "^sparko") -gt 0 ];then
if [ ! -f /home/bitcoin/${netprefix}cln-plugins-enabled/sparko ];then if [ ! -f /home/bitcoin/${netprefix}cln-plugins-enabled/sparko ];then
echo "# The Sparko plugin is not present despite being configured" echo "# The Sparko plugin is not present but in config"
/home/admin/config.scripts/cln-plugin.sparko.sh on $CHAIN /home/admin/config.scripts/cln-plugin.sparko.sh on $CHAIN
fi fi
sparkoStart="--plugin=/home/bitcoin/${netprefix}cln-plugins-enabled/sparko"
fi fi
if grep -Eq "${netprefix}clnEncryptedHSM=on" /mnt/hdd/raspiblitz.conf;then if grep -Eq "${netprefix}clnEncryptedHSM=on" /mnt/hdd/raspiblitz.conf;then
@@ -30,6 +29,7 @@ else
passwordInput="" passwordInput=""
encryptedHSMoption="" encryptedHSMoption=""
fi fi
sudo systemctl stop ${netprefix}lightningd sudo systemctl stop ${netprefix}lightningd
sudo systemctl disable ${netprefix}lightningd sudo systemctl disable ${netprefix}lightningd
echo "# Create /etc/systemd/system/${netprefix}lightningd.service" echo "# Create /etc/systemd/system/${netprefix}lightningd.service"
@@ -42,8 +42,7 @@ User=bitcoin
Group=bitcoin Group=bitcoin
Type=simple Type=simple
ExecStart=/bin/sh -c '${passwordInput}/usr/local/bin/lightningd\ ExecStart=/bin/sh -c '${passwordInput}/usr/local/bin/lightningd\
--conf=/home/bitcoin/.lightning/${netprefix}config\ --conf=${CLNCONF} ${encryptedHSMoption}'
${sparkoStart} ${encryptedHSMoption}'
Restart=always Restart=always
TimeoutSec=120 TimeoutSec=120
RestartSec=30 RestartSec=30

View File

@@ -140,8 +140,10 @@ if [ "$1" = on ]||[ "$1" = update ]||[ "$1" = experimental ]||[ "$1" = testPR ];
sudo rm -rf /home/bitcoin/.lightning # not a symlink, delete sudo rm -rf /home/bitcoin/.lightning # not a symlink, delete
sudo mkdir -p /mnt/hdd/app-data/.lightning sudo mkdir -p /mnt/hdd/app-data/.lightning
sudo ln -s /mnt/hdd/app-data/.lightning /home/bitcoin/ sudo ln -s /mnt/hdd/app-data/.lightning /home/bitcoin/
echo "# Create /home/bitcoin/.lightning/${netprefix}config"
if [ ! -f /home/bitcoin/.lightning/${netprefix}config ];then
echo "# Create ${CLNCONF}"
if [ ! -f ${CLNCONF} ];then
echo " echo "
# lightningd configuration for ${network} ${CHAIN} # lightningd configuration for ${network} ${CHAIN}
@@ -156,9 +158,9 @@ proxy=127.0.0.1:9050
bind-addr=127.0.0.1:${portprefix}9736 bind-addr=127.0.0.1:${portprefix}9736
addr=statictor:127.0.0.1:9051/torport=${portprefix}9736 addr=statictor:127.0.0.1:9051/torport=${portprefix}9736
always-use-proxy=true always-use-proxy=true
" | sudo tee /home/bitcoin/.lightning/${netprefix}config " | sudo tee ${CLNCONF}
else else
echo "# The file /home/bitcoin/.lightning/${netprefix}config is already present" echo "# The file ${CLNCONF} is already present"
fi fi
sudo chown -R bitcoin:bitcoin /mnt/hdd/app-data/.lightning sudo chown -R bitcoin:bitcoin /mnt/hdd/app-data/.lightning
sudo chown -R bitcoin:bitcoin /home/bitcoin/ sudo chown -R bitcoin:bitcoin /home/bitcoin/
@@ -177,16 +179,15 @@ always-use-proxy=true
echo "# Adding aliases" echo "# Adding aliases"
echo "\ echo "\
alias ${netprefix}lightning-cli=\"sudo -u bitcoin /usr/local/bin/lightning-cli\ alias ${netprefix}lightning-cli=\"sudo -u bitcoin /usr/local/bin/lightning-cli\
--conf=/home/bitcoin/.lightning/${netprefix}config\" --conf=${CLNCONF}\"
alias ${netprefix}cln=\"sudo -u bitcoin /usr/local/bin/lightning-cli\ alias ${netprefix}cln=\"sudo -u bitcoin /usr/local/bin/lightning-cli\
--conf=/home/bitcoin/.lightning/${netprefix}config\" --conf=${CLNCONF}\"
alias ${netprefix}clnlog=\"sudo\ alias ${netprefix}clnlog=\"sudo\
tail -n 30 -f /home/bitcoin/.lightning/${CLNETWORK}/cl.log\" tail -n 30 -f /home/bitcoin/.lightning/${CLNETWORK}/cl.log\"
alias ${netprefix}clnconf=\"sudo\ alias ${netprefix}clnconf=\"sudo\
nano /home/bitcoin/.lightning/${netprefix}config\" nano ${CLNCONF}\"
" | sudo tee -a /home/admin/_aliases " | sudo tee -a /home/admin/_aliases
echo
echo "# The installed C-lightning version is: $(sudo -u bitcoin /usr/local/bin/lightningd --version)" echo "# The installed C-lightning version is: $(sudo -u bitcoin /usr/local/bin/lightningd --version)"
echo echo
echo "# To activate the aliases reopen the terminal or use:" echo "# To activate the aliases reopen the terminal or use:"

View File

@@ -35,14 +35,6 @@ if [ $1 = getvars ];then
fi fi
echo "LNTYPE=${LNTYPE}" echo "LNTYPE=${LNTYPE}"
# typeprefix is: "" | c
if [ $LNTYPE = cln ];then
typeprefix=c
elif [ $LNTYPE = lnd ];then
typeprefix=''
fi
echo "typeprefix=${typeprefix}"
# from raspiblitz.conf or raspiblitz.info or defaults to main # from raspiblitz.conf or raspiblitz.info or defaults to main
if [ ${#chain} -eq 0 ]; then if [ ${#chain} -eq 0 ]; then
chain=main chain=main
@@ -60,7 +52,12 @@ if [ $1 = getvars ];then
# netprefix is: "" | t | s # netprefix is: "" | t | s
# portprefix is: "" | 1 | 3 # portprefix is: "" | 1 | 3
# L2rpcportmod is: 0 | 1 | 3 # L2rpcportmod is: 0 | 1 | 3
if [ ${chain} = "test" ];then if [ ${chain} = "main" ];then
netprefix=""
L1rpcportmod=""
L2rpcportmod=0
portprefix=""
elif [ ${chain} = "test" ];then
netprefix="t" netprefix="t"
L1rpcportmod=1 L1rpcportmod=1
L2rpcportmod=1 L2rpcportmod=1
@@ -70,23 +67,35 @@ if [ $1 = getvars ];then
L1rpcportmod=3 L1rpcportmod=3
L2rpcportmod=3 L2rpcportmod=3
portprefix=3 portprefix=3
elif [ ${chain} = "main" ];then
netprefix=""
L1rpcportmod=""
L2rpcportmod=0
portprefix=""
fi fi
echo "netprefix=${netprefix}" echo "netprefix=${netprefix}"
echo "portprefix=${portprefix}" echo "portprefix=${portprefix}"
echo "L2rpcportmod=${L2rpcportmod}" echo "L2rpcportmod=${L2rpcportmod}"
if [ $LNTYPE = cln ];then
# CLNETWORK is: bitcoin / signet / testnet
if [ $chain = main ];then
CLNETWORK=${network}
else
CLNETWORK=${chain}net
fi
echo "CLNETWORK=${CLNETWORK}"
# CLNETWORK is: bitcoin / signet / testnet # CLNCONF is the path to the config
if [ $chain = main ];then if [ ${CLNETWORK} = "bitcoin" ]; then
CLNETWORK=${network} CLNCONF="/home/bitcoin/.lightning/config"
else else
CLNETWORK=${chain}net CLNCONF="/home/bitcoin/.lightning/${CLNETWORK}/config"
fi
echo "CLNCONF=${CLNCONF}"
typeprefix=c
fi fi
echo CLNETWORK=${CLNETWORK}
# typeprefix is: "" | c
if [ $LNTYPE = lnd ];then
typeprefix=''
fi
echo "typeprefix=${typeprefix}"
# instead of all # instead of all
# sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net # sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net