2 Commits

Author SHA1 Message Date
570a692bb2 Configure and run nbxplorer 2020-12-21 12:19:30 +01:00
5277bce20b Formatting 2020-12-21 11:14:19 +01:00
4 changed files with 64 additions and 6 deletions

View File

@@ -35,6 +35,8 @@ node.default['dotnet']['ms_packages_src_checksum'] = "4df5811c41fdded83eb9e2da93
node.default['nbxplorer']['repo'] = 'https://github.com/dgarage/NBXplorer'
node.default['nbxplorer']['revision'] = 'latest'
node.default['nbxplorer']['source_dir'] = '/opt/nbxplorer'
node.default['nbxplorer']['config_path'] = "/home/#{node['bitcoin']['username']}/.nbxplorer/Main/settings.config"
node.default['nbxplorer']['port'] = '24445'
node.default['btcpay']['repo'] = 'https://github.com/btcpayserver/btcpayserver'
node.default['btcpay']['revision'] = 'latest'

View File

@@ -16,8 +16,6 @@ end
bash 'build_nbxplorer' do
cwd node['nbxplorer']['source_dir']
code <<-EOH
./build.sh
EOH
code './build.sh'
action :nothing
end

View File

@@ -16,8 +16,61 @@ end
bash 'build_btcpay' do
cwd node['btcpay']['source_dir']
code <<-EOH
./build.sh
EOH
code './build.sh'
action :nothing
end
bitcoin_credentials = Chef::EncryptedDataBagItem.load('credentials', 'bitcoin')
directory File.dirname(node['nbxplorer']['config_path']) do
owner node['bitcoin']['username']
group node['bitcoin']['usergroup']
mode '0750'
recursive true
end
template node['nbxplorer']['config_path'] do
source "nbxplorer-settings.config.erb"
owner node['bitcoin']['username']
group node['bitcoin']['usergroup']
mode '0640'
variables bitcoin_rpc_user: node['bitcoin']['conf']['rpcuser'],
bitcoin_rpc_password: bitcoin_credentials["rpcpassword"],
bitcoin_rpc_url: "http://#{node['bitcoin']['conf']['rpcbind']}",
nbxplorer_port: node['nbxplorer']['port']
end
directory '/run/nbxplorer' do
owner node['bitcoin']['username']
group node['bitcoin']['usergroup']
mode '0640'
end
systemd_unit 'nbxplorer.service' do
content({
Unit: {
Description: 'NBXplorer daemon',
Documentation: ['https://github.com/dgarage/NBXplorer'],
Requires: 'bitcoind.service',
After: 'bitcoind.service'
},
Service: {
User: node['bitcoin']['username'],
Group: node['bitcoin']['usergroup'],
Type: 'simple',
ExecStart: "/usr/bin/dotnet '#{node['nbxplorer']['source_dir']}/NBXplorer/bin/Release/netcoreapp3.1/NBXplorer.dll' -c #{node['nbxplorer']['config_path']}",
PIDFile: "/run/nbxplorer/nbxplorer.pid",
Restart: 'on-failure',
PrivateTmp: true,
ProtectSystem: 'full',
NoNewPrivileges: true,
PrivateDevices: true
},
Install: {
WantedBy: 'multi-user.target'
}
})
verify false
triggers_reload true
action [:create, :enable, :start]
end

View File

@@ -0,0 +1,5 @@
btc.rpc.auth=<%= @bitcoin_rpc_user %>:<%= @bitcoin_rpc_password %>
btc.rpc.url=<%= @bitcoin_rpc_url %>
btc.node.endpoint=127.0.0.1:8333
port=<%= @nbxplorer_port %>
mainnet=1