Some features implemented on the RaspiBlitz which can be tackled one-by-one after the initial install is functional:
- git verification
- creating an hsm_secret from seed
- systemd service
- setting up the backup plugin
- hsm_secret encryption
#!/bin/bash | |
# https://lightning.readthedocs.io/ | |
# https://github.com/ElementsProject/lightning/releases | |
# CLVERSION=v0.10.2 | |
# install the latest master by using the last commit id | |
# https://github.com/ElementsProject/lightning/commit/master | |
# CLVERSION="063366ed7e3b7cc12a8d1681acc2b639cf07fa23" | |
# https://github.com/ElementsProject/lightning/tree/master/contrib/keys | |
# PGPsigner="rustyrussel" | |
# PGPpubkeyLink="https://raw.githubusercontent.com/ElementsProject/lightning/master/contrib/keys/rustyrussell.txt" | |
# PGPpubkeyFingerprint="D9200E6CD1ADB8F1" | |
# PGPsigner="cdecker" | |
# PGPpubkeyLink="https://raw.githubusercontent.com/ElementsProject/lightning/master/contrib/keys/${PGPsigner}.txt" | |
# PGPpubkeyFingerprint="A26D6D9FE088ED58" | |
# refer also to https://github.com/real-doman/RaspiBolt/blob/c-lightning/c-lightning.md | |
# Login as "admin" user, create the "cl" service user and add it to the groups "bitcoin" and "debian-tor" | |
sudo adduser --disabled-password --gecos "" cl | |
sudo usermod -a -G bitcoin,debian-tor cl | |
# download and verify the source from github | |
cd /home/cl | |
# - Cloning https://github.com/ElementsProject/lightning.git | |
sudo -u cl git clone https://github.com/ElementsProject/lightning.git | |
cd lightning | |
# - Reset to version v0.10.2 | |
sudo -u cl git reset --hard v0.10.2 | |
## git verification | |
## see raspiblitz | |
# /home.admin/config.scripts/blitz.git-verify.sh | |
# sudo -u bitcoin /home/admin/config.scripts/blitz.git-verify.sh \ | |
# "${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" "${CLVERSION}" || exit 1 | |
# from https://lightning.readthedocs.io/INSTALL.html#to-build-on-ubuntu | |
sudo apt-get install -y \ | |
autoconf automake build-essential git libtool libgmp-dev \ | |
libsqlite3-dev python3 python3-mako net-tools zlib1g-dev libsodium-dev \ | |
gettext | |
# additional requirements | |
sudo apt-get install -y postgresql libpq-dev | |
# installing mrkd and mistune for root is likely redundant so just install for the cl user | |
#sudo pip3 install mrkd==0.2.0 | |
#sudo pip3 install mistune==0.8.4 | |
# for pylightning | |
# - Install from the requirements.txt | |
sudo -u cl pip3 install --user mrkd==0.2.0 | |
sudo -u cl pip3 install --user mistune==0.8.4 | |
sudo -u cl pip3 install --user -r requirements.txt | |
#- Configuring EXPERIMENTAL_FEATURES enabled" | |
sudo -u cl ./configure --enable-experimental-features | |
#"- Building C-lightning from source" | |
sudo -u cl make | |
# - Install to /usr/local/bin/ | |
sudo make install | |
########## | |
# Config # | |
########## | |
# check version | |
sudo -u cl lightning-cli --version | |
# Add plugin-dir: /home/cl/cl-plugins-enabled" | |
# Add plugin-dir: /home/cl/cl-plugins-available" | |
# note that the disk is mounted with noexec | |
sudo -u cl mkdir /home/cl/cl-plugins-enabled | |
sudo -u cl mkdir /home/cl/cl-plugins-available | |
# Store the lightning data in /data | |
# Symlink to /home/cl/ | |
sudo rm -rf /home/cl/.lightning # not a symlink, delete | |
sudo mkdir -p /data/.lightning | |
sudo ln -s /data/.lightning /home/cl/ | |
# Create a symbolic link, which points from your admin home directory into the lightning directory | |
sudo ln -s /data/.lightning /home/admin/ | |
sudo -u cl mkdir /home/cl/.lightning/bitcoin | |
# Create /home/cl/.lightning/config" | |
# paste this as a block | |
echo "# lightningd configuration for bitcoin mainnet | |
network=bitcoin | |
log-file=cl.log | |
log-level=info | |
plugin-dir=/home/cl/cl-plugins-enabled | |
# Tor settings | |
proxy=127.0.0.1:9050 | |
bind-addr=127.0.0.1:9736 | |
addr=statictor:127.0.0.1:9051/torport=9736 | |
always-use-proxy=true | |
" | sudo tee /home/cl/.lightning/config | |
sudo chown -R cl:cl /data/.lightning | |
sudo chown -R cl:cl /home/cl/ | |
## Create a wallet from seedwords for mainnet | |
## see raspiblitz /home.admin/config.scripts/cl.hsmtool.sh new-force mainnet | |
################# | |
# Backup plugin # | |
################# | |
# see raspiblitz | |
# /home.admin/config.scripts/cl-plugin.backup.sh on mainnet | |
################### | |
# Systemd service # | |
################### | |
## see Raspiblitz | |
# /home.admin/config.scripts/cl.install-service.sh mainnet | |
############# | |
# logrotate # | |
############# | |
# Set logrotate for lightningd" | |
sudo -u cl mkdir /home/cl/.lightning/bitcoin/cl.log_old | |
# paste this as a block | |
echo "\ | |
/home/cl/.lightning/bitcoin/cl.log | |
{ | |
rotate 5 | |
daily | |
copytruncate | |
missingok | |
olddir /home/cl/.lightning/bitcoin/cl.log_old | |
notifempty | |
nocompress | |
sharedscripts | |
# We don't need to kill as we use copytruncate | |
#postrotate | |
# kill -HUP \`cat /run/lightningd/lightningd.pid\' | |
#endscript | |
su cl cl | |
}" | sudo tee /etc/logrotate.d/lightningd | |
# debug logrotate: | |
# sudo logrotate --debug /etc/logrotate.d/lightningd | |
# Monitor the lightningd with:" | |
# sudo journalctl -fu lightningd" | |
# sudo systemctl status lightningd" | |
# logs:" | |
# sudo tail -f /home/cl/.lightning/bitcoin/cl.log" | |
# for the command line options use" | |
# lightning-cli help" |