From 57148484348ca33f170ab85f00debe67cc3b265f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Thu, 10 Apr 2025 12:28:08 +0200 Subject: [PATCH] feat: install lnbits.sh bash script (#2684) (#3101) --- docs/guide/installation.md | 22 +++++++++++++--- lnbits.sh | 54 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 lnbits.sh diff --git a/docs/guide/installation.md b/docs/guide/installation.md index 8a6bd6762..def8fe548 100644 --- a/docs/guide/installation.md +++ b/docs/guide/installation.md @@ -29,11 +29,13 @@ It is recommended to use the latest version of Poetry. Make sure you have Python ### Install Python 3.12 +## Option 2 (recommended): Poetry + +It is recommended to use the latest version of Poetry. Make sure you have Python version 3.9 or higher installed. + +### Verify Python version + ```sh -sudo add-apt-repository -y ppa:deadsnakes/ppa -sudo apt update -y -sudo apt install -y python3.12 python3.12-dev # ensure correct headers needed for secp256k1 -sudo apt install -y pkg-config python3-dev build-essential # ensure correct headers python3 --version ``` @@ -83,6 +85,18 @@ poetry install --only main # Start LNbits with `poetry run lnbits` ``` +## Option 2: Install script (on Debian/Ubuntu) + +```sh +wget https://raw.githubusercontent.com/lnbits/lnbits/main/lnbits.sh && +chmod +x lnbits.sh && +./lnbits.sh +``` + +Now visit `0.0.0.0:5000` to make a super-user account. + +`./lnbits.sh` can be used to run, but for more control `cd lnbits` and use `poetry run lnbits` (see previous option). + ## Option 3: Nix ```sh diff --git a/lnbits.sh b/lnbits.sh new file mode 100644 index 000000000..8e2c990fc --- /dev/null +++ b/lnbits.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Check install has not already run +if [ ! -d lnbits/data ]; then + + # Update package list and install prerequisites non-interactively + sudo apt update -y + sudo apt install -y software-properties-common + + # Add the deadsnakes PPA repository non-interactively + sudo add-apt-repository -y ppa:deadsnakes/ppa + + # Install Python 3.9 and distutils non-interactively + sudo apt install -y python3.9 python3.9-distutils + + # Install Poetry + curl -sSL https://install.python-poetry.org | python3.9 - + + # Add Poetry to PATH for the current session + export PATH="/home/$USER/.local/bin:$PATH" + + if [ ! -d lnbits/wallets ]; then + # Clone the LNbits repository + git clone https://github.com/lnbits/lnbits.git + if [ $? -ne 0 ]; then + echo "Failed to clone the repository ... FAIL" + exit 1 + fi + # Ensure we are in the lnbits directory + cd lnbits || { echo "Failed to cd into lnbits ... FAIL"; exit 1; } + fi + + git checkout main + # Make data folder + mkdir data + + # Copy the .env.example to .env + cp .env.example .env + +elif [ ! -d lnbits/wallets ]; then + # cd into lnbits + cd lnbits || { echo "Failed to cd into lnbits ... FAIL"; exit 1; } +fi + +# Install the dependencies using Poetry +poetry env use python3.9 +poetry install --only main + +# Set environment variables for LNbits +export LNBITS_ADMIN_UI=true +export HOST=0.0.0.0 + +# Run LNbits +poetry run lnbits \ No newline at end of file