Compare commits

...

44 Commits

Author SHA1 Message Date
c1c08b1ced
Bump version 2022-05-12 17:02:27 +02:00
8f3b79d7f0
Remove superfluous license headers 2022-05-12 17:02:17 +02:00
ee0c6f7de0
Upgrade go-ipfs 2022-05-12 17:02:01 +02:00
d7c25b6ce5 Merge pull request 'Update go-ipfs to 0.7.0' (#4) from chore/update_go_ipfs into master
Reviewed-on: #4
2020-10-25 11:04:21 +00:00
9f430fa6d2
Bump cookbook version 2020-10-25 11:25:48 +01:00
05a04ac832
Update go-ipfs to 0.7 2020-10-25 11:18:25 +01:00
2dfbc073ed
Merge pull request #16 from 67P/bugfix/14-restart_on_update
Restart the service on update
2019-08-14 19:01:33 +02:00
e2c00c2afb
Merge pull request #15 from 67P/bugfix/specs
Fix the specs
2019-08-14 18:59:32 +02:00
Greg Karékinian
b3b03a9744 Remove Ubuntu 16.04 from the Travis matrix 2019-08-14 17:10:14 +02:00
Greg Karékinian
d845e3443a Add the CHEF_LICENSE environment variable again 2019-08-14 17:07:30 +02:00
Greg Karékinian
ae5a27d100 Fix a linting error 2019-08-14 17:05:39 +02:00
Greg Karékinian
200552d1b7 Restart the service on update
A restart notification on the service was missing on the ark resource
that takes care of downloading and installing/updating go-ipfs

Fixes #14
2019-08-14 17:02:20 +02:00
Greg Karékinian
856b48d015 Fix the specs not being seen on Travis 2019-08-14 16:49:16 +02:00
Greg Karékinian
9fd88a7da3 Accept the Chef license as part of the config files 2019-08-14 16:47:41 +02:00
Greg Karékinian
2552847d7e Remove the deleted cluster specs from the kitchen config files 2019-08-14 16:38:30 +02:00
Greg Karékinian
b6028ffff8 Do not run specs on Ubuntu 16.04 2019-08-14 16:38:30 +02:00
Greg Karékinian
f25802a6ce Fix the checks for the default config in the integration specs 2019-08-14 16:33:03 +02:00
5c31191ff8
Merge pull request #12 from 67P/feature/go-ipfs_0.4.22
Update go-ipfs to 0.4.22
2019-08-14 11:32:43 +02:00
Greg Karékinian
7dc20eea12 Update go-ipfs to 0.4.22
https://blog.ipfs.io/054-go-ipfs-0.4.22

Closes #11
2019-08-14 11:27:17 +02:00
Greg Karékinian
1d09c15108 Fix Markdown line break 2019-07-05 16:01:24 +02:00
Greg Karékinian
79a12165a2 Update the README 2019-07-05 15:59:53 +02:00
0c6416f9c7
Merge pull request #10 from 67P/feature/better_config
Improve the default config
2019-07-05 15:56:11 +02:00
Greg Karékinian
7b524204c8 Update the README for the changes to the config attribute 2019-07-05 15:50:30 +02:00
Greg Karékinian
f118a954fa Another linting fix 2019-07-05 15:46:22 +02:00
Greg Karékinian
468b6d9a9d Fix the linting warnings 2019-07-05 15:42:13 +02:00
Greg Karékinian
679f78d248 Bump the cookbook version
Co-authored-by: Sebastian Kippe <sebastian@kip.pe>
2019-07-05 15:29:13 +02:00
Greg Karékinian
9cdbf6d947 Use the new attributes for ulimit and max memory
Co-authored-by: Sebastian Kippe <sebastian@kip.pe>
2019-07-05 15:29:08 +02:00
Greg Karékinian
0e6ac38434 Improve the default config
Enable CORS and writeable gateway by default, remove config that only
applies to Kosmos

Co-authored-by: Sebastian Kippe <sebastian@kip.pe>
2019-07-05 15:29:02 +02:00
Greg Karékinian
d54e962926 Get rid of the cluster recipes and tests
Co-authored-by: Sebastian Kippe <sebastian@kip.pe>
2019-07-05 15:28:54 +02:00
Greg Karékinian
95e92a0703 Bump the ipfs version, remove the ipfs-cluster attributes
Co-authored-by: Sebastian Kippe <sebastian@kip.pe>
2019-07-05 15:28:12 +02:00
3d4e9cceea
Merge pull request #7 from 67P/feature/5-default_config_attributes
Move the default config to a Chef attribute
2019-06-25 15:47:03 +02:00
Greg Karékinian
cfa3435c40 Fix the indentation of an EOF in the integration tests 2019-06-20 19:10:29 +02:00
Greg Karékinian
01c2246454 Bump the cookbook version 2019-06-20 18:22:57 +02:00
Greg Karékinian
b2c7416087 Merge branch 'master' into feature/5-default_config_attributes 2019-06-20 18:22:44 +02:00
Greg Karékinian
6d31746a87
Merge pull request #8 from 67P/feature/cluster_checksums
Add the checksums for the cluster packages
2019-06-20 18:20:26 +02:00
Greg Karékinian
18d04d68fd Accept the Chef license agreement on Travis
Based on
c3eaf7eac2/.travis.yml
2019-06-20 18:08:24 +02:00
Greg Karékinian
ddad121924 Add the checksums for the cluster packages
It prevents Chef from trying to download the packages again if the files
are already present with the correct checksum
2019-06-20 13:00:08 +02:00
Greg Karékinian
ae97c0d739 Fix the linting errors 2019-05-09 19:29:38 +02:00
Greg Karékinian
553ec510eb Move the default config to a Chef attribute
This is tested by serverspec integration test

Closes #5
2019-05-09 18:38:56 +02:00
c6a0159e82
Merge pull request #4 from 67P/feature/reduce_memory_usage
Reduce the memory usage of go-ipfs
2019-05-07 15:21:08 +02:00
Greg Karékinian
5aa50ecc7e Fix the ipfs_config resource to handle integers too 2019-05-07 14:55:41 +02:00
Greg Karékinian
f22b7d9b1f Update the Berksfile.lock file 2019-05-07 14:55:29 +02:00
Greg Karékinian
5303612854 Turn integers into strings for now 2019-05-07 14:41:06 +02:00
Greg Karékinian
76d60b87dd Reduce the memory usage of go-ipfs
Lower the number of connections, change the routing mode to dhtclient,
and disable bandwidth metrics. This is hardcoded for now
2019-05-07 14:30:29 +02:00
20 changed files with 92 additions and 434 deletions

View File

@ -13,12 +13,10 @@ provisioner:
verifier:
name: inspec
root_path: '/opt/verifier' # Needed for the specs to be detected in Docker
chef_license: accept
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
@ -33,8 +31,3 @@ suites:
run_list:
- recipe[ipfs::default]
attributes:
- name: cluster
run_list:
- recipe[ipfs::cluster]
- recipe[ipfs::cluster_service]
attributes:

View File

@ -6,17 +6,14 @@ provisioner:
name: chef_zero
platforms:
- name: ubuntu-16.04
- name: ubuntu-18.04
- name: debian-9
verifier:
chef_license: accept
suites:
- name: default
run_list:
- recipe[ipfs::default]
attributes:
- name: cluster
run_list:
- recipe[ipfs::cluster]
- recipe[ipfs::cluster_service]
attributes:

View File

@ -20,20 +20,19 @@ 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 --version
- CHEF_LICENSE=accept-no-persist chef --version
- cookstyle --version
- foodcritic --version
script: KITCHEN_LOCAL_YAML=.kitchen.dokken.yml CHEF_VERSION=13.10.4 kitchen verify ${INSTANCE}
script: CHEF_LICENSE=accept-no-persist KITCHEN_LOCAL_YAML=.kitchen.dokken.yml kitchen test ${INSTANCE}
matrix:
include:
- script:
- chef exec delivery local all
- CHEF_LICENSE=accept-no-persist chef exec delivery local all
env: UNIT_AND_LINT=1

View File

@ -10,7 +10,7 @@ GRAPH
build-essential (8.1.1)
mingw (>= 1.1)
seven_zip (>= 0.0.0)
ipfs (0.1.0)
ipfs (0.4.2)
ark (>= 0.0.0)
mingw (2.1.0)
seven_zip (>= 0.0.0)

View File

@ -1,23 +1,23 @@
# ipfs Cookbook
# IPFS Cookbook
This cookbook installs ipfs and starts it as a daemon
This cookbook installs go-ipfs and starts it as a daemon
## Requirements
### Platforms
This cookbook is tested on Ubuntu 16.06, 14.04 and Debian 8 using Test Kitchen.
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 (we are providing a
- Chef 12.5 or later (the cookbook provides a
[Custom Resource](https://docs.chef.io/custom_resources.html) to configure
IPFS)
go-ipfs)
### Cookbook dependencies
- `ark` to download and uncompress the Go IPFS package
- `ark` to download and uncompress the go-ipfs package
## Usage
@ -36,12 +36,10 @@ Just include `ipfs` in your node's `run_list`:
## Attributes
- `node.['ipfs']['version']` - the Go IPFS version to download from the official
- `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']['swarm']['addr_filter']` - the network ranges to not
connect to. This will stop platforms like Hetzner to block your server
(https://github.com/ipfs/go-ipfs/issues/1226)
- `node['ipfs']['config']` - a hash of config options
## Resources
@ -66,8 +64,8 @@ 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, [Kosmos Developers](https://kredits.kosmos.org/)
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

View File

@ -1,7 +1,31 @@
node.default['ipfs']['version'] = '0.4.17'
node.default['ipfs']['checksum'] = '1bb1050ebe74f9042ac721eb1b71f92e1b0e78e54c59dadfde13080facb2901c'
# 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']['version'] = '0.12.2'
node.default['ipfs']['checksum'] = 'd1b376fe1fb081631af773ea05632090dd79ae5a0057f8b8a0202c28b64a966d14bbfde768ce5a993745761ce56ceed6323a6bd1714f9ae71fa4d68fcbeb1dbb'
node.default['ipfs']['cluster']['version'] = '0.4.0'
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

@ -2,9 +2,9 @@ name 'ipfs'
maintainer 'Kosmos Developers'
maintainer_email 'mail@kosmos.org'
license 'MIT'
description 'Installs/Configures ipfs'
description 'Installs/Configures go-ipfs'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.3'
version '0.8.0'
supports %w(ubuntu debian)

View File

@ -2,27 +2,6 @@
# 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

View File

@ -1,48 +0,0 @@
#
# Cookbook Name:: ipfs
# Recipe:: cluster
#
# 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']['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

View File

@ -1,33 +0,0 @@
#
# Cookbook Name:: ipfs
# Recipe:: cluster_bootstrap
#
# 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'
execute "ipfs-cluster-service daemon --bootstrap #{peer}" do
user 'ipfs'
environment 'IPFS_CLUSTER_PATH' => '/home/ipfs/.ipfs-cluster'
not_if { File.exist? '/home/ipfs/.ipfs-cluster/service.json' }
end

View File

@ -1,64 +0,0 @@
#
# Cookbook Name:: ipfs
# Recipe:: cluster_service
#
# 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.
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

View File

@ -2,27 +2,6 @@
# 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'
@ -32,6 +11,7 @@ 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']
notifies :restart, 'service[ipfs]', :delayed
end
execute 'ipfs init --empty-repo' do
@ -79,7 +59,8 @@ else
end
end
# Configure ipfs to not contact local network addresses
ipfs_config 'Swarm.AddrFilters' do
value node['ipfs']['config']['swarm']['addr_filter']
node['ipfs']['config'].each do |k, v|
ipfs_config k do
value v
end
end

View File

@ -2,7 +2,7 @@ require 'json'
require 'mixlib/shellout'
property :key, String, name_property: true
property :value, [String, Hash, Array, TrueClass, FalseClass], required: true
property :value, [String, Hash, Array, TrueClass, FalseClass, Integer], required: true
action :create do
include_recipe 'ipfs'

View File

@ -1,55 +0,0 @@
#
# 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::cluster_service' 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 'enables the service' do
expect(chef_run).to enable_service('ipfs-cluster')
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 'enables the service' do
expect(chef_run).to enable_service('ipfs-cluster')
end
end
end

View File

@ -1,102 +0,0 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: ipfs-cluster 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-cluster daemon
# Description: Starts the ipfs-cluster 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-cluster daemon"
NAME=ipfs-cluster
DAEMON=/usr/local/bin/ipfs-cluster-service
DAEMON_ARGS="daemon --upgrade"
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

@ -1,13 +0,0 @@
[Unit]
Description=Start ipfs-cluster
[Service]
ExecStart=/usr/local/bin/ipfs-cluster-service daemon --upgrade
User=ipfs
Group=ipfs
Restart=always
# Raise the ulimit (max number of open files)
LimitNOFILE=64000
[Install]
WantedBy=multi-user.target

View File

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

View File

@ -1,27 +0,0 @@
require 'serverspec'
# Required by serverspec
set :backend, :exec
describe 'ipfs-cluster-ctl' do
# It is in the PATH
describe command('which ipfs-cluster-ctl') do
its(:exit_status) { should eq 0 }
end
end
describe 'ipfs-cluster-service' do
# It is in the PATH
describe command('which ipfs-cluster-service') do
its(:exit_status) { should eq 0 }
end
it 'is listening on port 9096' do
expect(port(9096)).to be_listening
end
it 'runs the ipfs-cluster-service' do
expect(service('ipfs-cluster')).to be_running
expect(service('ipfs-cluster')).to be_enabled
end
end

View File

@ -1,4 +0,0 @@
{
"id": "ipfs_cluster",
"secret": "d9de2f31ca7e9989949010fed2e704f42b8e96fa1e8e60a0ad26611f0a01cf07"
}

View File

@ -1,4 +1,5 @@
require 'serverspec'
require 'json'
# Required by serverspec
set :backend, :exec
@ -21,4 +22,34 @@ describe '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,
'Gateway.Writable' => true,
}.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