mirror of
https://github.com/rootzoll/raspiblitz.git
synced 2025-02-25 23:21:13 +01:00
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
54 lines
No EOL
1.7 KiB
Bash
54 lines
No EOL
1.7 KiB
Bash
#!/bin/bash
|
|
|
|
# command info
|
|
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ];then
|
|
echo
|
|
echo "Install and show the output of the chosen plugin for C-lightning"
|
|
echo "Usage:"
|
|
echo "cln-plugin.standard-python.sh [plugin-name] [testnet|mainnet|signet] [runonce]"
|
|
echo
|
|
echo "tested plugins:"
|
|
echo "summary | helpme | feeadjuster"
|
|
echo
|
|
echo "find more at:"
|
|
echo "https://github.com/lightningd/plugins"
|
|
echo
|
|
exit 1
|
|
fi
|
|
|
|
source <(/home/admin/config.scripts/network.aliases.sh getvars cln $2)
|
|
shopt -s expand_aliases
|
|
alias bitcoincli_alias="$bitcoincli_alias"
|
|
alias lncli_alias="$lncli_alias"
|
|
alias lightningcli_alias="$lightningcli_alias"
|
|
|
|
plugin=$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/cln-plugins-available/plugins/${plugin}/requirements.txt
|
|
lightningcli_alias plugin start /home/bitcoin/cln-plugins-available/plugins/${plugin}/${plugin}.py
|
|
fi
|
|
|
|
echo
|
|
echo "Node URI:"
|
|
ln_getinfo=$(lightningcli_alias -H getinfo 2>/dev/null)
|
|
pubkey=$(echo "$ln_getinfo" | grep "id=" | cut -d= -f2)
|
|
toraddress=$(echo "$ln_getinfo" | grep ".onion" | cut -d= -f2)
|
|
port=$(echo "$ln_getinfo" | grep "port" | tail -n1 | cut -d= -f2)
|
|
echo "${pubkey}@${toraddress}:${port}"
|
|
echo
|
|
echo "# Running:"
|
|
echo "${netprefix}lightning-cli ${plugin}"
|
|
echo
|
|
lightningcli_alias ${plugin}
|
|
echo
|
|
|
|
if [ "$(echo "$@" | grep -c "runonce")" -gt 0 ];then
|
|
lightningcli_alias plugin stop /home/bitcoin/cln-plugins-available/plugins/${plugin}/${plugin}.py
|
|
fi |