Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
infertux committed May 30, 2024
1 parent 00f2f7c commit 1948a0b
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 113 deletions.
8 changes: 0 additions & 8 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
default['bitcoin']['home'] = "/home/#{node['bitcoin']['user']}"
default['bitcoin']['conf_dir'] = "#{node['bitcoin']['home']}/.bitcoin"
default['bitcoin']['conf_file'] = "#{node['bitcoin']['conf_dir']}/bitcoin.conf"
default['bitcoin']['service_file'] = "/usr/lib/systemd/system/#{node['bitcoin']['binary_name']}.service"
default['bitcoin']['archive_file'] = "#{node['bitcoin']['variant']}.tar.gz"
default['bitcoin']['archive_path'] = "#{Chef::Config['file_cache_path']}/bitcoin/#{node['bitcoin']['archive_file']}"
default['bitcoin']['extract_path'] = "#{Chef::Config['file_cache_path']}/bitcoin/#{node['bitcoin']['variant']}"
Expand All @@ -28,13 +27,6 @@
default['bitcoin']['binary']['url']['core'] = "https://bitcoincore.org/bin/bitcoin-core-#{node['bitcoin']['binary']['version']['core']}/bitcoin-#{node['bitcoin']['binary']['version']['core']}-x86_64-linux-gnu.tar.gz"
default['bitcoin']['binary']['checksum']['core'] = '2a6974c5486f528793c79d42694b5987401e4a43c97f62b1383abf35bcee44a8'

# 'package' recipe

default['bitcoin']['package']['repo_url']['rhel'] = 'https://linux.ringingliberty.com/bitcoin/el7/x86_64/bitcoin-release-4-1.noarch.rpm'
default['bitcoin']['package']['repo_checksum']['rhel'] = 'dcba5cb150b8af5a2c1ebec2c9d0255c8b5221c1002469f2170a679e60908ec5'
default['bitcoin']['package']['repo_url']['fedora'] = 'https://linux.ringingliberty.com/bitcoin/f27/x86_64/bitcoin-release-4-1.noarch.rpm'
default['bitcoin']['package']['repo_checksum']['fedora'] = 'cac67430e1e76b1b740cd7967e0038ba7989c3fde0660a30bfd22a233e33f708'

# 'source' recipe

default['bitcoin']['source']['version']['core'] = '27.0'
Expand Down
4 changes: 0 additions & 4 deletions recipes/_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
# Recipe:: _common
#

unless node['bitcoin']['variant']
raise "You must select the variant you wish to install with `node['bitcoin']['variant'] = $variant'. Possible variants are abc, bucash, core, unlimited, and xt."
end

user node['bitcoin']['user'] do
home node['bitcoin']['home']
shell '/bin/sh'
Expand Down
58 changes: 28 additions & 30 deletions recipes/_systemd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,35 @@
# Recipe:: _systemd
#

directory File.dirname(node['bitcoin']['service_file']) do
user 'root'
group 'root'
mode '0755'
only_if 'test -f /bin/systemctl && /bin/systemctl'
end
systemd_unit "#{node['bitcoin']['binary_name']}.service" do
content <<~SYSTEMD
[Unit]
Description=Bitcoin daemon
After=network.target
template node['bitcoin']['service_file'] do
source "#{node['bitcoin']['binary_name']}.service.erb"
owner 'root'
group 'root'
mode '0644'
variables(
user: node['bitcoin']['user'],
binary_path: node['bitcoin']['binary_path'],
conf_dir: node['bitcoin']['conf_dir'],
)
notifies :run, 'execute[systemd-daemon-reload]', :immediately
only_if 'test -f /bin/systemctl && /bin/systemctl'
end
[Service]
User=#{node['bitcoin']['user']}
Group=#{node['bitcoin']['user']}
service node['bitcoin']['binary_name'] do
provider Chef::Provider::Service::Systemd
action [:enable]
subscribes :restart, "template[#{node['bitcoin']['service_file']}]", :delayed
subscribes :restart, "template[#{node['bitcoin']['conf_file']}]", :delayed
only_if 'test -f /bin/systemctl && /bin/systemctl'
end
Type=forking
PIDFile=#{node['bitcoin']['conf_dir']}/bitcoind.pid
ExecStart=#{node['bitcoin']['binary_path']} -daemon -pid=#{node['bitcoin']['conf_dir']}/bitcoind.pid
PrivateTmp=true
ProtectHome=true
ProtectProc=invisible
ProtectSystem=full
Restart=on-failure
TimeoutStopSec=60
TimeoutStartSec=5
StartLimitInterval=120
StartLimitBurst=5
[Install]
WantedBy=multi-user.target
SYSTEMD

execute 'systemd-daemon-reload' do
action :nothing
command 'systemctl daemon-reload'
only_if 'test -f /bin/systemctl && /bin/systemctl'
action %i(enable)
notifies :restart, "systemd_unit[#{node['bitcoin']['binary_name']}.service]"
end
2 changes: 1 addition & 1 deletion recipes/binary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
SCRIPT
end

include_recipe 'bitcoin::_systemd'
include_recipe 'bitcoin::_systemd' if systemd?
47 changes: 0 additions & 47 deletions recipes/package.rb

This file was deleted.

2 changes: 1 addition & 1 deletion recipes/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
SCRIPT
end

include_recipe 'bitcoin::_systemd'
include_recipe 'bitcoin::_systemd' if systemd?
21 changes: 0 additions & 21 deletions templates/default/bitcoind.service.erb

This file was deleted.

2 changes: 1 addition & 1 deletion test/integration/default/bitcoin_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe command('sudo -u bitcoin -- bitcoin-cli -version') do
its('exit_status') { should eq 0 }
its('stdout') { should include "Bitcoin Core RPC client" }
its('stdout') { should include 'Bitcoin Core RPC client' }
end

0 comments on commit 1948a0b

Please sign in to comment.