Skip to content

Commit

Permalink
cln: load plugins from ${netprefix}cln-plugins-enabled
Browse files Browse the repository at this point in the history
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
  • Loading branch information
openoms committed Jul 20, 2021
1 parent 626b074 commit bcc5ba5
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 47 deletions.
13 changes: 11 additions & 2 deletions home.admin/config.scripts/cln-plugin.backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ function install() {
fi
sudo chmod +x ${plugindir}/${plugin}/${plugin}.py
# symlink to the default plugin dir
if [ ! -L /home/bitcoin/${netprefix}cln-plugins-enabled/backup ];then
sudo ln -s ${plugindir}/backup \
if [ ! -L /home/bitcoin/${netprefix}cln-plugins-enabled/backup.py ];then
sudo ln -s ${plugindir}/backup/backup.py \
/home/bitcoin/${netprefix}cln-plugins-enabled/
fi
fi
Expand All @@ -51,6 +51,9 @@ if [ $1 = on ];then

install

echo "# Stop the ${netprefix}lightningd.service"
sudo systemctl stop ${netprefix}lightningd

# don't overwrite old backup
if [ -f /home/bitcoin/${netprefix}lightningd.sqlite3.backup ];then
echo "# Backup the existing old backup on the SDcard"
Expand All @@ -68,6 +71,12 @@ if [ $1 = on ];then
file:///home/bitcoin/${netprefix}lightningd.sqlite3.backup
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
echo "# Removing the backup plugin"
sudo rm -f /home/bitcoin/${netprefix}cln-plugins-enabled/backup
Expand Down
24 changes: 12 additions & 12 deletions home.admin/config.scripts/cln-plugin.sparko.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ sparko-keys=${masterkeythatcandoeverything}; ${secretaccesskeythatcanreadstuff}:
echo "# Sparko is already configured in the /home/bitcoin/.lightning/${netprefix}config"
fi

###################
# Systemd service #
###################
/home/admin/config.scripts/cln.install-service.sh $CHAIN

echo "# Allowing port ${portprefix}9000 through the firewall"
sudo ufw allow "${portprefix}9000" comment "${netprefix}sparko"

Expand All @@ -153,10 +148,15 @@ sparko-keys=${masterkeythatcandoeverything}; ${secretaccesskeythatcanreadstuff}:
# setting value in raspi blitz config
sudo sed -i "s/^${netprefix}sparko=.*/${netprefix}sparko=on/g" /mnt/hdd/raspiblitz.conf

sleep 5
# show some logs
sudo tail -n100 /home/bitcoin/.lightning/${CLNETWORK}/cl.log | grep sparko
netstat -tulpn | grep "${portprefix}9000"
source /home/admin/raspiblitz.info
if [ "${state}" == "ready" ]; then
echo "# Restart the ${netprefix}lightningd.service to activate Sparko"
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 "# Monitor with:"
Expand All @@ -172,9 +172,8 @@ if [ $1 = off ];then
echo "# Editing /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
/home/admin/config.scripts/cln.install-service.sh $CHAIN
fi
echo "# Restart the ${netprefix}lightningd.service to deactivate Sparko"
sudo systemctl restart ${netprefix}lightningd

echo "# Deny port ${portprefix}9000 through the firewall"
sudo ufw deny "${portprefix}9000"
Expand All @@ -189,4 +188,5 @@ if [ $1 = off ];then
# setting value in raspi blitz config
sudo sed -i "s/^${netprefix}sparko=.*/${netprefix}sparko=off/g" /mnt/hdd/raspiblitz.conf
echo "# Sparko was uninstalled"

fi
9 changes: 4 additions & 5 deletions home.admin/config.scripts/cln.install-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $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
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
fi
sparkoStart="--plugin=/home/bitcoin/${netprefix}cln-plugins-enabled/sparko"
fi

if grep -Eq "${netprefix}clnEncryptedHSM=on" /mnt/hdd/raspiblitz.conf;then
Expand All @@ -30,6 +29,7 @@ else
passwordInput=""
encryptedHSMoption=""
fi

sudo systemctl stop ${netprefix}lightningd
sudo systemctl disable ${netprefix}lightningd
echo "# Create /etc/systemd/system/${netprefix}lightningd.service"
Expand All @@ -42,8 +42,7 @@ User=bitcoin
Group=bitcoin
Type=simple
ExecStart=/bin/sh -c '${passwordInput}/usr/local/bin/lightningd\
--conf=/home/bitcoin/.lightning/${netprefix}config\
${sparkoStart} ${encryptedHSMoption}'
--conf=${CLNCONF} ${encryptedHSMoption}'
Restart=always
TimeoutSec=120
RestartSec=30
Expand Down
17 changes: 9 additions & 8 deletions home.admin/config.scripts/cln.install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ if [ "$1" = on ]||[ "$1" = update ]||[ "$1" = experimental ]||[ "$1" = testPR ];
sudo rm -rf /home/bitcoin/.lightning # not a symlink, delete
sudo mkdir -p /mnt/hdd/app-data/.lightning
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 "
# lightningd configuration for ${network} ${CHAIN}
Expand All @@ -156,9 +158,9 @@ proxy=127.0.0.1:9050
bind-addr=127.0.0.1:${portprefix}9736
addr=statictor:127.0.0.1:9051/torport=${portprefix}9736
always-use-proxy=true
" | sudo tee /home/bitcoin/.lightning/${netprefix}config
" | sudo tee ${CLNCONF}
else
echo "# The file /home/bitcoin/.lightning/${netprefix}config is already present"
echo "# The file ${CLNCONF} is already present"
fi
sudo chown -R bitcoin:bitcoin /mnt/hdd/app-data/.lightning
sudo chown -R bitcoin:bitcoin /home/bitcoin/
Expand All @@ -177,16 +179,15 @@ always-use-proxy=true
echo "# Adding aliases"
echo "\
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\
--conf=/home/bitcoin/.lightning/${netprefix}config\"
--conf=${CLNCONF}\"
alias ${netprefix}clnlog=\"sudo\
tail -n 30 -f /home/bitcoin/.lightning/${CLNETWORK}/cl.log\"
alias ${netprefix}clnconf=\"sudo\
nano /home/bitcoin/.lightning/${netprefix}config\"
nano ${CLNCONF}\"
" | sudo tee -a /home/admin/_aliases

echo
echo "# The installed C-lightning version is: $(sudo -u bitcoin /usr/local/bin/lightningd --version)"
echo
echo "# To activate the aliases reopen the terminal or use:"
Expand Down
49 changes: 29 additions & 20 deletions home.admin/config.scripts/network.aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ if [ $1 = getvars ];then
fi
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
if [ ${#chain} -eq 0 ]; then
chain=main
Expand All @@ -60,7 +52,12 @@ if [ $1 = getvars ];then
# netprefix is: "" | t | s
# portprefix is: "" | 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"
L1rpcportmod=1
L2rpcportmod=1
Expand All @@ -70,23 +67,35 @@ if [ $1 = getvars ];then
L1rpcportmod=3
L2rpcportmod=3
portprefix=3
elif [ ${chain} = "main" ];then
netprefix=""
L1rpcportmod=""
L2rpcportmod=0
portprefix=""
fi
echo "netprefix=${netprefix}"
echo "portprefix=${portprefix}"
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
if [ $chain = main ];then
CLNETWORK=${network}
else
CLNETWORK=${chain}net
# CLNCONF is the path to the config
if [ ${CLNETWORK} = "bitcoin" ]; then
CLNCONF="/home/bitcoin/.lightning/config"
else
CLNCONF="/home/bitcoin/.lightning/${CLNETWORK}/config"
fi
echo "CLNCONF=${CLNCONF}"
typeprefix=c
fi
echo CLNETWORK=${CLNETWORK}

# typeprefix is: "" | c
if [ $LNTYPE = lnd ];then
typeprefix=''
fi
echo "typeprefix=${typeprefix}"

# instead of all
# sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net
Expand Down

0 comments on commit bcc5ba5

Please sign in to comment.