Fix the ipfs config
The whole thing was inconsistent and didn't work when creating a server from scratch
This commit is contained in:
parent
b2d92723d7
commit
d0f2275ebb
@ -2,4 +2,4 @@ node.default['ipfs']['version'] = "0.4.9"
|
||||
node.default['ipfs']['checksum'] = "ae50c760f58548adc7c6dade4cf549059b6bc73ebc25ff4ea9fece06a15ac0a6"
|
||||
# Do not contact local network addresses. This will stop platforms like Hetzner
|
||||
# to block your server (https://github.com/ipfs/go-ipfs/issues/1226)
|
||||
node.default['ipfs']['config']['swarm']['addr_filter'] = '["/ip4/10.0.0.0/ipcidr/8","/ip4/100.64.0.0/ipcidr/10","/ip4/169.254.0.0/ipcidr/16","/ip4/172.16.0.0/ipcidr/12","/ip4/192.0.0.0/ipcidr/24","/ip4/192.0.0.0/ipcidr/29","/ip4/192.0.0.8/ipcidr/32","/ip4/192.0.0.170/ipcidr/32","/ip4/192.0.0.171/ipcidr/32","/ip4/192.0.2.0/ipcidr/24","/ip4/192.168.0.0/ipcidr/16","/ip4/198.18.0.0/ipcidr/15","/ip4/198.51.100.0/ipcidr/24","/ip4/203.0.113.0/ipcidr/24","/ip4/240.0.0.0/ipcidr/4"]'
|
||||
node.default['ipfs']['config']['swarm']['addr_filter'] = ["/ip4/10.0.0.0/ipcidr/8", "/ip4/100.64.0.0/ipcidr/10", "/ip4/169.254.0.0/ipcidr/16", "/ip4/172.16.0.0/ipcidr/12", "/ip4/192.0.0.0/ipcidr/24", "/ip4/192.0.0.0/ipcidr/29", "/ip4/192.0.0.8/ipcidr/32", "/ip4/192.0.0.170/ipcidr/32", "/ip4/192.0.0.171/ipcidr/32", "/ip4/192.0.2.0/ipcidr/24", "/ip4/192.168.0.0/ipcidr/16", "/ip4/198.18.0.0/ipcidr/15", "/ip4/198.51.100.0/ipcidr/24", "/ip4/203.0.113.0/ipcidr/24", "/ip4/240.0.0.0/ipcidr/4"]
|
||||
|
@ -1,25 +1,22 @@
|
||||
require 'json'
|
||||
require 'mixlib/shellout'
|
||||
|
||||
property :key, String, name_property: true
|
||||
property :value, [String, Hash, Array, TrueClass, FalseClass], required: true
|
||||
|
||||
load_current_value do
|
||||
# some Ruby
|
||||
end
|
||||
|
||||
action :create do
|
||||
include_recipe "ipfs"
|
||||
|
||||
execute "ipfs config --json #{key} '#{value}'" do
|
||||
execute "ipfs config --json #{key} '#{JSON.generate(value)}'" do
|
||||
environment "IPFS_PATH" => "/home/ipfs/.ipfs"
|
||||
user "ipfs"
|
||||
not_if do
|
||||
require 'json'
|
||||
require 'mixlib/shellout'
|
||||
cmd = Mixlib::ShellOut.new("ipfs", "config", key,
|
||||
user: 'ipfs',
|
||||
env: { "IPFS_PATH" => "/home/ipfs/.ipfs" })
|
||||
cmd.run_command
|
||||
begin
|
||||
JSON.parse(cmd.stdout) == JSON.parse(value)
|
||||
JSON.parse(cmd.stdout) == JSON.parse(JSON.generate(value))
|
||||
rescue JSON::ParserError
|
||||
cmd.stdout.include?("#{value}")
|
||||
end
|
||||
|
@ -7,6 +7,7 @@
|
||||
# All rights reserved - Do Not Redistribute
|
||||
#
|
||||
|
||||
require 'json'
|
||||
include_recipe "ipfs"
|
||||
|
||||
# Configure ipfs
|
||||
@ -18,18 +19,18 @@ end
|
||||
|
||||
# Set up the Gateway to be writable
|
||||
ipfs_config "Gateway.Writable" do
|
||||
value "true"
|
||||
value true
|
||||
end
|
||||
|
||||
# Set up CORS headers
|
||||
ipfs_config "API.HTTPHeaders.Access-Control-Allow-Credentials" do
|
||||
value '["true"]'
|
||||
value ["true"]
|
||||
end
|
||||
ipfs_config "API.HTTPHeaders.Access-Control-Allow-Methods" do
|
||||
value '["PUT","GET","POST"]'
|
||||
value ["PUT", "GET", "POST"]
|
||||
end
|
||||
ipfs_config "API.HTTPHeaders.Access-Control-Allow-Origin" do
|
||||
value '["*"]'
|
||||
value ["*"]
|
||||
end
|
||||
|
||||
include_recipe "kosmos-ipfs::letsencrypt"
|
||||
|
Loading…
x
Reference in New Issue
Block a user