mirror of
https://github.com/rootzoll/raspiblitz.git
synced 2025-02-25 07:07:46 +01:00
make cln default plugin dir: cln-plugins-enabled
similar to the nginx model make 2 directories for plugins: cln-plugins-enabled - symlinked to ~/.lightning/plugins plugins from here are loaded automatically on cln start cln-plugins-available: plugins are downloaded here to be run until the next cln restart (or stopped with runonce) note the disk is mounted with noexec so plugins can't run from there discuss in: https://github.com/rootzoll/raspiblitz/issues/2295
This commit is contained in:
parent
48ab3737b7
commit
1c9fd09e09
4 changed files with 33 additions and 47 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
# explanation on paths https://github.com/ElementsProject/lightning/issues/4223
|
||||
# built-in path dir: /usr/local/libexec/c-lightning/plugins/
|
||||
# added --plugin-dir=/home/bitcoin/cln-plugins-enabled
|
||||
|
||||
SPARKOVERSION="v2.7"
|
||||
|
||||
|
@ -55,9 +56,9 @@ if [ $1 = on ];then
|
|||
|
||||
# download binary
|
||||
sudo wget https://github.com/fiatjaf/sparko/releases/download/${SPARKOVERSION}/sparko_${DISTRO}\
|
||||
-O /usr/local/libexec/c-lightning/plugins/sparko
|
||||
-O /home/bitcoin/cln-plugins-enabled/sparko
|
||||
# make executable
|
||||
sudo chmod +x /usr/local/libexec/c-lightning/plugins/sparko
|
||||
sudo chmod +x /home/bitcoin/cln-plugins-enabled/sparko
|
||||
|
||||
echo "# Editing /home/bitcoin/.lightning/${netprefix}config"
|
||||
echo "# See: https://github.com/fiatjaf/sparko#how-to-use"
|
||||
|
@ -79,7 +80,7 @@ sparko-keys=${masterkeythatcandoeverything}; ${secretaccesskeythatcanreadstuff}:
|
|||
echo "# Editing /etc/systemd/system/${netprefix}lightningd.service"
|
||||
sudo sed -i "s#^ExecStart=.*#ExecStart=/usr/local/bin/lightningd\
|
||||
--conf=/home/bitcoin/.lightning/${netprefix}config\
|
||||
--plugin=/usr/local/libexec/c-lightning/plugins/sparko#g"\
|
||||
--plugin=/home/bitcoin/cln-plugins-enabled/sparko#g"\
|
||||
/etc/systemd/system/${netprefix}lightningd.service
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
|
@ -121,7 +122,7 @@ if [ $1 = off ];then
|
|||
# purge
|
||||
if [ "$(echo "$@" | grep -c purge)" -gt 0 ];then
|
||||
echo "# Delete plugin"
|
||||
sudo rm /usr/local/libexec/c-lightning/plugins/${netprefix}sparko
|
||||
sudo rm /home/bitcoin/cln-plugins-enabled/${netprefix}sparko
|
||||
fi
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^${netprefix}sparko=.*/${netprefix}sparko=off/g" /mnt/hdd/raspiblitz.conf
|
||||
|
|
|
@ -24,14 +24,15 @@ alias lightningcli_alias="$lightningcli_alias"
|
|||
|
||||
plugin=$1
|
||||
|
||||
if [ ! -f "/home/bitcoin/plugins/${plugin}/${plugin}.py" ]; then
|
||||
cd /home/bitcoin || exit 1
|
||||
if [ ! -f "/home/bitcoin/cln-plugins-available/plugins/${plugin}/${plugin}.py" ]; then
|
||||
cd /home/bitcoin/cln-plugins-available || exit 1
|
||||
sudo -u bitcoin git clone https://github.com/lightningd/plugins.git
|
||||
fi
|
||||
|
||||
if [ $(lightningcli_alias | grep -c "${plugin}") -eq 0 ];then
|
||||
echo "# Starting the ${plugin} plugin"
|
||||
sudo -u bitcoin pip install -r /home/bitcoin/plugins/${plugin}/requirements.txt
|
||||
lightningcli_alias plugin start /home/bitcoin/plugins/${plugin}/${plugin}.py
|
||||
sudo -u bitcoin pip install -r /home/bitcoin/cln-plugins-available/plugins/${plugin}/requirements.txt
|
||||
lightningcli_alias plugin start /home/bitcoin/cln-plugins-available/plugins/${plugin}/${plugin}.py
|
||||
fi
|
||||
|
||||
echo
|
||||
|
@ -49,5 +50,5 @@ lightningcli_alias ${plugin}
|
|||
echo
|
||||
|
||||
if [ "$(echo "$@" | grep -c "runonce")" -gt 0 ];then
|
||||
lightningcli_alias plugin stop /home/bitcoin/plugins/${plugin}/${plugin}.py
|
||||
lightningcli_alias plugin stop /home/bitcoin/cln-plugins-available/plugins/${plugin}/${plugin}.py
|
||||
fi
|
|
@ -11,22 +11,18 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ];then
|
|||
fi
|
||||
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars cln $1)
|
||||
shopt -s expand_aliases
|
||||
alias bitcoincli_alias="$bitcoincli_alias"
|
||||
alias lncli_alias="$lncli_alias"
|
||||
alias lightningcli_alias="$lightningcli_alias"
|
||||
|
||||
if [ ! -f "/home/bitcoin/plugins/summary/summary.py" ]; then
|
||||
if [ ! -f "/home/bitcoin/cln-plugins-available/plugins/summary/summary.py" ]; then
|
||||
cd /home/bitcoin || exit 1
|
||||
sudo -u bitcoin git clone https://github.com/lightningd/plugins.git
|
||||
fi
|
||||
if [ $(lightningcli_alias | grep -c "summary") -eq 0 ];then
|
||||
if [ $($lightningcli_alias | grep -c "summary") -eq 0 ];then
|
||||
echo "# Starting the summary plugin"
|
||||
# https://github.com/ElementsProject/lightning/tree/master/contrib/pylightning
|
||||
sudo -u bitcoin pip install pylightning 1>/dev/null
|
||||
# https://github.com/lightningd/plugins#dynamic-plugin-initialization
|
||||
sudo -u bitcoin pip install -r /home/bitcoin/plugins/summary/requirements.txt 1>/dev/null
|
||||
lightningcli_alias plugin start -H /home/bitcoin/plugins/summary/summary.py 1>/dev/null
|
||||
sudo -u bitcoin pip install -r /home/bitcoin/cln-plugins-available/plugins/summary/requirements.txt 1>/dev/null
|
||||
$lightningcli_alias plugin start -H /home/bitcoin/cln-plugins-available/plugins/summary/summary.py 1>/dev/null
|
||||
fi
|
||||
|
||||
echo
|
||||
|
@ -40,9 +36,9 @@ echo
|
|||
echo "# Running:"
|
||||
echo "${netprefix}lightning-cli -H summary"
|
||||
echo
|
||||
lightningcli_alias -H summary
|
||||
$lightningcli_alias -H summary
|
||||
echo
|
||||
|
||||
if [ "$(echo "$@" | grep -c "runonce")" -gt 0 ];then
|
||||
lightningcli_alias plugin stop -H /home/bitcoin/plugins/summary/summary.py
|
||||
$lightningcli_alias plugin stop -H /home/bitcoin/cln-plugins-available/plugins/summary/summary.py
|
||||
fi
|
|
@ -27,31 +27,10 @@ fi
|
|||
# Tor
|
||||
TORGROUP="debian-tor"
|
||||
|
||||
# bitcoin mainnet / signet / testnet
|
||||
if [ "$1" = on ] || [ "$1" = off ] && [ $# -gt 1 ];then
|
||||
NETWORK=$2
|
||||
else
|
||||
if [ $chain = main ];then
|
||||
NETWORK=${network}
|
||||
else
|
||||
NETWORK=${chain}net
|
||||
fi
|
||||
fi
|
||||
|
||||
# prefix for parallel testnetwork services
|
||||
if [ $NETWORK = testnet ];then
|
||||
netprefix="t"
|
||||
portprefix=1
|
||||
elif [ $NETWORK = signet ];then
|
||||
netprefix="s"
|
||||
portprefix=3
|
||||
else
|
||||
netprefix=""
|
||||
portprefix=""
|
||||
fi
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars cln $2)
|
||||
|
||||
echo "# Running: 'cln.install.sh $*'"
|
||||
echo "# Using the settings for: ${NETWORK} "
|
||||
echo "# Using the settings for: ${network} ${CHAIN}"
|
||||
|
||||
# add default value to raspi config if needed
|
||||
if ! grep -Eq "^${netprefix}cln=" /mnt/hdd/raspiblitz.conf; then
|
||||
|
@ -136,6 +115,14 @@ if [ "$1" = on ]||[ "$1" = update ]||[ "$1" = experimental ]||[ "$1" = testPR ];
|
|||
echo "# Make sure bitcoin is in the ${TORGROUP} group"
|
||||
sudo usermod -a -G ${TORGROUP} bitcoin
|
||||
|
||||
echo "# Add plugin-dir: /home/bitcoin/cln-plugins-enabled"
|
||||
echo "# Add plugin-dir: /home/bitcoin/cln-plugins-available"
|
||||
# note that the disk is mounted with noexec
|
||||
sudo -u bitcoin mkdir /home/bitcoin/cln-plugins-enabled
|
||||
sudo -u bitcoin mkdir /home/bitcoin/cln-plugins-available
|
||||
echo "# symlink to /home/bitcoin/cln-plugins-enabled to /home/bitcoin/.lightning/plugins"
|
||||
sudo ln -s /home/bitcoin/cln-plugins-enabled /home/bitcoin/.lightning/plugins
|
||||
|
||||
echo "# Store the lightning data in /mnt/hdd/app-data/.lightning"
|
||||
echo "# Symlink to /home/bitcoin/"
|
||||
sudo rm -rf /home/bitcoin/.lightning # not a symlink, delete
|
||||
|
@ -144,12 +131,13 @@ if [ "$1" = on ]||[ "$1" = update ]||[ "$1" = experimental ]||[ "$1" = testPR ];
|
|||
echo "# Create /home/bitcoin/.lightning/${netprefix}config"
|
||||
if [ ! -f /home/bitcoin/.lightning/${netprefix}config ];then
|
||||
echo "
|
||||
# lightningd configuration for $NETWORK
|
||||
# lightningd configuration for ${network} ${CHAIN}
|
||||
|
||||
network=$NETWORK
|
||||
network=${CLNETWORK}
|
||||
announce-addr=127.0.0.1:${portprefix}9736
|
||||
log-file=cl.log
|
||||
log-level=debug
|
||||
plugin-dir=/home/bitcoin/cln-plugins-enabled
|
||||
|
||||
# Tor settings
|
||||
proxy=127.0.0.1:9050
|
||||
|
@ -161,7 +149,7 @@ always-use-proxy=true
|
|||
echo "# The file /home/bitcoin/.lightning/${netprefix}config is already present"
|
||||
#TODO look for plugin configs and clear or install
|
||||
if [ $(grep -c "^sparko" < /home/bitcoin/.lightning/${netprefix}config) -gt 0 ];then
|
||||
/home/admin/config.scripts/cln-plugin.sparko.sh on $NETWORK
|
||||
/home/admin/config.scripts/cln-plugin.sparko.sh on $CHAIN
|
||||
fi
|
||||
fi
|
||||
sudo chown -R bitcoin:bitcoin /mnt/hdd/app-data/.lightning
|
||||
|
@ -173,7 +161,7 @@ always-use-proxy=true
|
|||
echo "# Create /etc/systemd/system/${netprefix}lightningd.service"
|
||||
echo "
|
||||
[Unit]
|
||||
Description=c-lightning daemon on $NETWORK
|
||||
Description=c-lightning daemon on $CHAIN
|
||||
|
||||
[Service]
|
||||
User=bitcoin
|
||||
|
@ -222,7 +210,7 @@ alias ${netprefix}cl=\"sudo -u bitcoin /usr/local/bin/lightning-cli\
|
|||
echo "sudo journalctl -fu ${netprefix}lightningd"
|
||||
echo "sudo systemctl status ${netprefix}lightningd"
|
||||
echo "# logs:"
|
||||
echo "sudo tail -f /home/bitcoin/.lightning/${NETWORK}/cl.log"
|
||||
echo "sudo tail -f /home/bitcoin/.lightning/${CLNETWORK}/cl.log"
|
||||
echo "# for the command line options use"
|
||||
echo "${netprefix}lightning-cli help"
|
||||
echo
|
||||
|
|
Loading…
Add table
Reference in a new issue