Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a99f24b1aa |
235
README.md
235
README.md
@ -2,19 +2,236 @@
|
||||
|
||||
Instructions to deploy BTCPay Server in [production environment](https://github.com/btcpayserver/btcpayserver-docker/tree/master/Production) hosted in Microsoft Azure.
|
||||
|
||||
You can click on this button to view what will be deployed by your deployment:
|
||||
|
||||
[](http://armviz.io/#?load=https%3A%2F%2Fraw.githubusercontent.com%2Fbtcpayserver%2Fbtcpayserver-azure%2Fmaster%2Fazuredeploy.json)
|
||||
|
||||
The following instructions assume you have [Microsoft Azure](https://azure.microsoft.com/) subscription.
|
||||
|
||||
You can click on this button to deploy BTCPayServer:
|
||||
|
||||
[](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fbtcpayserver%2Fbtcpayserver-azure%2Fmaster%2Fazuredeploy.json)
|
||||
|
||||
You can see our video for an overview:
|
||||
|
||||
[](http://www.youtube.com/watch?v=Bxs95BdEMHY "BTCPay - One Click Setup")
|
||||
|
||||
You can find more details about the tooling install in the Virtual Machine in [the tooling section of BTCPayServer-Docker repository](https://github.com/btcpayserver/btcpayserver-docker/blob/master/README.md#tooling).
|
||||
---
|
||||
|
||||
It must be noted that even if this repository's goal is to make deployment on Azure easy, you can use it on your own VM, see [Running without Azure](#running-without-azure).
|
||||
|
||||
---
|
||||
|
||||
# Deploy via Microsoft Azure Portal
|
||||
|
||||
Click on this button and follow instructions:
|
||||
|
||||
[](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fbtcpayserver%2Fbtcpayserver-azure%2Fmaster%2Fazuredeploy.json)
|
||||
|
||||
# Deploy with PowerShell
|
||||
|
||||
## Step 1: Download and install Azure PowerShell
|
||||
|
||||
You can do it by [using PowerShell command line](https://docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps?view=azurermps-5.0.0) or manually via [Web Platform Installer or MSI](https://docs.microsoft.com/en-us/powershell/azure/other-install?view=azurermps-5.0.0).
|
||||
|
||||
## Step 2: Authenticate to Azure
|
||||
|
||||
In PowerShell, you first need to authenticate to azure:
|
||||
|
||||
```
|
||||
# This will popup a windows to authenticate to azure
|
||||
Login-AzureRmAccount
|
||||
```
|
||||
|
||||
If you have multiple subscriptions, select the one you want:
|
||||
|
||||
```
|
||||
# List your subscriptions
|
||||
Get-AzureRmSubscription
|
||||
|
||||
# Select the one you want
|
||||
Get-AzureRmSubscription –SubscriptionId "your subscription" | Select-AzureRmSubscription
|
||||
```
|
||||
|
||||
## Step 3: Run the deployment
|
||||
|
||||
Create a new BTCPay Server instance:
|
||||
|
||||
```
|
||||
.\deployOnAzure.ps1 -ResourceGroupName "myawesomebtcpay" -Network "mainnet"
|
||||
```
|
||||
|
||||
Valid Network values are:
|
||||
|
||||
* mainnet
|
||||
* testnet
|
||||
* regtest
|
||||
|
||||
For ResourceGroupName, use only alphabetic lower case.
|
||||
|
||||
This might take around 5 minutes.
|
||||
|
||||
It will print you the DNS name of your server `myawesomebtcpay.southcentralus.cloudapp.azure.com`, you can browse to it to enjoy your BTCPay instance.
|
||||
|
||||
# Deploy on Linux
|
||||
|
||||
TODO: Write shell scripts using [Az tool](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/create-ssh-secured-vm-from-template), [other link](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-template-deploy-cli), [other link](https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/azure-resource-manager/resource-group-template-deploy-cli.md), [best link](http://markheath.net/post/deploying-arm-templates-azure-cli).
|
||||
|
||||
# How to change the domain name
|
||||
|
||||
By default, you will have a domain name assigned ending with `xxx.cloudapp.azure.com`. Because Let's Encrypt does not allow us to get HTTPS certificate for the `azure.com` domain, you need your own domain.
|
||||
|
||||
Then, add a CNAME record in your name server pointing to `xxx.cloudapp.azure.com`.
|
||||
|
||||
Connect then with SSH to your VM and run
|
||||
|
||||
```
|
||||
sudo su -
|
||||
changedomain.sh blah.example.com
|
||||
```
|
||||
|
||||
This will change the settings of BTCPay and NGinx to use your domain. Upon restart, a new certificate for your domain will be requested by Let's encrypt.
|
||||
|
||||
# How to update BTCPay
|
||||
|
||||
Just pull the latest changes of the docker-compose and restart the docker service.
|
||||
|
||||
```
|
||||
sudo su -
|
||||
btcpay-update.sh
|
||||
```
|
||||
|
||||
# How to restart BTCPay
|
||||
|
||||
Reboot docker:
|
||||
|
||||
```
|
||||
sudo su -
|
||||
btcpay-restart.sh
|
||||
```
|
||||
|
||||
Or reboot the server:
|
||||
|
||||
```
|
||||
sudo su -
|
||||
reboot
|
||||
```
|
||||
|
||||
# How to update the btcpay-* tools
|
||||
|
||||
```
|
||||
sudo su -
|
||||
cd $DOWNLOAD_ROOT
|
||||
if [ ! -d "btcpayserver-azure" ]; then
|
||||
git clone https://github.com/btcpayserver/btcpayserver-azure
|
||||
fi
|
||||
cd btcpayserver-azure
|
||||
git pull
|
||||
cp *.sh ..
|
||||
```
|
||||
|
||||
# Under the hood
|
||||
|
||||
Here are the step on provisioning done by Azure (so you can do it yourelf):
|
||||
|
||||
* Azure provision a new virtual machine
|
||||
* Then copy all the sh files of this repository inside the new virtual machine
|
||||
* Azure then execute `entrypoint.sh` passing the following arguments taken from the wizard:
|
||||
1. The initial DNS name
|
||||
2. The network (mainnet, testnet, regtest)
|
||||
3. Let's encrypt email
|
||||
4. Supported crypto currencies separated by '-'
|
||||
5. Docker repository url used for fetching the docker-compose
|
||||
6. The branch of this repository
|
||||
* `entrypoint.sh` does the following actions:
|
||||
1. Copy the parameters inside `/etc/environment` and `/etc/profile.d/btcpay-env.sh` so they can be accessed via environment variable globally
|
||||
2. Add also those parameters in the `.env` file which will be used by the `docker-compose`
|
||||
3. Install `docker-compose` and `git`
|
||||
4. Clone the `btcpayserver-docker` repository
|
||||
5. Configure upstart in `/etc/init/start_containers.conf` to start `docker-compose` if the machine reboot
|
||||
6. Start `docker-compose` in the directory of the `.env` as working directory
|
||||
7. Create symbolic links to `/usr/bin` to the other `btcpay-*.sh` utility scripts
|
||||
|
||||
Example of `/etc/environment`:
|
||||
|
||||
```
|
||||
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
|
||||
AZURE_DNS="dwoiqdwqb.westeurope.cloudapp.azure.com"
|
||||
BTCPAY_DOCKER_COMPOSE="/var/lib/waagent/custom-script/download/0/btcpayserver-docker/Production/docker-compose.btc-ltc.yml"
|
||||
BTCPAY_ENV_FILE="/var/lib/waagent/custom-script/download/0/.env"
|
||||
DOWNLOAD_ROOT="/var/lib/waagent/custom-script/download/0"
|
||||
```
|
||||
|
||||
Example of `/etc/profile.d/btcpay-env.sh`:
|
||||
|
||||
```
|
||||
export AZURE_DNS="dwoiqdwqb.westeurope.cloudapp.azure.com"
|
||||
export BTCPAY_DOCKER_COMPOSE="/var/lib/waagent/custom-script/download/0/btcpayserver-docker/Production/docker-compose.btc-ltc.yml"
|
||||
export DOWNLOAD_ROOT="/var/lib/waagent/custom-script/download/0"
|
||||
export BTCPAY_ENV_FILE="/var/lib/waagent/custom-script/download/0/.env"
|
||||
```
|
||||
|
||||
Example of `.env` file:
|
||||
|
||||
```
|
||||
BTCPAY_HOST=test-btc-ltc.forkbitpay.ninja
|
||||
ACME_CA_URI=https://acme-v01.api.letsencrypt.org/directory
|
||||
NBITCOIN_NETWORK=testnet
|
||||
LETSENCRYPT_EMAIL=me@example.com
|
||||
```
|
||||
|
||||
Example of `/etc/init/start_containers.conf` file:
|
||||
|
||||
```
|
||||
# File is saved under /etc/init/start_containers.conf
|
||||
# After file is modified, update config with : $ initctl reload-configuration
|
||||
|
||||
description "Start containers (see http://askubuntu.com/a/22105 and http://askubuntu.com/questions/612928/how-to-run-docker-compose-at-bootup)"
|
||||
|
||||
start on filesystem and started docker
|
||||
stop on runlevel [!2345]
|
||||
|
||||
# if you want it to automatically restart if it crashes, leave the next line in
|
||||
# respawn # might cause over charge
|
||||
|
||||
script
|
||||
. /etc/profile.d/btcpay-env.sh
|
||||
cd "`dirname $BTCPAY_ENV_FILE`"
|
||||
docker-compose -f "$BTCPAY_DOCKER_COMPOSE" up -d
|
||||
end script
|
||||
```
|
||||
|
||||
Note that `AZURE_DNS` is not really used anywhere except for debugging purpose.
|
||||
When you want to start/stop docker, for the environment variables in `.env` to be taken into account, you need to start from its folder:
|
||||
|
||||
```
|
||||
cd "`dirname $BTCPAY_ENV_FILE`"
|
||||
docker-compose -f "$BTCPAY_DOCKER_COMPOSE" up
|
||||
```
|
||||
|
||||
# Running without Azure <a name="running-without-azure" />
|
||||
|
||||
You can run `entrypoint.sh` without Azure, on your own Linux machine:
|
||||
|
||||
1. Make sure your VM has enough RAM (3GB at least for BTC only, 4GB for BTC+LTC)
|
||||
2. Configure your DNS record (eg. btcpay.example.com)
|
||||
3. Make sure it point to this VM (A record or CNAME record)
|
||||
4. Make sure port 80 and 443 are open
|
||||
5. Run the following script
|
||||
|
||||
```
|
||||
# Configure your DNS record (eg. btcpay.example.com)
|
||||
# Make sure it point to this VM and that port 80 and 443 are open
|
||||
|
||||
# Clone the repository
|
||||
git clone https://github.com/btcpayserver/btcpayserver-azure/
|
||||
|
||||
# Enter into this folder
|
||||
cd btcpayserver-azure
|
||||
|
||||
export AZURE_DNS=btcpay.example.com
|
||||
export NBITCOIN_NETWORK=mainnet
|
||||
export LETSENCRYPT_EMAIL=admin@example.com
|
||||
export BTCPAY_DOCKER_REPO=https://github.com/btcpayserver/btcpayserver-docker/
|
||||
export BTCPAY_DOCKER_REPO_BRANCH=master
|
||||
export LIGHTNING_ALIAS="my-node"
|
||||
export USE_BTC=True
|
||||
export USE_LTC=True
|
||||
export USE_CLIGHTNING=True
|
||||
export ACME_CA_URI=https://acme-v01.api.letsencrypt.org/directory
|
||||
. ./entrypoint.sh
|
||||
```
|
||||
|
||||
You can then browse https://btcpay.example.com/ and enjoy your new node and all commands documented here (like `btcpay-update.sh`) and on the [btcpay-docker](https://github.com/btcpayserver/btcpayserver-docker) repository.
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if ! [ -x "$(command -v git)" ]; then
|
||||
apt-get update 2>error
|
||||
apt-get install -y git 2>error
|
||||
fi
|
||||
|
||||
: "${BTCPAY_HOST:=$1}"
|
||||
: "${NBITCOIN_NETWORK:=$2}"
|
||||
: "${LETSENCRYPT_EMAIL:=$3}"
|
||||
: "${BTCPAY_DOCKER_REPO:=$4}"
|
||||
: "${BTCPAY_DOCKER_REPO_BRANCH:=$5}"
|
||||
: "${LIGHTNING_ALIAS:=$6}"
|
||||
: "${BTCPAYGEN_CRYPTO1:=$7}"
|
||||
: "${BTCPAYGEN_CRYPTO2:=$8}"
|
||||
: "${BTCPAYGEN_CRYPTO3:=$9}"
|
||||
: "${BTCPAYGEN_CRYPTO4:=${10}}"
|
||||
: "${BTCPAYGEN_CRYPTO5:=${11}}"
|
||||
: "${BTCPAYGEN_CRYPTO6:=${12}}"
|
||||
: "${BTCPAYGEN_CRYPTO7:=${13}}"
|
||||
: "${BTCPAYGEN_CRYPTO8:=${14}}"
|
||||
: "${BTCPAYGEN_CRYPTO9:=${15}}"
|
||||
: "${BTCPAYGEN_LIGHTNING:=${16}}"
|
||||
: "${BTCPAYGEN_REVERSEPROXY:=nginx}"
|
||||
|
||||
CUSTOM_SSH_KEY="${17}"
|
||||
BTCPAYGEN_ADDITIONAL_FRAGMENTS="opt-save-storage"
|
||||
|
||||
if [[ "$CUSTOM_SSH_KEY" ]]; then
|
||||
echo "" >> /root/.ssh/authorized_keys
|
||||
echo "# User key" >> /root/.ssh/authorized_keys
|
||||
echo "$CUSTOM_SSH_KEY" >> /root/.ssh/authorized_keys
|
||||
echo "Custom SSH Key added to /root/.ssh/authorized_keys"
|
||||
fi
|
||||
sed -i -e '/^PasswordAuthentication / s/ .*/ no/' /etc/ssh/sshd_config
|
||||
userdel -r -f temp
|
||||
|
||||
cd /root
|
||||
# Configure BTCPAY to have access to SSH
|
||||
BTCPAY_ENABLE_SSH=true
|
||||
|
||||
# Clone btcpayserver-docker
|
||||
git clone $BTCPAY_DOCKER_REPO
|
||||
cd btcpayserver-docker
|
||||
git checkout $BTCPAY_DOCKER_REPO_BRANCH
|
||||
|
||||
. ./btcpay-setup.sh -i
|
||||
|
||||
[ -x "$(command -v /etc/init.d/sshd)" ] && nohup /etc/init.d/sshd restart &
|
||||
[ -x "$(command -v /etc/init.d/ssh)" ] && nohup /etc/init.d/ssh restart &
|
||||
237
azuredeploy.json
237
azuredeploy.json
@ -1,17 +1,23 @@
|
||||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.1.0.0",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"sshKey": {
|
||||
"adminUsername": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"defaultValue": "btcpayserver",
|
||||
"metadata": {
|
||||
"description": "SSH Key which will be granted access to the VM (optional)"
|
||||
"description": "The name of the SSH user."
|
||||
}
|
||||
},
|
||||
"adminPassword": {
|
||||
"type": "securestring",
|
||||
"metadata": {
|
||||
"description": "The name of the SSH password."
|
||||
}
|
||||
},
|
||||
"notificationEmail": {
|
||||
"type": "string",
|
||||
"defaultValue": "me@example.com",
|
||||
"defaultValue": "yourname@example.com",
|
||||
"metadata": {
|
||||
"description": "Email used by Let's encrypt to notify you about certificate expiration (optional)"
|
||||
}
|
||||
@ -32,190 +38,28 @@
|
||||
],
|
||||
"defaultValue": "mainnet",
|
||||
"metadata": {
|
||||
"description": "Choose mainnet for production, or testnet for testing"
|
||||
"description": "Choose nainnet for production, or testnet for testing"
|
||||
}
|
||||
},
|
||||
"supportedCrypto1": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"",
|
||||
"btc",
|
||||
"ltc",
|
||||
"dash",
|
||||
"grs",
|
||||
"btg",
|
||||
"ftc",
|
||||
"via",
|
||||
"doge",
|
||||
"mona"
|
||||
],
|
||||
"defaultValue": "btc",
|
||||
"acceptBTC": {
|
||||
"type": "bool",
|
||||
"defaultValue": true,
|
||||
"metadata": {
|
||||
"description": "Choose a crypto currency to support"
|
||||
"description": "Accept Bitcoin"
|
||||
}
|
||||
},
|
||||
"supportedCrypto2": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"",
|
||||
"btc",
|
||||
"ltc",
|
||||
"dash",
|
||||
"grs",
|
||||
"btg",
|
||||
"ftc",
|
||||
"via",
|
||||
"doge",
|
||||
"mona"
|
||||
],
|
||||
"defaultValue": "",
|
||||
"acceptLTC": {
|
||||
"type": "bool",
|
||||
"defaultValue": false,
|
||||
"metadata": {
|
||||
"description": "Choose a second crypto currency to support"
|
||||
"description": "Accept Litecoin"
|
||||
}
|
||||
},
|
||||
"supportedCrypto3": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"",
|
||||
"btc",
|
||||
"ltc",
|
||||
"dash",
|
||||
"grs",
|
||||
"btg",
|
||||
"ftc",
|
||||
"via",
|
||||
"doge",
|
||||
"mona"
|
||||
],
|
||||
"defaultValue": "",
|
||||
"internalCLightning": {
|
||||
"type": "bool",
|
||||
"defaultValue": false,
|
||||
"metadata": {
|
||||
"description": "Choose a third crypto currency to support"
|
||||
}
|
||||
},
|
||||
"supportedCrypto4": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"",
|
||||
"btc",
|
||||
"ltc",
|
||||
"dash",
|
||||
"grs",
|
||||
"btg",
|
||||
"ftc",
|
||||
"via",
|
||||
"doge",
|
||||
"mona"
|
||||
],
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Choose a fourth crypto currency to support"
|
||||
}
|
||||
},
|
||||
"supportedCrypto5": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"",
|
||||
"btc",
|
||||
"ltc",
|
||||
"dash",
|
||||
"grs",
|
||||
"btg",
|
||||
"ftc",
|
||||
"via",
|
||||
"doge",
|
||||
"mona"
|
||||
],
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Choose a fifth crypto currency to support"
|
||||
}
|
||||
},
|
||||
"supportedCrypto6": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"",
|
||||
"btc",
|
||||
"ltc",
|
||||
"dash",
|
||||
"grs",
|
||||
"btg",
|
||||
"ftc",
|
||||
"via",
|
||||
"doge",
|
||||
"mona"
|
||||
],
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Choose a sixth crypto currency to support"
|
||||
}
|
||||
},
|
||||
"supportedCrypto7": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"",
|
||||
"btc",
|
||||
"ltc",
|
||||
"dash",
|
||||
"grs",
|
||||
"btg",
|
||||
"ftc",
|
||||
"via",
|
||||
"doge",
|
||||
"mona"
|
||||
],
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Choose a seventh crypto currency to support"
|
||||
}
|
||||
},
|
||||
"supportedCrypto8": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"",
|
||||
"btc",
|
||||
"ltc",
|
||||
"dash",
|
||||
"grs",
|
||||
"btg",
|
||||
"ftc",
|
||||
"via",
|
||||
"doge",
|
||||
"mona"
|
||||
],
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Choose a eigth crypto currency to support"
|
||||
}
|
||||
},
|
||||
"supportedCrypto9": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"",
|
||||
"btc",
|
||||
"ltc",
|
||||
"dash",
|
||||
"grs",
|
||||
"btg",
|
||||
"ftc",
|
||||
"via",
|
||||
"doge",
|
||||
"mona"
|
||||
],
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Choose a nineth crypto currency to support"
|
||||
}
|
||||
},
|
||||
"lightningNetworkImplementation": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"",
|
||||
"clightning",
|
||||
"lnd"
|
||||
],
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Choose a lightning network implementation"
|
||||
"description": "Support internal clightning node (beta)"
|
||||
}
|
||||
},
|
||||
"lightningNodeAlias": {
|
||||
@ -227,14 +71,14 @@
|
||||
},
|
||||
"ubuntuOSVersion": {
|
||||
"type": "string",
|
||||
"defaultValue": "16.04.0-LTS",
|
||||
"defaultValue": "14.04.4-LTS",
|
||||
"metadata": {
|
||||
"description": "The Ubuntu version for deploying the Docker containers. This will pick a fully patched image of this given Ubuntu version. Allowed values: 14.04.4-LTS, 15.10, 16.04.0-LTS"
|
||||
},
|
||||
"allowedValues": [
|
||||
"14.04.4-LTS",
|
||||
"16.04.0-LTS",
|
||||
"18.04-LTS"
|
||||
"15.10",
|
||||
"16.04.0-LTS"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
@ -246,7 +90,7 @@
|
||||
},
|
||||
"branch": {
|
||||
"type": "string",
|
||||
"defaultValue": "master",
|
||||
"defaultValue": "stable",
|
||||
"metadata": {
|
||||
"description": "The branch from the GIT repository to use"
|
||||
}
|
||||
@ -441,8 +285,8 @@
|
||||
},
|
||||
"osProfile": {
|
||||
"computerName": "[variables('vmName')]",
|
||||
"adminUsername": "temp",
|
||||
"adminPassword": "[concat(uniqueString(resourceGroup().id), 'aA5@')]"
|
||||
"adminUsername": "[parameters('adminUsername')]",
|
||||
"adminPassword": "[parameters('adminPassword')]"
|
||||
},
|
||||
"storageProfile": {
|
||||
"imageReference": {
|
||||
@ -485,20 +329,27 @@
|
||||
"autoUpgradeMinorVersion": true,
|
||||
"settings":
|
||||
{
|
||||
"fileUris" : ["https://raw.githubusercontent.com/btcpayserver/btcpayserver-azure/master/azure-entrypoint.sh"],
|
||||
"commandToExecute" : "[concat('./azure-entrypoint.sh ', reference(concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName')), '2016-03-30').dnsSettings.fqdn, ' \"', parameters('network'), '\" \"', parameters('notificationEmail'), '\" \"', parameters('repository'), '\" \"', parameters('branch'), '\" \"', parameters('lightningNodeAlias'), '\" \"', parameters('supportedCrypto1'), '\" \"', parameters('supportedCrypto2'), '\" \"', parameters('supportedCrypto3'), '\" \"', parameters('supportedCrypto4'), '\" \"', parameters('supportedCrypto5'), '\" \"', parameters('supportedCrypto6'), '\" \"', parameters('supportedCrypto7'), '\" \"', parameters('supportedCrypto8'), '\" \"', parameters('supportedCrypto9'), '\" \"', parameters('lightningNetworkImplementation'), '\" \"', parameters('sshKey'),'\"')]"
|
||||
"fileUris" : ["https://raw.githubusercontent.com/btcpayserver/btcpayserver-azure/systemd/entrypoint.sh",
|
||||
"https://raw.githubusercontent.com/btcpayserver/btcpayserver-azure/systemd/changedomain.sh",
|
||||
"https://raw.githubusercontent.com/btcpayserver/btcpayserver-azure/systemd/btcpay-restart.sh",
|
||||
"https://raw.githubusercontent.com/btcpayserver/btcpayserver-azure/systemd/btcpay-update.sh"],
|
||||
"commandToExecute" : "[concat('./entrypoint.sh ', reference(concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName')), '2016-03-30').dnsSettings.fqdn, ' ', parameters('network'), ' ', parameters('notificationEmail'), ' ', parameters('repository'), ' ', parameters('branch'), ' \"', parameters('lightningNodeAlias'), '\" ', parameters('acceptBTC'), ' ', parameters('acceptLTC'), ' ', parameters('internalCLightning'))]"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
"ssh-username" : {
|
||||
"type": "string",
|
||||
"value": "[parameters('adminUsername')]"
|
||||
},
|
||||
"server-azure-dns" : {
|
||||
"type": "string",
|
||||
"value": "[reference(concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName')), '2016-03-30').dnsSettings.fqdn]"
|
||||
},
|
||||
"ssh-commandline" : {
|
||||
"type": "string",
|
||||
"value": "[concat('ssh', ' root@', reference(concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName')), '2016-03-30').dnsSettings.fqdn)]"
|
||||
},
|
||||
"ssh-help" : {
|
||||
"type": "string",
|
||||
"value": "If you did not set a SSH Key, please connect to your BTCPay instance, register the administration account and go to Server Settings / Services / SSH to get more information"
|
||||
"value": "[concat('ssh', ' ', parameters('adminUsername'), '@', reference(concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName')), '2016-03-30').dnsSettings.fqdn)]"
|
||||
},
|
||||
"server-url" : {
|
||||
"type": "string",
|
||||
|
||||
3
btcpay-restart.sh
Executable file
3
btcpay-restart.sh
Executable file
@ -0,0 +1,3 @@
|
||||
cd "`dirname $BTCPAY_ENV_FILE`"
|
||||
docker-compose -f $BTCPAY_DOCKER_COMPOSE down
|
||||
docker-compose -f $BTCPAY_DOCKER_COMPOSE up -d
|
||||
8
btcpay-update.sh
Executable file
8
btcpay-update.sh
Executable file
@ -0,0 +1,8 @@
|
||||
cd "`dirname $BTCPAY_DOCKER_COMPOSE`"
|
||||
git pull --force
|
||||
cd "`dirname $BTCPAY_ENV_FILE`"
|
||||
docker-compose -f $BTCPAY_DOCKER_COMPOSE up -d
|
||||
|
||||
cd btcpayserver-docker
|
||||
find `pwd` -name "*.sh" -exec chmod +x {} \; 2>/dev/null
|
||||
find `pwd` -name "*.sh" -exec ln -s {} /usr/bin \; 2>/dev/null
|
||||
16
changedomain.sh
Executable file
16
changedomain.sh
Executable file
@ -0,0 +1,16 @@
|
||||
|
||||
export NEW_HOST="$1"
|
||||
export OLD_HOST=`cat $BTCPAY_ENV_FILE | sed -n 's/^BTCPAY_HOST=\(.*\)$/\1/p'`
|
||||
echo "Changing domain from \"$OLD_HOST\" to \"$NEW_HOST\""
|
||||
|
||||
export BTCPAY_HOST="$NEW_HOST"
|
||||
export ACME_CA_URI="https://acme-v01.api.letsencrypt.org/directory"
|
||||
|
||||
# Modify environment file
|
||||
sed -i '/^BTCPAY_HOST/d' $BTCPAY_ENV_FILE
|
||||
sed -i '/^ACME_CA_URI/d' $BTCPAY_ENV_FILE
|
||||
echo "BTCPAY_HOST=$BTCPAY_HOST" >> $BTCPAY_ENV_FILE
|
||||
echo "ACME_CA_URI=$ACME_CA_URI" >> $BTCPAY_ENV_FILE
|
||||
|
||||
cd "`dirname $BTCPAY_ENV_FILE`"
|
||||
docker-compose -f "$BTCPAY_DOCKER_COMPOSE" up -d
|
||||
40
deployOnAzure.ps1
Normal file
40
deployOnAzure.ps1
Normal file
@ -0,0 +1,40 @@
|
||||
# This
|
||||
# Assume your ran logged to azure with
|
||||
# Login-AzureRmAccount
|
||||
# Then you selected your subscript with
|
||||
# Get-AzureRmSubscription –SubscriptionName "your subscription" | Select-AzureRmSubscription
|
||||
param([String]$ResourceGroupName, [String]$Network)
|
||||
|
||||
$rg = $ResourceGroupName
|
||||
|
||||
$usr = ([char[]]([char]'a'..[char]'z') + ([char[]]([char]'A'..[char]'Z')) + 0..9 | Sort-Object {Get-Random})[0..8] -join ''
|
||||
$pass = ([char[]]([char]'a'..[char]'z') + ([char[]]([char]'A'..[char]'Z')) + 0..9 | Sort-Object {Get-Random})[0..16] -join ''
|
||||
$pass = $pass + 'aB1' # So we satisfy 100% sure the password requirements
|
||||
|
||||
$parameters = `
|
||||
@{"adminUsername" = $usr;`
|
||||
"adminPassword" = $pass;`
|
||||
"network" = $Network;
|
||||
}
|
||||
|
||||
New-AzureRmResourceGroup -Name $rg -Location "South Central US"
|
||||
New-AzureRmResourceGroupDeployment -ResourceGroupName $rg -TemplateFile "azuredeploy.json" -TemplateParameterObject $parameters
|
||||
|
||||
|
||||
$site = (Get-AzureRmPublicIpAddress -ResourceGroupName $rg).DnsSettings.Fqdn
|
||||
|
||||
$cmd = "ssh $usr@$site"
|
||||
|
||||
$temp += "BTCPay server on Network: $Network`n"
|
||||
$temp = "Username: $usr`n"
|
||||
$temp += "Password: $pass`n"
|
||||
$temp += "Machine address: $site`n"
|
||||
$temp += "Command line: $cmd`n`n"
|
||||
|
||||
$temp += "Your BTCPay server instance will be available shortly on: https://$site/ with a staging certificate from Let's Encrypt!`n"
|
||||
$temp += "Your next steps are:`n"
|
||||
$temp += "`t1. Add the following DNS record to your domain server: `"your-domain.com. CNAME $site.`"`n"
|
||||
$temp += "`t2. Connect via SSH to this virtual machine, and run `". ./changedomain your-domain.com`"`n"
|
||||
$temp += "You will then have a fully HTTPS configured access to your own BTCPay Server instance"
|
||||
|
||||
Write-Host $temp
|
||||
180
entrypoint.sh
Executable file
180
entrypoint.sh
Executable file
@ -0,0 +1,180 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
: "${AZURE_DNS:=$1}"
|
||||
: "${NBITCOIN_NETWORK:=$2}"
|
||||
: "${LETSENCRYPT_EMAIL:=$3}"
|
||||
: "${BTCPAY_DOCKER_REPO:=$4}"
|
||||
: "${BTCPAY_DOCKER_REPO_BRANCH:=$5}"
|
||||
: "${LIGHTNING_ALIAS:=$6}"
|
||||
: "${USE_BTC:=$7}"
|
||||
: "${USE_LTC:=$8}"
|
||||
: "${USE_CLIGHTNING:=$9}"
|
||||
: "${ACME_CA_URI:=https://acme-staging.api.letsencrypt.org/directory}"
|
||||
|
||||
DOWNLOAD_ROOT="`pwd`"
|
||||
|
||||
echo "
|
||||
-------SETUP-----------
|
||||
Parameters passed:
|
||||
AZURE_DNS:$AZURE_DNS
|
||||
NBITCOIN_NETWORK:$NBITCOIN_NETWORK
|
||||
LETSENCRYPT_EMAIL:$LETSENCRYPT_EMAIL
|
||||
BTCPAY_DOCKER_REPO:$BTCPAY_DOCKER_REPO
|
||||
BTCPAY_DOCKER_REPO_BRANCH:$BTCPAY_DOCKER_REPO_BRANCH
|
||||
LIGHTNING_ALIAS:$LIGHTNING_ALIAS
|
||||
USE_BTC:$USE_BTC
|
||||
USE_LTC:$USE_LTC
|
||||
USE_CLIGHTNING:$USE_CLIGHTNING
|
||||
----------------------
|
||||
ACME_CA_URI:$ACME_CA_URI
|
||||
DOWNLOAD_ROOT:$DOWNLOAD_ROOT
|
||||
----------------------
|
||||
"
|
||||
|
||||
BTCPAY_ENV_FILE="`pwd`/.env"
|
||||
SUPPORTED_CRYPTO_CURRENCIES=""
|
||||
|
||||
if [ "$USE_BTC" == "True" ]; then
|
||||
SUPPORTED_CRYPTO_CURRENCIES="$SUPPORTED_CRYPTO_CURRENCIES-btc"
|
||||
fi
|
||||
|
||||
if [ "$USE_LTC" == "True" ]; then
|
||||
SUPPORTED_CRYPTO_CURRENCIES="$SUPPORTED_CRYPTO_CURRENCIES-ltc"
|
||||
fi
|
||||
|
||||
if [ "$SUPPORTED_CRYPTO_CURRENCIES" == "" ]; then
|
||||
SUPPORTED_CRYPTO_CURRENCIES="-btc"
|
||||
fi
|
||||
|
||||
if [ "$USE_CLIGHTNING" == "True" ]; then
|
||||
SUPPORTED_CRYPTO_CURRENCIES="$SUPPORTED_CRYPTO_CURRENCIES-clightning"
|
||||
fi
|
||||
|
||||
# Remove superflous -
|
||||
SUPPORTED_CRYPTO_CURRENCIES=`echo $SUPPORTED_CRYPTO_CURRENCIES | sed 's/^-\(.*\)/\1/'`
|
||||
|
||||
BTCPAY_HOST="$AZURE_DNS"
|
||||
BTCPAY_DOCKER_COMPOSE="`pwd`/btcpayserver-docker/Production/docker-compose.$SUPPORTED_CRYPTO_CURRENCIES.yml"
|
||||
|
||||
export AZURE_DNS
|
||||
export BTCPAY_DOCKER_COMPOSE
|
||||
export DOWNLOAD_ROOT
|
||||
export BTCPAY_ENV_FILE
|
||||
|
||||
# Put the variable in /etc/environment for reboot
|
||||
cp /etc/environment /etc/environment.bak
|
||||
echo "
|
||||
AZURE_DNS=\"$AZURE_DNS\"
|
||||
BTCPAY_DOCKER_COMPOSE=\"$BTCPAY_DOCKER_COMPOSE\"
|
||||
DOWNLOAD_ROOT=\"$DOWNLOAD_ROOT\"
|
||||
BTCPAY_ENV_FILE=\"$BTCPAY_ENV_FILE\"" >> /etc/environment
|
||||
|
||||
|
||||
# Put the variable in /etc/profile.d when a user log interactively
|
||||
touch "/etc/profile.d/btcpay-env.sh"
|
||||
echo "
|
||||
export AZURE_DNS=\"$AZURE_DNS\"
|
||||
export BTCPAY_DOCKER_COMPOSE=\"$BTCPAY_DOCKER_COMPOSE\"
|
||||
export DOWNLOAD_ROOT=\"$DOWNLOAD_ROOT\"
|
||||
export BTCPAY_ENV_FILE=\"$BTCPAY_ENV_FILE\"" > /etc/profile.d/btcpay-env.sh
|
||||
|
||||
chmod +x /etc/profile.d/btcpay-env.sh
|
||||
|
||||
# Install docker (https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#set-up-the-repository) and docker-compose
|
||||
apt-get update 2>error
|
||||
apt-get install -y \
|
||||
git \
|
||||
curl \
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
software-properties-common \
|
||||
2>error
|
||||
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
|
||||
|
||||
add-apt-repository \
|
||||
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
|
||||
$(lsb_release -cs) \
|
||||
stable"
|
||||
|
||||
apt-get update
|
||||
apt-get install -y docker-ce
|
||||
|
||||
# Install docker-compose
|
||||
curl -L https://github.com/docker/compose/releases/download/1.17.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
|
||||
chmod +x /usr/local/bin/docker-compose
|
||||
|
||||
# Clone btcpayserver-docker
|
||||
git clone $BTCPAY_DOCKER_REPO
|
||||
cd btcpayserver-docker
|
||||
git checkout $BTCPAY_DOCKER_REPO_BRANCH
|
||||
cd ..
|
||||
|
||||
# Set .env file
|
||||
touch $BTCPAY_ENV_FILE
|
||||
echo "
|
||||
BTCPAY_HOST=$BTCPAY_HOST
|
||||
ACME_CA_URI=$ACME_CA_URI
|
||||
NBITCOIN_NETWORK=$NBITCOIN_NETWORK
|
||||
LETSENCRYPT_EMAIL=$LETSENCRYPT_EMAIL
|
||||
LIGHTNING_ALIAS=$LIGHTNING_ALIAS" > $BTCPAY_ENV_FILE
|
||||
|
||||
# Schedule for reboot
|
||||
if [ -d "/etc/systemd/system" ]; then # Use systemd
|
||||
|
||||
echo "Adding btcpayserver.service to systemd"
|
||||
echo "
|
||||
[Unit]
|
||||
Description=BTCPayServer service
|
||||
After=docker.service network-online.target
|
||||
Requires=docker.service network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
|
||||
ExecStart=/bin/bash -c '. /etc/profile.d/btcpay-env.sh && cd \"\$(dirname \$BTCPAY_ENV_FILE)\" && docker-compose -f \"\$BTCPAY_DOCKER_COMPOSE\" up -d'
|
||||
ExecStop=/bin/bash -c '. /etc/profile.d/btcpay-env.sh && cd \"\$(dirname \$BTCPAY_ENV_FILE)\" && docker-compose -f \"\$BTCPAY_DOCKER_COMPOSE\" stop'
|
||||
ExecReload=/bin/bash -c '. /etc/profile.d/btcpay-env.sh && cd \"\$(dirname \$BTCPAY_ENV_FILE)\" && docker-compose -f \"\$BTCPAY_DOCKER_COMPOSE\" restart'
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target" > /etc/systemd/system/btcpayserver.service
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable btcpayserver
|
||||
systemctl start btcpayserver
|
||||
|
||||
else # Use upstart
|
||||
echo "Using upstart"
|
||||
echo "
|
||||
# File is saved under /etc/init/start_containers.conf
|
||||
# After file is modified, update config with : $ initctl reload-configuration
|
||||
|
||||
description \"Start containers (see http://askubuntu.com/a/22105 and http://askubuntu.com/questions/612928/how-to-run-docker-compose-at-bootup)\"
|
||||
|
||||
start on filesystem and started docker
|
||||
stop on runlevel [!2345]
|
||||
|
||||
# if you want it to automatically restart if it crashes, leave the next line in
|
||||
# respawn # might cause over charge
|
||||
|
||||
script
|
||||
. /etc/profile.d/btcpay-env.sh
|
||||
cd \"`dirname \$BTCPAY_ENV_FILE`\"
|
||||
docker-compose -f \"\$BTCPAY_DOCKER_COMPOSE\" up -d
|
||||
end script" > /etc/init/start_containers.conf
|
||||
initctl reload-configuration
|
||||
docker-compose -f "$BTCPAY_DOCKER_COMPOSE" up -d
|
||||
fi
|
||||
|
||||
cd "`dirname $BTCPAY_ENV_FILE`"
|
||||
|
||||
find `pwd` -name "*.sh" -exec chmod +x {} \;
|
||||
find `pwd` -name "*.sh" -exec ln -s {} /usr/bin \;
|
||||
find `pwd`/btcpayserver-docker -name "*.sh" -exec chmod +x {} \;
|
||||
find `pwd`/btcpayserver-docker -name "*.sh" -exec ln -s {} /usr/bin \;
|
||||
Loading…
Reference in New Issue
Block a user