Vendor the external cookbooks

Knife-Zero doesn't include Berkshelf support, so vendoring everything in
the repo is convenient again
This commit is contained in:
Greg Karékinian
2019-10-13 19:17:42 +02:00
parent f4bfe31ac1
commit a32f34b408
1245 changed files with 100630 additions and 0 deletions

View File

@@ -0,0 +1 @@
remote_file = "https://raw.githubusercontent.com/chef-cookbooks/community_cookbook_tools/master/delivery/project.toml"

1
cookbooks/ipfs/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/.kitchen/

View File

@@ -0,0 +1,40 @@
---
driver:
name: dokken
privileged: true # because Docker and SystemD/Upstart
chef_version: <%= ENV['CHEF_VERSION'] || 'current' %>
transport:
name: dokken
provisioner:
name: dokken
deprecations_as_errors: true
verifier:
name: inspec
platforms:
- name: ubuntu-16.04
driver:
image: dokken/ubuntu-16.04
pid_one_command: /bin/systemd
- name: ubuntu-18.04
driver:
image: dokken/ubuntu-18.04
pid_one_command: /bin/systemd
- name: debian-9
driver:
image: dokken/debian-9
pid_one_command: /bin/systemd
suites:
- name: default
run_list:
- recipe[ipfs::default]
attributes:
- name: cluster
run_list:
- recipe[ipfs::cluster]
- recipe[ipfs::cluster_service]
attributes:

View File

@@ -0,0 +1,22 @@
---
driver:
name: vagrant
provisioner:
name: chef_zero
platforms:
- name: ubuntu-16.04
- name: ubuntu-18.04
- name: debian-9
suites:
- name: default
run_list:
- recipe[ipfs::default]
attributes:
- name: cluster
run_list:
- recipe[ipfs::cluster]
- recipe[ipfs::cluster_service]
attributes:

View File

@@ -0,0 +1,39 @@
sudo: required
dist: trusty
addons:
apt:
sources:
- chef-current-trusty
packages:
- chefdk
# Don't `bundle install` which takes about 1.5 mins
install: echo "skip bundle install"
branches:
only:
- master
services: docker
env:
matrix:
- INSTANCE=default-debian-9
- INSTANCE=default-ubuntu-1604
- INSTANCE=default-ubuntu-1804
before_script:
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
- eval "$(chef shell-init bash)"
- CHEF_LICENSE=accept-no-persist chef --version
- cookstyle --version
- foodcritic --version
script: CHEF_LICENSE=accept-no-persist KITCHEN_LOCAL_YAML=.kitchen.dokken.yml CHEF_VERSION=13.10.4 kitchen verify ${INSTANCE}
matrix:
include:
- script:
- CHEF_LICENSE=accept-no-persist chef exec delivery local all
env: UNIT_AND_LINT=1

3
cookbooks/ipfs/Berksfile Normal file
View File

@@ -0,0 +1,3 @@
source 'https://api.berkshelf.com'
metadata

View File

@@ -0,0 +1,19 @@
DEPENDENCIES
ipfs
path: .
metadata: true
GRAPH
ark (4.0.0)
build-essential (>= 0.0.0)
seven_zip (>= 0.0.0)
build-essential (8.1.1)
mingw (>= 1.1)
seven_zip (>= 0.0.0)
ipfs (0.4.0)
ark (>= 0.0.0)
mingw (2.1.0)
seven_zip (>= 0.0.0)
seven_zip (3.0.0)
windows (>= 0.0.0)
windows (5.0.0)

View File

@@ -0,0 +1,4 @@
# ipfs CHANGELOG
## 0.1.0
- [gregkare] - Initial release of ipfs

21
cookbooks/ipfs/LICENSE Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018 Kosmos Developers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

91
cookbooks/ipfs/README.md Normal file
View File

