Fix the ipfs config

The whole thing was inconsistent and didn't work when creating a server
from scratch
This commit is contained in:
Greg Karékinian
2018-08-06 12:14:20 +02:00
parent b2d92723d7
commit d0f2275ebb
3 changed files with 11 additions and 13 deletions

View File

@@ -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