From 1373f46ef3d5e59ee16f5aafb997be5883fd1ba8 Mon Sep 17 00:00:00 2001 From: shocknet-justin Date: Wed, 27 Aug 2025 11:51:03 -0400 Subject: [PATCH] readme, version checks, better url def --- DOCKER.md | 24 +++++++++++++ README.md | 61 ++++++++++++++++++-------------- scripts/install.sh | 34 +++++++++++++----- scripts/install_lightning_pub.sh | 24 +++++++++++++ 4 files changed, 108 insertions(+), 35 deletions(-) create mode 100644 DOCKER.md diff --git a/DOCKER.md b/DOCKER.md new file mode 100644 index 00000000..8ffbb87d --- /dev/null +++ b/DOCKER.md @@ -0,0 +1,24 @@ +# Docker Installation + +> [!WARNING] +> The Docker deployment method is currently unmaintained and may not work as expected. Help is wanted! If you are a Docker enjoyer, please consider contributing to this deployment method. + +1. Pull the Docker image: + +```ssh +docker pull ghcr.io/shocknet/lightning-pub:latest +``` + +2. Run the Docker container: + +```ssh +docker run -d \ + --name lightning-pub \ + --network host \ + -p 1776:1776 \ + -p 1777:1777 \ + -v /path/to/local/data:/app/data \ + -v $HOME/.lnd:/root/.lnd \ + ghcr.io/shocknet/lightning-pub:latest +``` +Network host is used so the service can reach a local LND via localhost. LND is assumed to be under the users home folder, update this location as needed. diff --git a/README.md b/README.md index 901e5bc7..60b2da0a 100644 --- a/README.md +++ b/README.md @@ -70,47 +70,52 @@ Dashboard Wireframe: Paste one-line and have a Pub node in under 2 minutes. It uses neutrino so you can run it on a $5 VPS or old laptop. -This method installs all dependencies and creates systemd entries. It has been tested only in Ubuntu/Debian x64 environments, but is general enough that it should work on any linux system with systemd. +This method installs all dependencies and creates user-level systemd services. -Mac support is rough'd in, but completely untested. Help wanted. +**Platform Support:** +- ✅ **Debian/Ubuntu**: Fully tested and supported +- ⚠️ **Arch/Fedora**: Should work but untested - please report issues +- 🚧 **macOS**: Basic support stubbed in but completely untested - help wanted To start, run the following command: -```ssh -sudo wget -qO- https://deploy.lightning.pub | sudo bash +```bash +wget -qO- https://deploy.lightning.pub | bash ``` It should look like this in a minute or so ![One-Line Deployment](https://raw.githubusercontent.com/shocknet/Lightning.Pub/master/one-liner.png) +**Note:** The installation is now confined to user-space, meaning: +- No sudo required for installation +- All data stored in `$HOME/lightning_pub/` +- Logs available at `$HOME/lightning_pub/install.log` + +**⚠️ Migration from Previous Versions:** +Previous system-wide installations (as of 8.27.2025) need some manual intervention: +1. Stop existing services: `sudo systemctl stop lnd lightning_pub` +2. Disable services: `sudo systemctl disable lnd lightning_pub` +3. Remove old systemd units: `sudo rm /etc/systemd/system/lnd.service /etc/systemd/system/lightning_pub.service` +4. Reload systemd: `sudo systemctl daemon-reload` +5. Run the new installer: `wget -qO- https://deploy.lightning.pub | bash` + Please report any issues to the [issue tracker](https://github.com/shocknet/Lightning.Pub/issues). #### Automatic updates -These are controversial to push by default and we're leaning against it. You can however add the line to cron to run it periodically and it will handle updating. +These are controversial, so we don't include them. You can however add a line to your crontab to re-run the installer on your time preference and it will gracefully handle updating: + +```bash +# Add to user's crontab (crontab -e) - runs weekly on Sunday at 2 AM +0 2 * * 0 wget -qO- https://deploy.lightning.pub | bash +``` + +**Note:** The installer will only restart services if version checks deem necessary. ### Docker Installation -1. Pull the Docker image: - -```ssh -docker pull ghcr.io/shocknet/lightning-pub:latest -``` - -2. Run the Docker container: - -```ssh -docker run -d \ - --name lightning-pub \ - --network host \ - -p 1776:1776 \ - -p 1777:1777 \ - -v /path/to/local/data:/app/data \ - -v $HOME/.lnd:/root/.lnd \ - ghcr.io/shocknet/lightning-pub:latest -``` -Network host is used so the service can reach a local LND via localhost. LND is assumed to be under the users home folder, update this location as needed. +See the [Docker Installation Guide](DOCKER.md). ### Manual CLI Installation @@ -140,9 +145,11 @@ npm start ## Usage Notes -Connect with [wallet2](https://github.com/shocknet/wallet2) using the wallet admin string that gets logged at startup. The nprofile of the node can also be used to send invitation links to guests. +Connect with ShockWallet ([wallet2](https://github.com/shocknet/wallet2)) using the wallet admin string that gets logged at startup. Simply copy/paste the string into the node connection screen. -Note that connecting with wallet will create an account on the node, it will not show or have access to the full LND balance. +The nprofile of the node can also be used to send invitation links to guests via the web version of ShockWallet. + +**Note that connecting with wallet will create an account on the node, it will not show or have access to the full LND balance. Allocating existing funds to the admin user will be added to the operator dashboard in a future release.** Additional docs are WIP at [docs.shock.network](https://docs.shock.network) @@ -156,4 +163,4 @@ Additional docs are WIP at [docs.shock.network](https://docs.shock.network) ## Warning > [!WARNING] -> While this software has been used in a high-profile production environment for over a year, it should still be considered bleeding edge. Special care has been taken to mitigate the risk of drainage attacks, which is a common risk to all Lightning API's. An integrated Watchdog service will terminate spends if it detects a discrepency between LND and the database, for this reason **IT IS NOT RECOMMENDED TO USE PUB ALONGSIDE OTHER ACCOUNT SYSTEMS**. While we give the utmost care and attention to security, **the internet is an adversarial environment and SECURITY/RELIABILITY ARE NOT GUARANTEED- USE AT YOUR OWN RISK**. +> While this software has been used in a high-profile production environment for several years, it should still be considered bleeding edge. Special care has been taken to mitigate the risk of drainage attacks, which is a common risk to all Lightning APIs. An integrated Watchdog service will terminate spends if it detects a discrepancy between LND and the database, for this reason **IT IS NOT RECOMMENDED TO USE PUB ALONGSIDE OTHER ACCOUNT SYSTEMS** such as AlbyHub, LNBits, or BTCPay - this watchdog may however be disabled. While we give the utmost care and attention to security, **the internet is an adversarial environment and SECURITY/RELIABILITY ARE NOT GUARANTEED- USE AT YOUR OWN RISK**. diff --git a/scripts/install.sh b/scripts/install.sh index e7f22303..5476ce84 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -2,7 +2,7 @@ set -e # Use user-space log file -LOG_FILE="$HOME/.lightning_pub/install.log" +LOG_FILE="$HOME/lightning_pub/install.log" mkdir -p "$(dirname "$LOG_FILE")" touch $LOG_FILE @@ -15,12 +15,15 @@ log() { } SCRIPT_VERSION="0.2.0" -REPO_URL="https://github.com/shocknet/Lightning.Pub/tarball/script" -BASE_URL="https://raw.githubusercontent.com/shocknet/Lightning.Pub/script/scripts/" +REPO="shocknet/Lightning.Pub" +BRANCH="script" +BASE_URL="https://raw.githubusercontent.com/${REPO}/${BRANCH}" +REPO_URL="https://github.com/${REPO}/tarball/${BRANCH}" +SCRIPTS_URL="${BASE_URL}/scripts/" cleanup() { echo "Cleaning up temporary files..." - rm -f "$HOME/.lightning_pub/tmp"/*.sh 2>/dev/null || true + rm -f "$HOME/lightning_pub_tmp"/*.sh 2>/dev/null || true } trap cleanup EXIT @@ -48,11 +51,11 @@ modules=( log "Script version $SCRIPT_VERSION" # Create user-space temp directory -mkdir -p "$HOME/.lightning_pub/tmp" +mkdir -p "$HOME/lightning_pub_tmp" for module in "${modules[@]}"; do - wget -q "${BASE_URL}/${module}.sh" -O "$HOME/.lightning_pub/tmp/${module}.sh" || log_error "Failed to download ${module}.sh" 1 - source "$HOME/.lightning_pub/tmp/${module}.sh" || log_error "Failed to source ${module}.sh" 1 + wget -q "${SCRIPTS_URL}${module}.sh" -O "$HOME/lightning_pub_tmp/${module}.sh" || log_error "Failed to download ${module}.sh" 1 + source "$HOME/lightning_pub_tmp/${module}.sh" || log_error "Failed to source ${module}.sh" 1 done detect_os_arch @@ -81,7 +84,22 @@ else install_nodejs || log_error "Failed to install Node.js" 1 - install_lightning_pub "$REPO_URL" || log_error "Failed to install Lightning.Pub" 1 + pub_install_result=$(install_lightning_pub "$REPO_URL") + pub_install_status=$? + + case $pub_install_status in + 0) + log "Lightning.Pub installation/upgrade completed successfully." + pub_upgrade_status=100 + ;; + 2) + log "Lightning.Pub is already up-to-date. No restart needed." + pub_upgrade_status=0 + ;; + *) + log_error "Lightning.Pub installation failed" $pub_install_status + ;; + esac log "Starting services..." touch /tmp/pub_install_timestamp diff --git a/scripts/install_lightning_pub.sh b/scripts/install_lightning_pub.sh index 393d4e0f..5a20bdc7 100755 --- a/scripts/install_lightning_pub.sh +++ b/scripts/install_lightning_pub.sh @@ -33,6 +33,25 @@ install_lightning_pub() { # Check if directory exists and is not empty to determine if it's an upgrade if [ -d "$USER_HOME/lightning_pub" ] && [ "$(ls -A $USER_HOME/lightning_pub)" ]; then + log "Checking if Lightning.Pub update is needed..." + + # Check if update is needed by comparing commit hashes + # Get latest commit hash from GitHub API + LATEST_COMMIT=$(wget -qO- "https://api.github.com/repos/${REPO}/commits/${BRANCH}" 2>/dev/null | grep -o '"sha":"[^"]*"' | cut -d'"' -f4 | head -c 40) + + if [ -n "$LATEST_COMMIT" ]; then + # Check if we have a stored commit hash and compare + if [ -f "$USER_HOME/lightning_pub/.installed_commit" ]; then + CURRENT_COMMIT=$(cat "$USER_HOME/lightning_pub/.installed_commit" 2>/dev/null | head -c 40) + + if [ "$CURRENT_COMMIT" = "$LATEST_COMMIT" ]; then + log "${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} is already at the latest commit. No update needed." + rm -rf $USER_HOME/lightning_pub_temp + return 2 # Special exit code to indicate no changes + fi + fi + fi + log "Upgrading existing Lightning.Pub installation..." upgrade_status=100 # Use 100 to indicate an upgrade else @@ -99,5 +118,10 @@ install_lightning_pub() { return 1 fi + # Store the commit hash for future update checks + if [ -n "$LATEST_COMMIT" ]; then + echo "$LATEST_COMMIT" > "$USER_HOME/lightning_pub/.installed_commit" + fi + return 0 } \ No newline at end of file