Bitcoin source recipe
This commit is contained in:
parent
4606773440
commit
9795e77fde
10
data_bags/credentials/bitcoin.json
Normal file
10
data_bags/credentials/bitcoin.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"id": "bitcoin",
|
||||||
|
"rpcpassword": {
|
||||||
|
"encrypted_data": "dBXJXEYJIoWzo+TPg8CzaKfTo94SdowFDdQKVL/njQ==\n",
|
||||||
|
"iv": "UNragm2xuewXZu0v\n",
|
||||||
|
"auth_tag": "tfjO8qfvti3k5L3Ms2jPLw==\n",
|
||||||
|
"version": 3,
|
||||||
|
"cipher": "aes-256-gcm"
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@
|
|||||||
"automatic": {
|
"automatic": {
|
||||||
"fqdn": "draco.kosmos.org",
|
"fqdn": "draco.kosmos.org",
|
||||||
"os": "linux",
|
"os": "linux",
|
||||||
"os_version": "5.4.0-37-generic",
|
"os_version": "5.4.0-42-generic",
|
||||||
"hostname": "draco",
|
"hostname": "draco",
|
||||||
"ipaddress": "148.251.237.73",
|
"ipaddress": "148.251.237.73",
|
||||||
"roles": [
|
"roles": [
|
||||||
@ -20,6 +20,7 @@
|
|||||||
"kosmos_encfs",
|
"kosmos_encfs",
|
||||||
"kosmos_encfs::default",
|
"kosmos_encfs::default",
|
||||||
"kosmos-postgresql::replica",
|
"kosmos-postgresql::replica",
|
||||||
|
"kosmos-bitcoin::source",
|
||||||
"apt::default",
|
"apt::default",
|
||||||
"timezone_iii::default",
|
"timezone_iii::default",
|
||||||
"timezone_iii::debian",
|
"timezone_iii::debian",
|
||||||
@ -35,6 +36,7 @@
|
|||||||
"hostname::default",
|
"hostname::default",
|
||||||
"firewall::default",
|
"firewall::default",
|
||||||
"chef-sugar::default",
|
"chef-sugar::default",
|
||||||
|
"ark::default",
|
||||||
"build-essential::default"
|
"build-essential::default"
|
||||||
],
|
],
|
||||||
"platform": "ubuntu",
|
"platform": "ubuntu",
|
||||||
@ -54,6 +56,7 @@
|
|||||||
"run_list": [
|
"run_list": [
|
||||||
"recipe[kosmos-base]",
|
"recipe[kosmos-base]",
|
||||||
"recipe[kosmos_encfs]",
|
"recipe[kosmos_encfs]",
|
||||||
"role[postgresql_replica]"
|
"role[postgresql_replica]",
|
||||||
|
"recipe[kosmos-bitcoin::source]"
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1,7 +1,9 @@
|
|||||||
|
node.default['bitcoin']['version'] = '0.20.1'
|
||||||
|
node.default['bitcoin']['checksum'] = '4bbd62fd6acfa5e9864ebf37a24a04bc2dcfe3e3222f056056288d854c53b978'
|
||||||
node.default['bitcoin']['username'] = 'satoshi'
|
node.default['bitcoin']['username'] = 'satoshi'
|
||||||
node.default['bitcoin']['usergroup'] = 'satoshi'
|
node.default['bitcoin']['usergroup'] = 'bitcoin'
|
||||||
node.default['bitcoin']['datadir'] = '/mnt/data/bitcoin'
|
|
||||||
node.default['bitcoin']['network'] = 'mainnet'
|
node.default['bitcoin']['network'] = 'mainnet'
|
||||||
|
node.default['bitcoin']['datadir'] = '/mnt/data/bitcoin'
|
||||||
|
|
||||||
node.default['bitcoin']['conf'] = {
|
node.default['bitcoin']['conf'] = {
|
||||||
irc: 1,
|
irc: 1,
|
||||||
@ -14,8 +16,8 @@ node.default['bitcoin']['conf'] = {
|
|||||||
listen: 1,
|
listen: 1,
|
||||||
server: 1,
|
server: 1,
|
||||||
rpcssl: 0,
|
rpcssl: 0,
|
||||||
rpcuser: 'bitcoind',
|
rpcuser: 'satoshi',
|
||||||
rpcbind: "127.0.0.1:8336",
|
rpcbind: "127.0.0.1:8332",
|
||||||
gen: 0,
|
gen: 0,
|
||||||
zmqpubrawblock: 'tcp://127.0.0.1:8337',
|
zmqpubrawblock: 'tcp://127.0.0.1:8337',
|
||||||
zmqpubrawtx: 'tcp://127.0.0.1:8338'
|
zmqpubrawtx: 'tcp://127.0.0.1:8338'
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
name 'kosmos-bitcoin'
|
name 'kosmos-bitcoin'
|
||||||
maintainer 'The Authors'
|
maintainer 'Kosmos Developers'
|
||||||
maintainer_email 'you@example.com'
|
maintainer_email 'mail@kosmos.org'
|
||||||
license 'All Rights Reserved'
|
license 'MIT'
|
||||||
description 'Installs/Configures kosmos-bitcoin'
|
description 'Installs/Configures Bitcoin Core'
|
||||||
long_description 'Installs/Configures kosmos-bitcoin'
|
long_description 'Installs/Configures Bitcoin Core'
|
||||||
version '0.1.0'
|
version '0.1.0'
|
||||||
chef_version '>= 14.0'
|
chef_version '>= 14.0'
|
||||||
|
|
||||||
@ -18,3 +18,7 @@ chef_version '>= 14.0'
|
|||||||
# a Supermarket.
|
# a Supermarket.
|
||||||
#
|
#
|
||||||
# source_url 'https://github.com/<insert_org_here>/kosmos-bitcoin'
|
# source_url 'https://github.com/<insert_org_here>/kosmos-bitcoin'
|
||||||
|
|
||||||
|
depends "ark"
|
||||||
|
depends "kosmos_encfs"
|
||||||
|
depends "ulimit"
|
||||||
|
144
site-cookbooks/kosmos-bitcoin/recipes/source.rb
Normal file
144
site-cookbooks/kosmos-bitcoin/recipes/source.rb
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
#
|
||||||
|
# Cookbook:: kosmos-bitcoin
|
||||||
|
# Recipe:: source
|
||||||
|
#
|
||||||
|
# The MIT License (MIT)
|
||||||
|
#
|
||||||
|
# Copyright:: 2020, Kosmos Developers
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
include_recipe 'ark'
|
||||||
|
|
||||||
|
build_essential
|
||||||
|
|
||||||
|
%w{ libtool autotools-dev make automake cmake curl g++-multilib libtool
|
||||||
|
binutils-gold bsdmainutils pkg-config python3 patch }.each do |pkg|
|
||||||
|
apt_package pkg
|
||||||
|
end
|
||||||
|
|
||||||
|
ark 'bitcoind' do
|
||||||
|
url "https://bitcoincore.org/bin/bitcoin-core-#{node['bitcoin']['version']}/bitcoin-#{node['bitcoin']['version']}.tar.gz"
|
||||||
|
checksum node['bitcoin']['checksum']
|
||||||
|
action :put
|
||||||
|
end
|
||||||
|
|
||||||
|
execute "Compile bitcoin-core dependencies" do
|
||||||
|
cwd "/usr/local/bitcoind/depends"
|
||||||
|
command "make NO_QT=1"
|
||||||
|
not_if { ::File.directory?("/usr/local/bitcoind/depends/x86_64-pc-linux-gnu") }
|
||||||
|
end
|
||||||
|
|
||||||
|
execute "Configure bitcoin-core" do
|
||||||
|
cwd "/usr/local/bitcoind"
|
||||||
|
command [
|
||||||
|
"./autogen.sh",
|
||||||
|
"./configure --prefix=$PWD/depends/x86_64-pc-linux-gnu"
|
||||||
|
]
|
||||||
|
not_if { ::File.exist?("/usr/local/bitcoind/src/bitcoind") }
|
||||||
|
end
|
||||||
|
|
||||||
|
execute "Compile bitcoin-core" do
|
||||||
|
cwd "/usr/local/bitcoind"
|
||||||
|
command "make"
|
||||||
|
not_if { ::File.exist?("/usr/local/bitcoind/src/bitcoind") }
|
||||||
|
end
|
||||||
|
|
||||||
|
link "/usr/local/bin/bitcoind" do
|
||||||
|
to "/usr/local/bitcoind/src/bitcoind"
|
||||||
|
end
|
||||||
|
|
||||||
|
link "/usr/local/bin/bitcoin-cli" do
|
||||||
|
to "/usr/local/bitcoind/src/bitcoin-cli"
|
||||||
|
end
|
||||||
|
|
||||||
|
bitcoin_user = node['bitcoin']['username']
|
||||||
|
bitcoin_group = node['bitcoin']['usergroup']
|
||||||
|
bitcoin_datadir = node['bitcoin']['datadir']
|
||||||
|
credentials = Chef::EncryptedDataBagItem.load('credentials', 'bitcoin')
|
||||||
|
|
||||||
|
group bitcoin_group
|
||||||
|
|
||||||
|
user bitcoin_user do
|
||||||
|
manage_home true
|
||||||
|
gid bitcoin_group
|
||||||
|
shell "/bin/bash"
|
||||||
|
end
|
||||||
|
|
||||||
|
directory bitcoin_datadir do
|
||||||
|
owner bitcoin_user
|
||||||
|
group bitcoin_group
|
||||||
|
mode '0750'
|
||||||
|
recursive true
|
||||||
|
action :create
|
||||||
|
end
|
||||||
|
|
||||||
|
template "#{bitcoin_datadir}/bitcoin.conf" do
|
||||||
|
owner bitcoin_user
|
||||||
|
group bitcoin_group
|
||||||
|
mode '0640'
|
||||||
|
# TODO Create new in data bag and use here
|
||||||
|
variables conf: node['bitcoin']['conf'].merge({rpcpassword: credentials["rpcpassword"]}),
|
||||||
|
mainnet_conf: node['bitcoin']['mainnet_conf'],
|
||||||
|
testnet_conf: node['bitcoin']['testnet_conf'],
|
||||||
|
regtest_conf: node['bitcoin']['regtest_conf']
|
||||||
|
action :create
|
||||||
|
notifies :restart, "systemd_unit[bitcoind.service]", :delayed
|
||||||
|
end
|
||||||
|
|
||||||
|
systemd_unit 'bitcoind.service' do
|
||||||
|
content({
|
||||||
|
Unit: {
|
||||||
|
Description: 'Bitcoin Core daemon',
|
||||||
|
Documentation: ['https://bitcoincore.org'],
|
||||||
|
After: 'network.target'
|
||||||
|
},
|
||||||
|
Service: {
|
||||||
|
User: bitcoin_user,
|
||||||
|
Type: 'simple',
|
||||||
|
ExecStart: "bitcoind -datadir=#{bitcoin_datadir} -pid=#{bitcoin_datadir}/bitcoind.pid",
|
||||||
|
PIDFile: "#{bitcoin_datadir}/bitcoind.pid",
|
||||||
|
Restart: 'always',
|
||||||
|
PrivateTmp: true,
|
||||||
|
LimitNOFILE: 'infinity',
|
||||||
|
TimeoutStopSec: '60s',
|
||||||
|
TimeoutStartSec: '20s',
|
||||||
|
StartLimitInterval: '60s',
|
||||||
|
StartLimitBurst: '2'
|
||||||
|
},
|
||||||
|
Install: {
|
||||||
|
WantedBy: 'multi-user.target'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
verify false
|
||||||
|
triggers_reload true
|
||||||
|
action [:create, :start]
|
||||||
|
end
|
||||||
|
|
||||||
|
# Creates/starts a Path unit which starts the bitcoind service when the
|
||||||
|
# encrypted data directory is mounted
|
||||||
|
# TODO move to custom kosmos cookbook before publishing bitcoin cookbook
|
||||||
|
encfs_path_activation_unit 'bitcoind.service'
|
||||||
|
|
||||||
|
firewall_rule 'bitcoind' do
|
||||||
|
port [8333] # TODO adjust for testnet
|
||||||
|
protocol :tcp
|
||||||
|
command :allow
|
||||||
|
end
|
@ -5,14 +5,14 @@
|
|||||||
## during the next Chef run!
|
## during the next Chef run!
|
||||||
##
|
##
|
||||||
|
|
||||||
<% @conf.each do |key, value| %>
|
<% @conf.sort.each do |key, value| %>
|
||||||
<%= "#{key}=#{value}" %>
|
<%= "#{key}=#{value}" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @mainnet_conf %>
|
<% if @mainnet_conf %>
|
||||||
# Options only for mainnet
|
# Options only for mainnet
|
||||||
[main]
|
[main]
|
||||||
<% @mainnet_conf.each do |key, value| %>
|
<% @mainnet_conf.sort.each do |key, value| %>
|
||||||
<%= "#{key}=#{value}" %>
|
<%= "#{key}=#{value}" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -20,7 +20,7 @@
|
|||||||
<% if @testnet_conf %>
|
<% if @testnet_conf %>
|
||||||
# Options only for testnet
|
# Options only for testnet
|
||||||
[test]
|
[test]
|
||||||
<% @testnet_conf.each do |key, value| %>
|
<% @testnet_conf.sort.each do |key, value| %>
|
||||||
<%= "#{key}=#{value}" %>
|
<%= "#{key}=#{value}" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
<% if @regtest_conf %>
|
<% if @regtest_conf %>
|
||||||
# Options only for regtest
|
# Options only for regtest
|
||||||
[regtest]
|
[regtest]
|
||||||
<% @regtest_conf.each do |key, value| %>
|
<% @regtest_conf.sort.each do |key, value| %>
|
||||||
<%= "#{key}=#{value}" %>
|
<%= "#{key}=#{value}" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user