@@ -0,0 +1,91 @@
# IPFS Cookbook
This cookbook installs go-ipfs and starts it as a daemon
## Requirements
### Platforms
This cookbook is tested on Ubuntu 18.06, 16.04 and Debian 9 using Test Kitchen.
It currently only supports 64bit platforms
### Chef
- Chef 12.5 or later (the cookbook provides a
[Custom Resource](https://docs.chef.io/custom_resources.html) to configure
go-ipfs)
### Cookbook dependencies
- `ark` to download and uncompress the go-ipfs package
## Usage
### ipfs::default
Just include `ipfs` in your node's `run_list`:
```json
{
"name":"my_node",
"run_list": [
"recipe[ipfs]"
]
}
```
## Attributes
- `node['ipfs']['version']` - the go-ipfs version to download from the official
site (64bit)
- `node['ipfs']['checksum']` - the SHA256 checksum for the package
- `node['ipfs']['config']` - a hash of config options
## Resources
`ipfs_config` sets the config. Supports hashes, arrays, booleans and strings.
Does not change anything if the config already has that value, and restarts
the server automatically
```ruby
ipfs_config "Gateway.Writable" do
value "true"
end
```
## Running the specs and integrations tests
Install the latest [Chef DK](https://downloads.chef.io/chefdk).
```
chef exec delivery local all # Run the linting check, syntax check and unit tests
kitchen verify # Run the integration tests for Ubuntu 16.04, 18.06 and Debian 9
```
## License and Authors
Authors: Kosmos Developers mail@kosmos.org
Copyright: 2018-2019, [Kosmos Developers](https://kredits.kosmos.org/)
```
Unless otherwise noted, all files are released under the MIT license, possible
exceptions will contain licensing information in them.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```

65
cookbooks/ipfs/Rakefile Normal file
View File

@@ -0,0 +1,65 @@
#!/usr/bin/env rake
# Style tests. cookstyle (rubocop) and Foodcritic
namespace :style do
begin
require 'cookstyle'
require 'rubocop/rake_task'
desc 'Run Ruby style checks'
RuboCop::RakeTask.new(:ruby)
rescue LoadError => e
puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV['CI']
end
begin
require 'foodcritic'
desc 'Run Chef style checks'
FoodCritic::Rake::LintTask.new(:chef) do |t|
t.options = {
fail_tags: ['any'],
progress: true,
}
end
rescue LoadError
puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV['CI']
end
end
desc 'Run all style checks'
task style: ['style:chef', 'style:ruby']
# ChefSpec
begin
desc 'Run ChefSpec examples'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
rescue LoadError => e
puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV['CI']
end
# Integration tests. Kitchen.ci
namespace :integration do
begin
require 'kitchen/rake_tasks'
desc 'Run kitchen integration tests'
Kitchen::RakeTasks.new
rescue StandardError => e
puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV['CI']
end
end
namespace :supermarket do
begin
desc 'Publish cookbook to Supermarket with Stove'
require 'stove/rake_task'
Stove::RakeTask.new
rescue LoadError => e
puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV['CI']
end
end
# Default
task default: %w(style spec)

View File

@@ -0,0 +1,31 @@
node.default['ipfs']['version'] = '0.4.22'
node.default['ipfs']['checksum'] = '43431bbef105b1c8d0679350d6f496b934d005df28c13280a67f0c88054976aa'
node.default['ipfs']['ulimit'] = 64000
node.default['ipfs']['memory_max'] = '512M'
node.default['ipfs']['config'] = {
# Do not contact local network addresses. This will stop platforms like Hetzner
# to block your server (https://github.com/ipfs/go-ipfs/issues/1226)
'Swarm.AddrFilters' => ['/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'],
# Set up the Gateway to be writable
'Gateway.Writable' => true,
# Set up CORS headers
'API.HTTPHeaders.Access-Control-Allow-Credentials' => ['true'],
'API.HTTPHeaders.Access-Control-Allow-Methods' => %w(PUT GET POST),
'API.HTTPHeaders.Access-Control-Allow-Origin' => ['*'],
}

View File

@@ -0,0 +1 @@
.kitchen

View File

@@ -0,0 +1,35 @@
{
"name": "ipfs",
"description": "Installs/Configures ipfs",
"long_description": "# IPFS Cookbook\n\nThis cookbook installs go-ipfs and starts it as a daemon\n\n## Requirements\n\n### Platforms\n\nThis cookbook is tested on Ubuntu 18.06, 16.04 and Debian 9 using Test Kitchen.\nIt currently only supports 64bit platforms\n\n### Chef\n\n- Chef 12.5 or later (the cookbook provides a\n [Custom Resource](https://docs.chef.io/custom_resources.html) to configure\n go-ipfs)\n\n### Cookbook dependencies\n\n- `ark` to download and uncompress the go-ipfs package\n\n## Usage\n\n### ipfs::default\n\nJust include `ipfs` in your node's `run_list`:\n\n```json\n{\n \"name\":\"my_node\",\n \"run_list\": [\n \"recipe[ipfs]\"\n ]\n}\n```\n\n## Attributes\n\n- `node['ipfs']['version']` - the go-ipfs version to download from the official\nsite (64bit)\n- `node['ipfs']['checksum']` - the SHA256 checksum for the package\n- `node['ipfs']['config']` - a hash of config options\n\n## Resources\n\n`ipfs_config` sets the config. Supports hashes, arrays, booleans and strings.\nDoes not change anything if the config already has that value, and restarts\nthe server automatically\n\n```ruby\nipfs_config \"Gateway.Writable\" do\n value \"true\"\n end\n```\n\n## Running the specs and integrations tests\n\nInstall the latest [Chef DK](https://downloads.chef.io/chefdk).\n\n```\nchef exec delivery local all # Run the linting check, syntax check and unit tests\nkitchen verify # Run the integration tests for Ubuntu 16.04, 18.06 and Debian 9\n```\n\n## License and Authors\n\nAuthors: Kosmos Developers mail@kosmos.org \nCopyright: 2018-2019, [Kosmos Developers](https://kredits.kosmos.org/)\n\n```\nUnless otherwise noted, all files are released under the MIT license, possible\nexceptions will contain licensing information in them.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n",
"maintainer": "Kosmos Developers",
"maintainer_email": "mail@kosmos.org",
"license": "MIT",
"platforms": {
"[\"ubuntu\", \"debian\"]": ">= 0.0.0"
},
"dependencies": {
"ark": ">= 0.0.0"
},
"providing": {
},
"recipes": {
},
"version": "0.4.1",
"source_url": "https://github.com/67P/ipfs-cookbook",
"issues_url": "https://github.com/67P/ipfs-cookbook/issues",
"privacy": false,
"chef_versions": [
[
">= 12.14"
]
],
"ohai_versions": [
],
"gems": [
]
}

View File

@@ -0,0 +1,15 @@
name 'ipfs'
maintainer 'Kosmos Developers'
maintainer_email 'mail@kosmos.org'
license 'MIT'
description 'Installs/Configures ipfs'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.4.1'
supports %w(ubuntu debian)
depends 'ark'
source_url 'https://github.com/67P/ipfs-cookbook'
issues_url 'https://github.com/67P/ipfs-cookbook/issues'
chef_version '>= 12.14' if respond_to?(:chef_version)

View File

@@ -0,0 +1,38 @@
#
# Cookbook Name:: ipfs
# Recipe:: _user
#
# The MIT License (MIT)
#
# Copyright:: 2018, Kosmos Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
group 'ipfs' do
gid 4737
end
user 'ipfs' do
comment 'ipfs'
uid 4737
gid 4737
home '/home/ipfs'
shell '/bin/bash'
manage_home true
end

View File

@@ -0,0 +1,86 @@
#
# Cookbook Name:: ipfs
# Recipe:: default
#
# The MIT License (MIT)
#
# Copyright:: 2018, Kosmos Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
include_recipe 'ipfs::_user'
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
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
node['ipfs']['config'].each do |k, v|
ipfs_config k do
value v
end
end

View File

@@ -0,0 +1,26 @@
require 'json'
require 'mixlib/shellout'
property :key, String, name_property: true
property :value, [String, Hash, Array, TrueClass, FalseClass, Integer], required: true
action :create do
include_recipe 'ipfs'
execute "ipfs config --json #{new_resource.key} '#{JSON.generate(new_resource.value)}'" do
environment 'IPFS_PATH' => '/home/ipfs/.ipfs'
user 'ipfs'
not_if do
cmd = Mixlib::ShellOut.new('ipfs', 'config', new_resource.key,
user: 'ipfs',
env: { 'IPFS_PATH' => '/home/ipfs/.ipfs' })
cmd.run_command
begin
JSON.parse(cmd.stdout) == JSON.parse(JSON.generate(new_resource.value))
rescue JSON::ParserError
cmd.stdout.include?(new_resource.value.to_s)
end
end
notifies :restart, 'service[ipfs]', :delayed
end
end

View File

@@ -0,0 +1,3 @@
# frozen_string_literal: true
require 'chefspec'
require 'chefspec/berkshelf'

View File

@@ -0,0 +1,55 @@
#
# Cookbook:: ipfs
# Spec:: default
#
# The MIT License (MIT)
#
# Copyright:: 2018, Kosmos Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
require 'spec_helper'
describe 'ipfs::default' do
context 'When all attributes are default, on Ubuntu 16.04' do
let(:chef_run) do
# for a complete list of available platforms and versions see:
# https://github.com/customink/fauxhai/blob/master/PLATFORMS.md
runner = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04')
runner.converge(described_recipe)
end
it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
end
context 'When all attributes are default, on Ubuntu 18.04' do
let(:chef_run) do
# for a complete list of available platforms and versions see:
# https://github.com/customink/fauxhai/blob/master/PLATFORMS.md
runner = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '18.04')
runner.converge(described_recipe)
end
it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
end
end

View File

@@ -0,0 +1,102 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: ipfs daemon
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts the ipfs daemon
# Description: Starts the ipfs daemon using the start-stop-daemon
### END INIT INFO
# Author: Dylan Powers <dylan.kyle.powers@gmail.com
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
DESC="ipfs daemon"
NAME=ipfs
DAEMON=/usr/local/bin/ipfs
DAEMON_ARGS="daemon --mount --migrate"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
IPFS_PATH=/home/ipfs/.ipfs
IPFS_USER=ipfs
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start() {
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test >/dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \
--background --chuid $IPFS_USER --no-close \
--exec /usr/bin/env IPFS_PATH="$IPFS_PATH" $DAEMON 2>>$IPFS_PATH/daemon.log 1>/dev/null \
-- $DAEMON_ARGS \
|| return 2
}
#
# Function that stops the daemon/service
#
do_stop() {
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Delete the pid
rm -f $PIDFILE
return "$RETVAL"
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
restart)
do_stop
do_start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
exit 3
;;
esac

View File

@@ -0,0 +1,15 @@
[Unit]
Description=Start ipfs
[Service]
ExecStart=/usr/local/bin/ipfs daemon --migrate --routing=dhtclient
User=ipfs
Group=ipfs
Restart=always
# Raise the ulimit (max number of open files)
LimitNOFILE=<%= node['ipfs']['ulimit'] %>
# Limit the memory usage
MemoryMax=<%= node['ipfs']['memory_max'] %>
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,30 @@
I, [2018-08-10T16:28:48.996619 #26331] INFO -- Kitchen: -----> Starting Kitchen (v1.15.0)
E, [2018-08-10T16:28:48.997042 #26331] ERROR -- Kitchen: ------Exception-------
E, [2018-08-10T16:28:48.997089 #26331] ERROR -- Kitchen: Class: Kitchen::UserError
E, [2018-08-10T16:28:48.997122 #26331] ERROR -- Kitchen: Message: Kitchen YAML file /Users/kare/code/kosmos/cookbooks/ipfs/test/integration/data_bags/.kitchen.yml does not exist.
E, [2018-08-10T16:28:48.997151 #26331] ERROR -- Kitchen: ----------------------
E, [2018-08-10T16:28:48.997178 #26331] ERROR -- Kitchen: ------Backtrace-------
E, [2018-08-10T16:28:48.997205 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/loader/yaml.rb:71:in `read'
E, [2018-08-10T16:28:48.997239 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/config.rb:152:in `data'
E, [2018-08-10T16:28:48.997266 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/config.rb:131:in `suites'
E, [2018-08-10T16:28:48.997294 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/config.rb:182:in `filter_instances'
E, [2018-08-10T16:28:48.997321 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/config.rb:141:in `build_instances'
E, [2018-08-10T16:28:48.997347 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/config.rb:117:in `instances'
E, [2018-08-10T16:28:48.997374 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/command.rb:112:in `filtered_instances'
E, [2018-08-10T16:28:48.997402 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/command.rb:142:in `parse_subcommand'
E, [2018-08-10T16:28:48.997431 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/command/action.rb:35:in `block in call'
E, [2018-08-10T16:28:48.997459 #26331] ERROR -- Kitchen: /Users/kare/.rubies/ruby-2.4.2/lib/ruby/2.4.0/benchmark.rb:293:in `measure'
E, [2018-08-10T16:28:48.997515 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/command/action.rb:34:in `call'
E, [2018-08-10T16:28:48.997566 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/cli.rb:53:in `perform'
E, [2018-08-10T16:28:48.997600 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/cli.rb:187:in `block (2 levels) in <class:CLI>'
E, [2018-08-10T16:28:48.997631 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
E, [2018-08-10T16:28:48.997666 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
E, [2018-08-10T16:28:48.997696 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/cli.rb:334:in `invoke_task'
E, [2018-08-10T16:28:48.997726 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
E, [2018-08-10T16:28:48.997766 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
E, [2018-08-10T16:28:48.997796 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/bin/kitchen:13:in `block in <top (required)>'
E, [2018-08-10T16:28:48.997826 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/errors.rb:171:in `with_friendly_errors'
E, [2018-08-10T16:28:48.997855 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/bin/kitchen:13:in `<top (required)>'
E, [2018-08-10T16:28:48.997882 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/bin/kitchen:23:in `load'
E, [2018-08-10T16:28:48.997918 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/bin/kitchen:23:in `<main>'
E, [2018-08-10T16:28:48.997949 #26331] ERROR -- Kitchen: ----End Backtrace-----

View File

@@ -0,0 +1,58 @@
require 'serverspec'
require 'json'
# Required by serverspec
set :backend, :exec
describe 'IPFS' do
# It is in the PATH
describe command('which ipfs') do
its(:exit_status) { should eq 0 }
end
it 'is listening on port 4001' do
expect(port(4001)).to be_listening
end
it 'is listening on port 8080 (gateway)' do
expect(port(8080)).to be_listening
end
it 'has a running service of ipfs' do
expect(service('ipfs')).to be_running
expect(service('ipfs')).to be_enabled
end
addr_filters = <<-EOF
[
"/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"
]
EOF
{
'Swarm.AddrFilters' => addr_filters.rstrip,
'Swarm.DisableBandwidthMetrics' => true,
'Swarm.DisableRelay' => true,
'Swarm.ConnMgr.HighWater' => 10,
'Swarm.ConnMgr.LowWater' => 1,
}.each do |k, v|
describe command("IPFS_PATH=/home/ipfs/.ipfs ipfs config '#{k}'") do
let(:sudo_options) { '-u ipfs -i' }
its(:stdout) { should eq "#{v}\n" }
end
end
end