Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/1.9.0 #10

Merged
merged 8 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM ghcr.io/getalby/hub:v1.8.0 AS builder
FROM ghcr.io/getalby/hub:v1.10.1 AS builder
RUN apt update; apt install -y --no-install-recommends caddy

FROM debian:12-slim AS final

Expand All @@ -10,5 +11,7 @@ COPY --from=builder /usr/lib/nwc/libglalby_bindings.so /usr/lib/nwc/
COPY --from=builder /usr/lib/nwc/libldk_node.so /usr/lib/nwc/
COPY --from=builder /bin/main /bin/
COPY --chmod=755 docker_entrypoint.sh /usr/local/bin/
COPY --from=builder /usr/bin/caddy /usr/bin/
RUN mkdir -p /etc/caddy

LABEL maintainer="andrewlunde <[email protected]>"
145 changes: 0 additions & 145 deletions NOTES.md

This file was deleted.

150 changes: 137 additions & 13 deletions docker_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,143 @@
#!/bin/sh

export LN_BACKEND_TYPE="LND"
export LND_ADDRESS="lnd.embassy:10009" #the LND gRPC address, eg. localhost:10009 (used with the LND backend)
export LND_CERT_FILE="/mnt/lnd/tls.cert" #the location where LND's tls.cert file can be found (used with the LND backend)
export LND_MACAROON_FILE="/mnt/lnd/admin.macaroon" #the location where LND's admin.macaroon file can be found (used with the LND backend)
printf "\n\n [i] Starting Alby Hub ...\n\n"

# Read current LN setup from config
LN_VALUE=$(grep 'lightning:' /data/start9/config.yaml | cut -d ' ' -f 2)

# File to track initial setup (lnd or alby)
SETUP_FILE="/data/start9/initial_setup"
WORK_DIR="/data/albyhub"
BACKUP_DIR="/data/start9/backups"

# Ensure the backup directory exists
mkdir -p "$BACKUP_DIR"

# Determine the initial setup
if [ -f "$SETUP_FILE" ]; then
INITIAL_SETUP=$(cat "$SETUP_FILE")
else
INITIAL_SETUP="$LN_VALUE"
echo "$INITIAL_SETUP" >"$SETUP_FILE" # Store initial setup if it doesn't exist
fi
# Function to create a tar.gz backup of the albyhub directory
backup_dir() {
suffix="$INITIAL_SETUP"
tar_file="$BACKUP_DIR/${suffix}_backup.tar.gz"

# Create a tar.gz file containing the albyhub directory
tar -czf "$tar_file" -C "/data" albyhub 2>/dev/null
echo "[i] Created backup: $tar_file"
}
# Function to restore the albyhub directory from a tar.gz backup
restore_dir() {
suffix="$1" # Either 'lnd' or 'alby'
tar_file="$BACKUP_DIR/${suffix}_backup.tar.gz"

if [ -f "$tar_file" ]; then
rm -rf "$WORK_DIR"
tar -xzf "$tar_file" -C "/data"
echo "[i] Restored from backup: $tar_file"
else
echo "[i] No $suffix backup found."
fi
}

# Handling different setups
if [ "$INITIAL_SETUP" != "$LN_VALUE" ]; then
if [ "$INITIAL_SETUP" = "lnd" ] && [ "$LN_VALUE" = "alby" ]; then
echo "[i] Switching from LND to Alby/LDK..."

# Backup current LND directory
backup_dir

# Restore Alby backup if it exists, otherwise start fresh
if [ -f "$BACKUP_DIR/alby_backup.tar.gz" ]; then
restore_dir "alby"
else
echo "[i] No Alby/LDK backup found, starting fresh..."
rm -rf "$WORK_DIR"
mkdir -p "$WORK_DIR"
fi

# Update the initial setup to 'alby'
echo "alby" >"$SETUP_FILE"

elif [ "$INITIAL_SETUP" = "alby" ] && [ "$LN_VALUE" = "lnd" ]; then
echo "[i] Switching from Alby/LDK to LND..."

# Backup current Alby directory
backup_dir

# Restore LND backup if it exists, otherwise clean up the data directory for initial LND setup
if [ -f "$BACKUP_DIR/lnd_backup.tar.gz" ]; then
restore_dir "lnd"
else
echo "[i] No LND backup found, cleaning up the data directory for initial LND setup..."
rm -rf "$WORK_DIR"
mkdir -p "$WORK_DIR"
fi

# Update the initial setup to 'lnd'
echo "lnd" >"$SETUP_FILE"
fi
fi

