Skip to content
Open
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Let's assume your domain is `btcpay.EXAMPLE.com`.

The setup below assumes you want to support Bitcoin, Core Lightning (CLN), HTTPS automatically configured by Nginx. It also enables node pruning, which you can [modify](#generated-docker-compose) or ignore if you have enough disk space for a full node. Finally, your domain is `btcpay.EXAMPLE.com` should reflect your actual domain name.

[Environment variables](#environment-variables) can be tailored to your needs. Some variables require additional storage space.
[Environment variables](#environment-variables) can be tailored to your needs. Some variables require additional storage space. It may be useful to you to save your environment variables to a script, [details here](./docs/save-env-vars.md).

```bash
# Login as root
Expand Down
3 changes: 2 additions & 1 deletion docs/chatwoot.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ cat >> Generated/chatwoot-config.env <<EOL
EOL
```
3. Add chatwoot as an option to your BTCPay deployment and set the host to use (point DNS to server as well)
*Note: if using a script to save your environment variables, save them to the script - [guide here](./docs/save-env-vars.md)

```bash
CHATWOOT_HOST="chatwoot.xpayserver.com"
BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-chatwoot"
. btcpay-setup.sh -i

```
4. Wait for BTPay to be online and then create the database for chatwoot
4. Wait for BTCPay to be online and then create the database for chatwoot

```bash
docker exec -ti chatwoot sh -c "export DISABLE_DATABASE_ENVIRONMENT_CHECK=1 && bundle exec rails db:reset"
Expand Down
11 changes: 6 additions & 5 deletions docs/cloudflare-tunnel.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ First, we are going to create the tunnel on Cloudflare.

![BTCPay Server Cloudflare Tunnel](./img/btcpayexposecloudflare5.jpg)

8. In the SSH section of your server, add Cloudflare tunnel by running the following script. (replace `<YOUR_TOKEN_HERE>` with what you copied in step `5.`, and also replace `<YOUR_DOMAIN_HERE>` with the domain you entered in steps `7.`)
8. Log in to your server via SSH, login as root and navigate to `path/to/btcpayserver-docker/`. Add Cloudflare tunnel by running the following script. (Replace `<YOUR_TOKEN_HERE>` with what you copied in step `5.`, and also replace `<YOUR_DOMAIN_HERE>` with the domain you entered in step `7.`). If using [this guide](./docs/save-env-vars.md), remember to update script.

```bash
BTCPAY_HOST="<YOUR_DOMAIN_HERE>"
export BTCPAY_HOST="<YOUR_DOMAIN_HERE>"
[[ "$REVERSEPROXY_DEFAULT_HOST" ]] && REVERSEPROXY_DEFAULT_HOST="$BTCPAY_HOST"
CLOUDFLARE_TUNNEL_TOKEN="<YOUR_TOKEN_HERE>"
BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-cloudflared"
BTCPAYGEN_EXCLUDE_FRAGMENTS="$BTCPAYGEN_EXCLUDE_FRAGMENTS;nginx-https"
export CLOUDFLARE_TUNNEL_TOKEN="<YOUR_TOKEN_HERE>"
export BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-cloudflared"
export BTCPAYGEN_EXCLUDE_FRAGMENTS="$BTCPAYGEN_EXCLUDE_FRAGMENTS;nginx-https"
. btcpay-setup.sh -i
```

Expand Down
2 changes: 1 addition & 1 deletion docs/fireflyiii.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It can help you keep track of expenses, income, budgets and everything in betwee

1. Connect as root to your server
2. Configure a domain's DNS to point to your server ip. e.g. `firefly.yourserver.org`
3. Add fireflyiii as an option to your docker deployment
3. Add fireflyiii as an option to your docker deployment. *Note: if using a script to save your environment variables, save them to the script - [guide here](./docs/save-env-vars.md)

```bash
BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-fireflyiii"
Expand Down
1 change: 1 addition & 0 deletions docs/joinmarket.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ For hardcore bitcoiners only.
BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-joinmarket"
. btcpay-setup.sh -i
```
Or add to script if using [this guide](./docs/save-env-vars.md).

Then you need to setup your default joinmarket wallet:

Expand Down
1 change: 1 addition & 0 deletions docs/lightning-terminal.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export LIT_PASSWD="sUpErSeCuRe"
export BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-lightning-terminal"
. btcpay-setup.sh -i
```
If using [this guide](./docs/save-env-vars.md) to save your config to a script, remember to add the new options.

Afterwards you should see Lightning Terminal appear as a service on the Server Settings > Services page in BTCPay Server.

Expand Down
1 change: 1 addition & 0 deletions docs/ndlc.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ You need to add ndlc's docker fragment to your install with:
BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-ndlc"
. btcpay-setup.sh -i
```
If using [this guide](./docs/save-env-vars.md), remember to update script.

You can then use `ndlc-cli.sh` to run use ndlc-cli, for example:

Expand Down
1 change: 1 addition & 0 deletions docs/pihole.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Let's imagine the local IP of your BTCPay Server is `192.168.1.2`.
BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-pihole"
. btcpay-setup.sh -i
```
If using [this guide](./docs/save-env-vars.md), remember to update script.

3. If your server has a firewall, make sure it allow incoming traffic to port `53 (UDP)`.
4. Configure your home router DHCP server to use `192.168.1.2` as primary DNS server.
Expand Down
139 changes: 139 additions & 0 deletions docs/save-env-vars.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Save Environment Variables to Script

Environment Variables are lost upon logging out of the server. This means that any change to our config requires us to export ALL variables again before running `. ./btcpay-setup.sh -i`.

One solution to this might be simply saving your config as a `.txt` file and copying over from there, but this does not alleviate us of the manual labor of pasting each line.

My solution: save them as a script that we will run using `source` before runnning `btcpay-setup.sh`.

## Basic Way
From the [main docker deployment page](./README.md#full-installation-for-technical-users) our initial setup will look like this:

```bash
# Login as root
sudo su -

# Create a folder for BTCPay
mkdir BTCPayServer
cd BTCPayServer

# Clone this repository
git clone https://github.com/btcpayserver/btcpayserver-docker
cd btcpayserver-docker

# Run btcpay-setup.sh with the right parameters
export BTCPAY_HOST="btcpay.EXAMPLE.com"
export NBITCOIN_NETWORK="mainnet"
export BTCPAYGEN_CRYPTO1="btc"
export BTCPAYGEN_ADDITIONAL_FRAGMENTS="opt-save-storage-s"
export BTCPAYGEN_REVERSEPROXY="nginx"
export BTCPAYGEN_LIGHTNING="clightning"
export BTCPAY_ENABLE_SSH=true
. ./btcpay-setup.sh -i

exit
```

### Updating
SSH into the server, log in as root and navigate to the `btcpayserver-docker` folder.
```bash
# Login as root
sudo su -

# Navigate to directory
cd BTCPayServer/btcpayserver-docker/

# export ALL environment variables fresh because they didn't stick from the first time.
export BTCPAY_HOST="btcpay.EXAMPLE.com"
export NBITCOIN_NETWORK="mainnet"
export BTCPAYGEN_CRYPTO1="btc"
export BTCPAYGEN_ADDITIONAL_FRAGMENTS="opt-save-storage-s"
export BTCPAYGEN_REVERSEPROXY="nginx"
export BTCPAYGEN_LIGHTNING="clightning"
export BTCPAY_ENABLE_SSH=true
[[ "$REVERSEPROXY_DEFAULT_HOST" ]] && REVERSEPROXY_DEFAULT_HOST="$BTCPAY_HOST"
export CLOUDFLARE_TUNNEL_TOKEN="<YOUR_TOKEN_HERE>"
export BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-cloudflared"
export BTCPAYGEN_EXCLUDE_FRAGMENTS="$BTCPAYGEN_EXCLUDE_FRAGMENTS;nginx-https"

# build again
. ./btcpay-setup.sh -i
```

## Script Solution
Ours will look like this:

```bash
# Login as root
sudo su -

# Create a folder for BTCPay
mkdir BTCPayServer
cd BTCPayServer

# Clone this repository
git clone https://github.com/btcpayserver/btcpayserver-docker
cd btcpayserver-docker

# Create and edit our custom script
nano btcpay.cust-env.sh
```

In nano:
```bash
# modify these to your custom setup, for example adding options for cloudflare tunnel support
export BTCPAY_HOST="btcpay.EXAMPLE.com"
export NBITCOIN_NETWORK="mainnet"
export BTCPAYGEN_CRYPTO1="btc"
export BTCPAYGEN_ADDITIONAL_FRAGMENTS="opt-save-storage-s"
export BTCPAYGEN_REVERSEPROXY="nginx"
export BTCPAYGEN_LIGHTNING="clightning"
export BTCPAY_ENABLE_SSH=true
```
Save this by using CTRL+X, Y and Enter.

Build the server:
```bash
# load the environment variables to your current session
source ./btcpay.cust-env.sh

# build
. ./btcpay-setup.sh -i
```

### Updating with the script

So you logged out after building your very own BTCPay server implementation.
Things are going smoothly but now you find that you need to update the configuration to add support for a feature you hadn't originally implemented.
For this example, I'll add a cloudflare tunnel to the server. Keep in mind, you'll need to follow the [docs](./docs/cloudflare-tunnel.md) regarding the cloudflare website which I won't reproduce here.

1. Follow the above steps to login as root and navigate to the `btcpayserver-docker` directory.

2. Stop all btcpay related docker containers. You can use docker ps to make sure that these are the correct names for your containers. Modify accordingly.
```bash
docker stop nginx-gen btcpayserver_bitcoind nginx generated_btcpayserver_1 generated_nbxplorer_1 tor-gen generated_postgres_1 tor
```

3. Follow the [docs](./docs/cloudflare-tunnel.md) to create the cloudflare service on their website. Then, update the environment script file.
```bash
# edit the file
nano btcpay.cust-env.sh

# Add these lines to the end of the file. Don't forget to modify the cloudflare tunnel token.
[[ "$REVERSEPROXY_DEFAULT_HOST" ]] && REVERSEPROXY_DEFAULT_HOST="$BTCPAY_HOST"
export CLOUDFLARE_TUNNEL_TOKEN="<YOUR_TOKEN_HERE>"
export BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-cloudflared"
export BTCPAYGEN_EXCLUDE_FRAGMENTS="$BTCPAYGEN_EXCLUDE_FRAGMENTS;nginx-https"
```
Again, saving the file using CTRL+X, Y and Enter.

4. Rebuild the server. Fun fact: the bitcoin node is unaffected and you won't have to do another IBD :D

Notice how the build process every time is just two lines with your variables saved safely in a file where you can view/modify them at will.
```bash
# load the environment variables to your current session
source ./btcpay.cust-env.sh

# build
. ./btcpay-setup.sh -i
```
1 change: 1 addition & 0 deletions docs/tallycoin-connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export TALLYCOIN_PASSWD_CLEARTEXT="sUpErSeCuRe"
BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-tallycoin-connect"
. btcpay-setup.sh -i
```
If using [this guide](./docs/save-env-vars.md), remember to update script.

Afterwards you should see Tallycoin Connect appear as a service on the Server Settings > Services page in BTCPay Server.

Expand Down