# # Cookbook:: strfry # Recipe:: default # unless platform?("ubuntu") raise "This recipe only supports Ubuntu installs at the moment" end if node["strfry"]["download_url"] # # Install by downloading an executable file # remote_file '/usr/local/bin/strfry' do source node["strfry"]["download_url"] checksum node["strfry"]["checksum"] mode '0755' show_progress true notifies :restart, "service[strfry]", :delayed end else # # Install by building from source # %w[ git build-essential libyaml-perl libtemplate-perl libregexp-grammars-perl libssl-dev zlib1g-dev liblmdb-dev libflatbuffers-dev libsecp256k1-dev libzstd-dev ].each do |pkg| package pkg end git "/usr/local/src/strfry" do repository node["strfry"]["repo"] revision node["strfry"]["revision"] enable_submodules true notifies :run, "execute[compile]", :immediately end execute "compile" do cwd "/usr/local/src/strfry" command "make setup-golpe && make -j$(nproc)" # action :nothing notifies :create, "link[/usr/local/bin/strfry]", :immediately notifies :restart, "service[strfry]", :delayed end link "/usr/local/bin/strfry" do to "/usr/local/src/strfry/strfry" action :nothing end end group node["strfry"]["group"] user node["strfry"]["user"] do gid node["strfry"]["group"] manage_home false shell "/usr/sbin/nologin" end directory node["strfry"]["db_path"] do owner node["strfry"]["user"] group node["strfry"]["group"] mode "0755" end template "/etc/strfry.conf" do source "strfry.conf.erb" mode "0644" owner node["strfry"]["user"] group node["strfry"]["group"] variables config: { db_path: node["strfry"]["db_path"], bind: node["strfry"]["bind_ip"], real_ip_header: node["strfry"]["real_ip_header"], port: node["strfry"]["port"], nofiles: node["strfry"]["nofiles"], info: node["strfry"]["info"] } notifies :restart, "service[strfry]", :delayed end service 'strfry' do action :nothing end systemd_unit "strfry.service" do content({ Unit: { Description: "strfry relay", Documentation: ["https://github.com/hoytech/strfry"], }, Service: { Type: "simple", User: node["strfry"]["user"], ExecStart: "/usr/local/bin/strfry relay", Restart: "on-failure", RestartSec: "5", ProtectHome: "yes", NoNewPrivileges: "yes", ProtectSystem: "full", LimitCORE: "1000000000" }, Install: { WantedBy: "multi-user.target" } }) triggers_reload true action :create end service "strfry" do action [:enable, :start] end