# Set up environment variables based on LN_VALUE
if [ "$LN_VALUE" = "lnd" ]; then
export LN_BACKEND_TYPE="LND"
export LND_ADDRESS="lnd.embassy:10009" # the LND gRPC address
export LND_CERT_FILE="/mnt/lnd/tls.cert" # the location where LND's tls.cert file can be found
export LND_MACAROON_FILE="/mnt/lnd/admin.macaroon" # the location where LND's admin.macaroon file can be found
export ENABLE_ADVANCED_SETUP=false
else
# Default to Alby/LDK if lightning value is not "lnd"
export LN_BACKEND_TYPE="LDK"
unset LND_ADDRESS
unset LND_CERT_FILE
unset LND_MACAROON_FILE
fi

export WORK_DIR="/data/albyhub"
export PORT=8080 #the port on which the app should listen on (default='blah' #8080)
export PORT=8080 #the port on which the app should listen on (default='blah' #8080)
export LOG_EVENTS=true # makes debugging easier

# export TOR_ADDRESS=$(yq e '.tor-address' /data/start9/config.yaml)
# export LAN_ADDRESS=$(yq e '.lan-address' /data/start9/config.yaml)
printf "\n\n [i] Starting Alby Hub ...\n\n"
echo "LN Backend Type: " $LN_BACKEND_TYPE
echo "LN Address: " $LND_ADDRESS
echo "LND Cert: " $LND_CERT_FILE
echo "LND Macaroon: " $LND_MACAROON_FILE
# Reverse proxy configuration (aka Firefox patch)
cat <<EOF >/etc/caddy/Caddyfile
{
admin off
servers {
protocols h1 h2c h3
}
}

:8443 {
tls /mnt/cert/main.cert.pem /mnt/cert/main.key.pem
reverse_proxy albyhub.embassy:8080
}
EOF

# Output some debug information
echo "LN Backend Type: $LN_BACKEND_TYPE"
if [ "$LN_VALUE" = "lnd" ]; then
echo "LN Address: $LND_ADDRESS"
echo "LND Cert: $LND_CERT_FILE"
echo "LND Macaroon: $LND_MACAROON_FILE"
fi

# Set up a trap to catch INT signal for graceful shutdown and start
_term() {
echo "Caught INT signal!"
kill -INT "$alby_process" 2>/dev/null
kill -INT "$caddy_process" 2>/dev/null
}

main &
alby_process=$!

caddy run --config /etc/caddy/Caddyfile &
caddy_process=$!

trap _term INT

exec /bin/main
wait $caddy_process $alby_process
29 changes: 19 additions & 10 deletions instructions.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
# Quick Start Guide for Alby Hub

1. **Launch Alby Hub**
Click the `Launch UI` button to start Alby Hub.
1. **Configure Alby Hub**
In the Alby Hub configuration settings, select your preferred Lightning implementation:

2. **Get Started**
On the Alby Welcome screen, click **Get Started (LND)**.
- **LND on this server**: This option tells Alby Hub to use the LND node installed on this StartOS server. It is the more sovereign and secure option, allowing full control over your node.
- **Alby Hub embedded light node**: This option tells Alby Hub to use its own, built-in light node. This option is convenient but offers less control over your node.

3. **Create a Strong Password**
Set a strong password for your Alby Hub account. It’s recommended to store this password securely in your self-hosted Vaultwarden.
2. **Start the Service**
After configuring, start the Alby Hub service.

4. **Connect Your Alby Account**
3. **Launch Alby Hub**
Click the `Launch UI` button to open the Alby Hub interface.

4. **Get Started**
On the Alby Welcome screen, click the **Get Started** button. The button will display either (LND) or (LDK) based on your chosen configuration.

5. **Create a Strong Password**
Set a strong password for your Alby Hub account. It's recommended to store this password securely in your self-hosted Vaultwarden. If you are using the Alby Hub embedded light node, it is critical you do not lose your password, as it will result in loss of funds.

6. **Connect Your Alby Account**
Follow the on-screen instructions to connect your Alby account.

5. **All Set!**
Youre done! Your Alby Hub is now ready to use.
7. **All Set!**
You're done! Your Alby Hub is now ready to use.

## Getting Help

For more information and help about Alby visit [getalby.com](https://getalby.com)
For more information and help about Alby Hub visit [albyhub.com](https://albyhub.com/)

You can also ask for assistance in the [Start9 community chats](https://start9.com/contact).
Loading