Râu Cao 176dd64438
Remove peerswap policy file from recipe
This will be auto-created anyway, and we don't want to overwrite changes
added by the CLI.
2022-12-26 11:29:17 +07:00

87 lines
2.0 KiB
Ruby

#
# Cookbook:: kosmos-bitcoin
# Recipe:: peerswap-lnd
#
include_recipe 'git'
include_recipe 'kosmos-bitcoin::golang'
include_recipe 'kosmos-bitcoin::user'
bitcoin_user = node['bitcoin']['username']
bitcoin_group = node['bitcoin']['usergroup']
lnd_dir = node['lnd']['lnd_dir']
macaroon_path = "#{lnd_dir}/data/chain/bitcoin/#{node['bitcoin']['network']}/admin.macaroon"
source_dir = node['peerswap-lnd']['source_dir']
config_dir = "/home/#{bitcoin_user}/.peerswap"
directory config_dir do
owner bitcoin_user
group bitcoin_group
mode '0700'
action :create
end
git source_dir do
repository node['peerswap']['repo']
revision node['peerswap']['revision']
action :sync
notifies :run, 'bash[compile_peerswap]', :immediately
end
bash 'compile_peerswap' do
cwd source_dir
environment 'GOPATH' => '/opt/go'
code 'make lnd-release'
action :run
notifies :restart, 'service[peerswap]', :delayed
end
template "#{config_dir}/peerswap.conf" do
source 'peerswap-lnd.conf.erb'
owner bitcoin_user
group bitcoin_group
mode 0600
sensitive true
variables config: {
tlscertpath: "#{lnd_dir}/tls.cert",
macaroonpath: macaroon_path
}
notifies :restart, 'service[peerswap]', :delayed
end
systemd_unit 'peerswap.service' do
content({
Unit: {
Description: 'PeerSwap Lightning channel balancing',
Documentation: ['https://github.com/ElementsProject/peerswap'],
Requires: 'lnd.service',
After: 'lnd.service'
},
Service: {
User: bitcoin_user,
Group: bitcoin_group,
Type: 'simple',
WorkingDirectory: source_dir,
ExecStart: "/opt/go/bin/peerswapd",
Restart: 'always',
RestartSec: '10',
TimeoutSec: '60',
PrivateTmp: true,
ProtectSystem: 'full',
NoNewPrivileges: true,
PrivateDevices: true,
MemoryDenyWriteExecute: true
},
Install: {
WantedBy: 'multi-user.target'
}
})
verify false
triggers_reload true
action [:create, :enable, :start]
end
service 'peerswap' do
action :nothing
end