# # Cookbook:: kosmos-bitcoin # Recipe:: lnd-scb-s3 # # Static Channel Backup for LND channel states # include_recipe "kosmos-bitcoin::aws-client" package "inotify-tools" backup_script_path = "/opt/lnd-channel-backup-s3.sh" backup_credentials = Chef::EncryptedDataBagItem.load('credentials', 'backup') template backup_script_path do source "lnd-channel-backup-s3.sh.erb" mode '0740' variables lnd_dir: node['lnd']['lnd_dir'], bitcoin_network: node['bitcoin']['network'], s3_endpoint: backup_credentials['s3_endpoint'], s3_bucket: node['backup']['s3']['bucket'], s3_scb_dir: "#{node['name']}/lnd/#{node['bitcoin']['network']}" notifies :restart, "systemd_unit[lnd-channel-backup.service]", :delayed end systemd_unit 'lnd-channel-backup.service' do content({ Unit: { Description: 'LND Static Channel Backup', Documentation: ['https://gist.github.com/alexbosworth/2c5e185aedbdac45a03655b709e255a3'], Requires: 'lnd.service', After: 'lnd.service' }, Service: { User: 'root', Group: 'root', Type: 'simple', ExecStart: backup_script_path, Restart: 'always', RestartSec: 1 }, Install: { WantedBy: 'multi-user.target' } }) verify false triggers_reload true action [:create, :enable, :start] end