79 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			79 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| #
 | |
| # Cookbook Name:: ipfs
 | |
| # Recipe:: default
 | |
| #
 | |
| # Copyright 2017, Kosmos
 | |
| #
 | |
| # All rights reserved - Do Not Redistribute
 | |
| #
 | |
| 
 | |
| version = node["ipfs"]["version"]
 | |
| 
 | |
| ark "ipfs" do
 | |
|   url "https://dist.ipfs.io/go-ipfs/v#{version}/go-ipfs_v#{version}_linux-amd64.tar.gz"
 | |
|   checksum node["ipfs"]["checksum"]
 | |
|   has_binaries ["ipfs"]
 | |
| end
 | |
| 
 | |
| group "ipfs" do
 | |
|   gid 4737
 | |
| end
 | |
| 
 | |
| user "ipfs" do
 | |
|   comment "ipfs"
 | |
|   uid 4737
 | |
|   gid 4737
 | |
|   home "/home/ipfs"
 | |
|   manage_home true
 | |
| end
 | |
| 
 | |
| execute "ipfs init --empty-repo" do
 | |
|   environment "IPFS_PATH" => "/home/ipfs/.ipfs"
 | |
|   user "ipfs"
 | |
|   not_if { File.directory? "/home/ipfs/.ipfs" }
 | |
| end
 | |
| 
 | |
| if platform?('ubuntu') && node[:platform_version].to_f < 15.04 ||
 | |
|    platform?('debian') && node['platform_version'].to_f < 8
 | |
|   template "ipfs.initd.service.erb" do
 | |
|     path "/etc/init.d/ipfs"
 | |
|     source 'ipfs.initd.service.erb'
 | |
|     owner 'root'
 | |
|     group 'root'
 | |
|     mode '0750'
 | |
|     notifies :restart, "service[ipfs]", :delayed
 | |
|   end
 | |
| 
 | |
|   service "ipfs" 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.systemd.service.erb" do
 | |
|     path "/lib/systemd/system/ipfs.service"
 | |
|     source 'ipfs.systemd.service.erb'
 | |
|     owner 'root'
 | |
|     group 'root'
 | |
|     mode '0644'
 | |
|     notifies :run, "execute[systemctl daemon-reload]", :delayed
 | |
|     notifies :restart, "service[ipfs]", :delayed
 | |
|   end
 | |
| 
 | |
|   service "ipfs" do
 | |
|     provider Chef::Provider::Service::Systemd
 | |
|     action [:enable]
 | |
|   end
 | |
| end
 | |
| 
 | |
| # Configure ipfs to not contact local network addresses
 | |
| ipfs_config "Swarm.AddrFilters" do
 | |
|   value node['ipfs']['config']['swarm']['addr_filter']
 | |
| end
 |