Moving bitcoin-core to VM
This commit is contained in:
@@ -3,8 +3,9 @@ node.default['bitcoin']['checksum'] = '4bbd62fd6acfa5e9864ebf37a24a04bc2dcfe3e3
|
||||
node.default['bitcoin']['username'] = 'satoshi'
|
||||
node.default['bitcoin']['usergroup'] = 'bitcoin'
|
||||
node.default['bitcoin']['network'] = 'mainnet'
|
||||
node.default['bitcoin']['datadir'] = '/home/satoshi/.bitcoin'
|
||||
node.default['bitcoin']['walletdir'] = '/mnt/data/bitcoin'
|
||||
node.default['bitcoin']['conf_path'] = '/home/satoshi/.bitcoin/bitcoin.conf'
|
||||
node.default['bitcoin']['walletdir'] = '/home/satoshi/.bitcoin'
|
||||
node.default['bitcoin']['datadir'] = '/mnt/data/bitcoin'
|
||||
|
||||
node.default['bitcoin']['conf'] = {
|
||||
irc: 1,
|
||||
|
||||
@@ -25,6 +25,28 @@
|
||||
# THE SOFTWARE.
|
||||
#
|
||||
|
||||
# TODO move to custom kosmos cookbook before publshing bitcoin cookbook
|
||||
systemd_unit "mnt-data-bitcoin.mount" do
|
||||
content({
|
||||
Unit: {
|
||||
Description: 'Bitcoin Core data directory',
|
||||
},
|
||||
Mount: {
|
||||
What: '/var/lib/vmshare-bitcoin',
|
||||
Where: '/mnt/data/bitcoin',
|
||||
Type: '9p',
|
||||
Options: 'trans=virtio,version=9p2000.L'
|
||||
},
|
||||
Install: {
|
||||
WantedBy: 'multi-user.target'
|
||||
}
|
||||
})
|
||||
verify false
|
||||
triggers_reload true
|
||||
action [:create, :enable, :start]
|
||||
end
|
||||
|
||||
|
||||
include_recipe 'ark'
|
||||
|
||||
build_essential
|
||||
@@ -46,21 +68,17 @@ execute "Compile bitcoin-core dependencies" do
|
||||
not_if { ::File.directory?("/usr/local/bitcoind/depends/x86_64-pc-linux-gnu") }
|
||||
end
|
||||
|
||||
execute "Configure bitcoin-core" do
|
||||
execute "Configure, compile bitcoin-core" do
|
||||
cwd "/usr/local/bitcoind"
|
||||
# FIXME only executes first array item?
|
||||
command [
|
||||
"./autogen.sh",
|
||||
"./configure --prefix=$PWD/depends/x86_64-pc-linux-gnu"
|
||||
"./configure --prefix=$PWD/depends/x86_64-pc-linux-gnu",
|
||||
"make"
|
||||
]
|
||||
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
|
||||
@@ -73,12 +91,14 @@ bitcoin_user = node['bitcoin']['username']
|
||||
bitcoin_group = node['bitcoin']['usergroup']
|
||||
bitcoin_datadir = node['bitcoin']['datadir']
|
||||
bitcoin_walletdir = node['bitcoin']['walletdir']
|
||||
bitcoin_conf_path = node['bitcoin']['conf_path']
|
||||
credentials = Chef::EncryptedDataBagItem.load('credentials', 'bitcoin')
|
||||
|
||||
group bitcoin_group
|
||||
|
||||
user bitcoin_user do
|
||||
manage_home true
|
||||
uid 1006
|
||||
gid bitcoin_group
|
||||
shell "/bin/bash"
|
||||
end
|
||||
@@ -97,7 +117,7 @@ bitcoin_config = node['bitcoin']['conf'].merge({
|
||||
rpcpassword: credentials["rpcpassword"]
|
||||
})
|
||||
|
||||
template "#{bitcoin_datadir}/bitcoin.conf" do
|
||||
template bitcoin_conf_path do
|
||||
owner bitcoin_user
|
||||
group bitcoin_group
|
||||
mode '0640'
|
||||
@@ -119,7 +139,7 @@ systemd_unit 'bitcoind.service' do
|
||||
Service: {
|
||||
User: bitcoin_user,
|
||||
Type: 'simple',
|
||||
ExecStart: "bitcoind -datadir=#{bitcoin_datadir} -walletdir=#{bitcoin_walletdir} -pid=#{bitcoin_datadir}/bitcoind.pid",
|
||||
ExecStart: "bitcoind -conf=#{bitcoin_conf_path} -datadir=#{bitcoin_datadir} -walletdir=#{bitcoin_walletdir} -pid=#{bitcoin_datadir}/bitcoind.pid",
|
||||
PIDFile: "#{bitcoin_datadir}/bitcoind.pid",
|
||||
Restart: 'always',
|
||||
PrivateTmp: true,
|
||||
@@ -135,14 +155,9 @@ systemd_unit 'bitcoind.service' do
|
||||
})
|
||||
verify false
|
||||
triggers_reload true
|
||||
action [:create, :start]
|
||||
action [:create, :enable, :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'
|
||||
|
||||
# TODO move to custom kosmos cookbook before publishing bitcoin cookbook
|
||||
firewall_rule 'bitcoind' do
|
||||
port [8333] # TODO adjust for testnet
|
||||
|
||||
Reference in New Issue
Block a user