# # Cookbook Name:: ipfs # Recipe:: cluster # # Copyright 2018, Kosmos # # All rights reserved - Do Not Redistribute # version = node["ipfs"]["cluster"]["version"] ark "ipfs-cluster-service" do url "https://dist.ipfs.io/ipfs-cluster-service/v#{version}/ipfs-cluster-service_v#{version}_linux-amd64.tar.gz" has_binaries ["ipfs-cluster-service"] end ark "ipfs-cluster-ctl" do url "https://dist.ipfs.io/ipfs-cluster-ctl/v#{version}/ipfs-cluster-ctl_v#{version}_linux-amd64.tar.gz" has_binaries ["ipfs-cluster-ctl"] end credentials = data_bag_item("credentials", "ipfs_cluster") execute "ipfs-cluster-service init" do user "ipfs" environment "CLUSTER_SECRET" => credentials["secret"], "IPFS_CLUSTER_PATH" => "/home/ipfs/.ipfs-cluster" not_if { File.exist? "/home/ipfs/.ipfs-cluster/service.json" } end if platform?('ubuntu') && node[:platform_version].to_f < 15.04 || platform?('debian') && node['platform_version'].to_f < 8 template "ipfs.initd-cluster.service.erb" do path "/etc/init.d/ipfs-cluster" source 'ipfs-cluster.initd.service.erb' owner 'root' group 'root' mode '0750' notifies :restart, "service[ipfs-cluster]", :delayed end service "ipfs-cluster" do provider Chef::Provider::Service::Init::Debian action [:enable] supports start: true, stop: true, restart: true, reload: false, status: true end else execute "systemctl daemon-reload" do command "systemctl daemon-reload" action :nothing end template "ipfs-cluster.systemd.service.erb" do path "/lib/systemd/system/ipfs-cluster.service" source 'ipfs-cluster.systemd.service.erb' owner 'root' group 'root' mode '0644' notifies :run, "execute[systemctl daemon-reload]", :delayed notifies :restart, "service[ipfs-cluster]", :delayed end service "ipfs-cluster" do provider Chef::Provider::Service::Systemd action [:enable] end end