infrataster-plugin-ftp 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ffcf5b9c72cc6731ef714b4fab74c8e722891eba1b22060cc9ffb57491937171
4
+ data.tar.gz: b72e46c6df7ae55c72be93906ebc5e3fa93678f1b6fe30144a509298b0be244a
5
+ SHA512:
6
+ metadata.gz: 5b8181ce237dbe42b2dcd411638162223f96a57526cc99fc0a65c6aba2b48819453d2e87741d7f17d0b8a3e2478c9bf5fd571364e0cff520596fa0b59be24621
7
+ data.tar.gz: fad8ce9ba70a69c1fc97a607b04f2679698a2792c6bf465ce26d7338cb4aa543ecf1ad45749cb1d7b2c266e14e4f3f0e4fecd9979ccfe3cca7fe6229167aa28e
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ vendor/
14
+ .envrc
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,20 @@
1
+ sudo: required
2
+ matrix:
3
+ include:
4
+ - name: "Ruby 2.5"
5
+ env: TEST_TARGET=rspec-ruby25
6
+ - name: "Ruby 2.4"
7
+ env: TEST_TARGET=rspec-ruby24
8
+ - name: "Ruby 2.3"
9
+ env: TEST_TARGET=rspec-ruby23
10
+ services:
11
+ - docker
12
+ before_install:
13
+ - docker-compose build ${TEST_TARGET}
14
+ - docker-compose up -d
15
+ install:
16
+ before_script:
17
+ script:
18
+ - docker-compose exec ${TEST_TARGET} rspec
19
+ after_script:
20
+ notifications:
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in infrataster-plugin-ftp.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,81 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ infrataster-plugin-ftp (0.0.2)
5
+ infrataster
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.5.2)
11
+ public_suffix (>= 2.0.2, < 4.0)
12
+ capybara (3.9.0)
13
+ addressable
14
+ mini_mime (>= 0.1.3)
15
+ nokogiri (~> 1.8)
16
+ rack (>= 1.6.0)
17
+ rack-test (>= 0.6.3)
18
+ xpath (~> 3.1)
19
+ cliver (0.3.2)
20
+ diff-lcs (1.3)
21
+ faraday (0.15.3)
22
+ multipart-post (>= 1.2, < 3)
23
+ faraday_middleware (0.12.2)
24
+ faraday (>= 0.7.4, < 1.0)
25
+ infrataster (0.3.2)
26
+ capybara
27
+ faraday
28
+ faraday_middleware (>= 0.10.0)
29
+ net-ssh
30
+ net-ssh-gateway
31
+ poltergeist
32
+ rspec (>= 2.0, < 4.0)
33
+ thor
34
+ mini_mime (1.0.1)
35
+ mini_portile2 (2.3.0)
36
+ multipart-post (2.0.0)
37
+ net-ssh (5.0.2)
38
+ net-ssh-gateway (2.0.0)
39
+ net-ssh (>= 4.0.0)
40
+ nokogiri (1.8.5)
41
+ mini_portile2 (~> 2.3.0)
42
+ poltergeist (1.18.1)
43
+ capybara (>= 2.1, < 4)
44
+ cliver (~> 0.3.1)
45
+ websocket-driver (>= 0.2.0)
46
+ public_suffix (3.0.3)
47
+ rack (2.0.5)
48
+ rack-test (1.1.0)
49
+ rack (>= 1.0, < 3)
50
+ rake (10.5.0)
51
+ rspec (3.8.0)
52
+ rspec-core (~> 3.8.0)
53
+ rspec-expectations (~> 3.8.0)
54
+ rspec-mocks (~> 3.8.0)
55
+ rspec-core (3.8.0)
56
+ rspec-support (~> 3.8.0)
57
+ rspec-expectations (3.8.2)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.8.0)
60
+ rspec-mocks (3.8.0)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.8.0)
63
+ rspec-support (3.8.0)
64
+ thor (0.20.0)
65
+ websocket-driver (0.7.0)
66
+ websocket-extensions (>= 0.1.0)
67
+ websocket-extensions (0.1.3)
68
+ xpath (3.2.0)
69
+ nokogiri (~> 1.8)
70
+
71
+ PLATFORMS
72
+ ruby
73
+
74
+ DEPENDENCIES
75
+ bundler (~> 1.16)
76
+ infrataster-plugin-ftp!
77
+ rake (~> 10.0)
78
+ rspec (~> 3.0)
79
+
80
+ BUNDLED WITH
81
+ 1.16.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Infrataster::Plugin::Ftp
2
+ [![Build Status](https://travis-ci.org/inokappa/infrataster-plugin-ftp.svg?branch=master)](https://travis-ci.org/inokappa/infrataster-plugin-ftp)
3
+
4
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/infrataster/plugin/ftp`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'infrataster-plugin-ftp'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install infrataster-plugin-ftp
21
+
22
+ ## Usage
23
+
24
+ TODO: Write usage instructions here
25
+
26
+ ## Development
27
+
28
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
+
30
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
31
+
32
+ ## Contributing
33
+
34
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/infrataster-plugin-ftp.
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "infrataster/plugin/ftp"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,67 @@
1
+ version: '2'
2
+ services:
3
+ vsftpd-server:
4
+ build: ./spec/docker/vsftpd
5
+ container_name: vsftpd-server
6
+ environment:
7
+ - FTP_USER=ftpuser
8
+ - FTP_PASS=supersecret
9
+ - ONLY_UPLOAD=NO
10
+ - PASV_ENABLE=YES
11
+ - PASV_ADDRESS=192.168.0.6
12
+ - PASV_MIN=21200
13
+ - PASV_MAX=21210
14
+ ports:
15
+ - "21:21"
16
+ - "21200-21210:21200-21210"
17
+ networks:
18
+ my_net:
19
+ ipv4_address: 192.168.0.6
20
+ rspec-ruby25:
21
+ image: ruby:latest
22
+ build: ./spec/docker/rspec
23
+ container_name: rspec-ruby25
24
+ volumes:
25
+ - .:/work
26
+ command: tail -f /dev/null
27
+ networks:
28
+ my_net:
29
+ ipv4_address: 192.168.0.5
30
+ rspec-ruby24:
31
+ image: ruby:2.4
32
+ build: ./spec/docker/rspec
33
+ container_name: rspec-ruby24
34
+ volumes:
35
+ - .:/work
36
+ command: tail -f /dev/null
37
+ networks:
38
+ my_net:
39
+ ipv4_address: 192.168.0.4
40
+ rspec-ruby23:
41
+ image: ruby:2.3
42
+ build: ./spec/docker/rspec
43
+ container_name: rspec-ruby23
44
+ volumes:
45
+ - .:/work
46
+ command: tail -f /dev/null
47
+ networks:
48
+ my_net:
49
+ ipv4_address: 192.168.0.3
50
+ # ftp-client:
51
+ # image: ftp
52
+ # container_name: ftp-client
53
+ # working_dir: /work
54
+ # volumes:
55
+ # - .:/work
56
+ # command: tail -f /dev/null
57
+ # networks:
58
+ # my_net:
59
+ # ipv4_address: 192.168.0.2
60
+ networks:
61
+ my_net:
62
+ driver: bridge
63
+ ipam:
64
+ driver: default
65
+ config:
66
+ - subnet: 192.168.0.0/16
67
+ gateway: 192.168.0.1
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "infrataster/plugin/ftp/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "infrataster-plugin-ftp"
8
+ spec.version = Infrataster::Plugin::Ftp::VERSION
9
+ spec.authors = ["Yohei Kawahara"]
10
+ spec.email = ["inokara@gmail.com"]
11
+
12
+ spec.summary = %q{FTP Plugin for Infrataster.}
13
+ spec.description = %q{FTP Plugin for Infrataster.}
14
+ spec.homepage = "https://github.com/inokappa/infrataster-plugin-ftp"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_runtime_dependency 'infrataster'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ end
@@ -0,0 +1,3 @@
1
+ require 'infrataster/resources/ftp_resource'
2
+ require 'infrataster/helpers/ftp_helper'
3
+ require 'infrataster/contexts/ftp_context'
@@ -0,0 +1,32 @@
1
+ require 'infrataster'
2
+ require 'net/ftp'
3
+
4
+ module Infrataster
5
+ module Contexts
6
+ # FTP Context
7
+ class FtpContext < BaseContext
8
+ def result
9
+ options = {}
10
+ if server.options[:ftp]
11
+ options = options.merge(server.options[:ftp])
12
+ end
13
+
14
+ resource.ftp = Net::FTP.open(server.address,
15
+ user = options[:user],
16
+ pass = options[:pass],
17
+ acct = nil)
18
+
19
+ command, argument = resource.command.split
20
+
21
+ response = ''
22
+ if resource.ftp.respond_to?(command)
23
+ response = resource.ftp.method(command).call if argument.nil?
24
+ response = resource.ftp.method(command).call(argument) if argument
25
+ resource.ftp.method('close').call
26
+ end
27
+ return response.join if response.is_a?(Array)
28
+ response
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,12 @@
1
+ require 'rspec'
2
+ require 'infrataster/resources'
3
+
4
+ module Infrataster
5
+ module Helpers
6
+ module ResourceHelper
7
+ def ftp(*args)
8
+ Resources::FtpResource.new(*args)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ require "infrataster/plugin/ftp/version"
2
+
3
+ module Infrataster
4
+ module Plugin
5
+ module Ftp
6
+ # Your code goes here...
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module Infrataster
2
+ module Plugin
3
+ module Ftp
4
+ VERSION = "0.0.2"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ require 'infrataster'
2
+ require 'net/ftp'
3
+
4
+ module Infrataster
5
+ module Resources
6
+ class FtpResource < BaseResource
7
+ Error = Class.new(StandardError)
8
+
9
+ attr_reader :command
10
+ attr_accessor :ftp
11
+
12
+ def initialize(command)
13
+ @command = command
14
+ @ftp = nil
15
+ end
16
+
17
+ def to_s
18
+ "ftp:"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,4 @@
1
+ FROM ruby:latest
2
+ WORKDIR /work
3
+ ADD ./ /work
4
+ RUN bundle install
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ gem "infrataster"
@@ -0,0 +1,43 @@
1
+ ############################################################
2
+ # Dockerfile to build a simple vsFTPd server for the eBioKit
3
+ # Based on alpine linux
4
+ # Version 0.1 October 2017
5
+ ############################################################
6
+
7
+ FROM alpine
8
+
9
+ # File Author / Maintainer
10
+ MAINTAINER Rafael Hernandez <https://github.com/fikipollo>
11
+
12
+ ENV FTP_USER=ftpuser \
13
+ FTP_PASS=supersecret \
14
+ FTP_HOME=default \
15
+ FTP_UID=1000 \
16
+ ONLY_UPLOAD=NO \
17
+ ONLY_DOWNLOAD=NO \
18
+ PASV_ENABLE=NO \
19
+ PASV_ADDRESS=yourserveradress.com \
20
+ PASV_MIN=21100 \
21
+ PASV_MIN=21100 \
22
+ UMASK=022
23
+
24
+ COPY configs/entrypoint.sh /usr/sbin/
25
+
26
+ RUN apk update && apk upgrade && apk --update --no-cache add vsftpd
27
+
28
+ RUN echo "local_enable=YES" >> /etc/vsftpd/vsftpd.conf \
29
+ && echo "chroot_local_user=YES" >> /etc/vsftpd/vsftpd.conf \
30
+ && echo "allow_writeable_chroot=YES" >> /etc/vsftpd/vsftpd.conf \
31
+ && echo "background=NO" >> /etc/vsftpd/vsftpd.conf \
32
+ && echo "dirmessage_enable=YES" >> /etc/vsftpd/vsftpd.conf \
33
+ && echo "max_clients=10" >> /etc/vsftpd/vsftpd.conf \
34
+ && echo "max_per_ip=5" >> /etc/vsftpd/vsftpd.conf \
35
+ && echo "write_enable=YES" >> /etc/vsftpd/vsftpd.conf \
36
+ && echo "passwd_chroot_enable=yes" >> /etc/vsftpd/vsftpd.conf \
37
+ && echo "listen_ipv6=NO" >> /etc/vsftpd/vsftpd.conf \
38
+ && echo "seccomp_sandbox=NO" >> /etc/vsftpd/vsftpd.conf \
39
+ && sed -i "s/anonymous_enable=YES/anonymous_enable=NO/" /etc/vsftpd/vsftpd.conf \
40
+ && cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf_or \
41
+ && chmod +x /usr/sbin/entrypoint.sh
42
+
43
+ CMD /usr/sbin/entrypoint.sh
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 The SGBC - eBioKit team <https://github.com/eBioKit>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,74 @@
1
+ vsFTPd server docker
2
+ ===================
3
+
4
+ This docker image extends and distributes the following software:
5
+
6
+ #### vsFTPd
7
+
8
+ - Based on [vsftpd project](https://security.appspot.com/vsftpd.html).
9
+
10
+ # Build the image
11
+ The docker image for vsFTPd can be found in the [docker hub](https://hub.docker.com/r/fikipollo/vsftpd/). However, you can rebuild is manually by running **docker build**.
12
+
13
+ ```sh
14
+ sudo docker build -t vsftpd .
15
+ ```
16
+ Note that the current working directory must contain the Dockerfile file.
17
+
18
+ ## Running the Container
19
+ The recommended way for running your vsFTPd docker is using the provided **docker-compose** script that resolves the dependencies and make easier to customize your instance. Alternatively you can run the docker manually.
20
+
21
+ ## Quickstart
22
+
23
+ This procedure starts vsFTPd in a standard virtualised environment.
24
+
25
+ - Install [docker](https://docs.docker.com/engine/installation/) for your system if not previously done.
26
+ - `docker run -it -p 21:21 fikipollo/vsftpd`
27
+ - vsFTPd will be available at [ftp://localhost:21/](ftp://localhost:21/)
28
+
29
+ ## Using the docker-compose file
30
+ Launching your vsFTPd docker is really easy using docker-compose. Just download the *docker-compose.yml* file and customize the content according to your needs. There are few settings that should be change in the file, follow the instructions in the file to configure your container.
31
+ To launch the container, type:
32
+ ```sh
33
+ sudo docker-compose up
34
+ ```
35
+ Using the *-d* flag you can launch the containers in background.
36
+
37
+ In case you do not have the Container stored locally, docker will download it for you.
38
+
39
+ # Install the image <a name="install" />
40
+ You can run manually your containers using the following commands:
41
+
42
+ ```sh
43
+ sudo docker run --name vsftpd -v /your/data/location/ftp-data:/home/ -e FTP_USER=myftpuser -e FTP_PASS=supersecret -p 8021:21 -d fikipollo/vsftpd
44
+ ```
45
+
46
+ In case you do not have the Container stored locally, docker will download it for you.
47
+
48
+ A short description of the parameters would be:
49
+ - `docker run` will run the container for you.
50
+
51
+ - `-p 8021:21` will make the port 21 (inside of the container) available on port 8021 on your host.
52
+ Inside the container a vsFTPd server is running on port 21 and that port can be bound to a local port on your host computer.
53
+
54
+ - `fikipollo/vsftpd` is the Image name, which can be found in the [docker hub](https://hub.docker.com/r/fikipollo/vsftpd/).
55
+
56
+ - `-d` will start the docker container in daemon mode.
57
+
58
+ - `-e VARIABLE_NAME=VALUE` changes the default value for a system variable.
59
+ The vsFTPd docker accepts the following variables that modify the behavior of the system in the docker. All variables are optional.
60
+
61
+ - **FTP_USER**, the name for the default ftp account. Default is _ftpuser_.
62
+ - **FTP_PASS**, the password for the default ftp account. Default is _supersecret_.
63
+ - **FTP_HOME**, the home directory for the default ftp account. Default value: _/home/$FTP_USER_.
64
+ - **FTP_UID**, the user and group id for the default ftp account. Default value: _1000_.
65
+ - **ONLY_UPLOAD**, set to _YES_ to disable data download. By default download is enabled (i.e. default value is _NO_).
66
+ - **PASV_ENABLE**, set to _YES_ to enable passive mode (PASV). By default PASV mode is disabled (i.e. default value is _NO_).
67
+ - **PASV_ADDRESS**, if PASV mode is enabled, you may need to specify the IP address (external) or the URL to your FTP server. Default value: _127.0.0.1_.
68
+ - **PASV_MIN**, the minimum port number used for PASV mode. Default value: _21200_.
69
+ - **PASV_MAX**, the maximum port number used for PASV mode. Default value: _21210_.
70
+
71
+ Note that if you enable PASV mode, the internal ports used for passive mode (i.e. ports PASV_MIN to PASV_MAX) should be mapped to external ports (same ports). For example, if PASV_MIN=21100 and PASV_MAX=21110, you should add the option _-p 21100-21110_.
72
+
73
+ # Version log
74
+ - v0.9 October 2017: First version of the docker.
@@ -0,0 +1,44 @@
1
+ #!/bin/sh
2
+
3
+ #CREATE THE USER AND THE HOME FOLDER
4
+ addgroup -g $FTP_UID -S $FTP_USER
5
+ if [[ "$FTP_HOME" != "default" ]]; then
6
+ adduser -u $FTP_UID -D -G $FTP_USER -h $FTP_HOME -s /bin/false $FTP_USER
7
+ touch $FTP_HOME/sample.txt
8
+ chown $FTP_USER:$FTP_USER $FTP_HOME -R
9
+ else
10
+ adduser -u $FTP_UID -D -G $FTP_USER -h /home/$FTP_USER -s /bin/false $FTP_USER
11
+ touch /home/$FTP_USER/sample.txt
12
+ chown $FTP_USER:$FTP_USER /home/$FTP_USER/ -R
13
+ fi
14
+
15
+ #UPDATE PASSWORD
16
+ echo "$FTP_USER:$FTP_PASS" | /usr/sbin/chpasswd
17
+
18
+ cp /etc/vsftpd/vsftpd.conf_or /etc/vsftpd/vsftpd.conf
19
+
20
+ if [[ "$PASV_ENABLE" == "YES" ]]; then
21
+ echo "PASV is enabled"
22
+ echo "pasv_enable=YES" >> /etc/vsftpd/vsftpd.conf
23
+ echo "pasv_max_port=$PASV_MAX" >> /etc/vsftpd/vsftpd.conf
24
+ echo "pasv_min_port=$PASV_MIN" >> /etc/vsftpd/vsftpd.conf
25
+ echo "pasv_address=$PASV_ADDRESS" >> /etc/vsftpd/vsftpd.conf
26
+ else
27
+ echo "pasv_enable=NO" >> /etc/vsftpd/vsftpd.conf
28
+ fi
29
+
30
+ if [[ "$ONLY_UPLOAD" == "YES" ]]; then
31
+ echo "This FTP server only accepts upload."
32
+ echo "download_enable=NO" >> /etc/vsftpd/vsftpd.conf
33
+ echo "ftpd_banner=Welcome to FTP Server. Note: this FTP server only accepts upload." >> /etc/vsftpd/vsftpd.conf
34
+ elif [[ "$ONLY_DOWNLOAD" == "YES" ]]; then
35
+ echo "This FTP server only accepts download."
36
+ echo "ftpd_banner=Welcome to FTP Server. Note: this FTP server only accepts download." >> /etc/vsftpd/vsftpd.conf
37
+ sed -i 's/write_enable=YES/write_enable=NO/g' /etc/vsftpd/vsftpd.conf
38
+ else
39
+ echo "ftpd_banner=Welcome to FTP Server" >> /etc/vsftpd/vsftpd.conf
40
+ fi
41
+
42
+ echo "local_umask=$UMASK" >> /etc/vsftpd/vsftpd.conf
43
+
44
+ /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
@@ -0,0 +1,23 @@
1
+ version: '2'
2
+ services:
3
+
4
+ instance1-vsftpd:
5
+ image: fikipollo/vsftpd
6
+ container_name: instance1-vsftpd
7
+ environment:
8
+ - FTP_USER=ftpuser
9
+ - FTP_PASS=supersecret
10
+ - ONLY_UPLOAD=NO
11
+ - PASV_ENABLE=NO
12
+ depends_on:
13
+ - instance1-vsftpd-data
14
+ volumes_from:
15
+ - instance1-vsftpd-data
16
+ ports:
17
+ - "8021:21"
18
+
19
+ instance1-vsftpd-data:
20
+ image: busybox
21
+ container_name: instance1-vsftpd-data
22
+ volumes:
23
+ - /home/foo/dockers/vsftpd/data:/home
@@ -0,0 +1,27 @@
1
+ version: '2'
2
+ services:
3
+
4
+ instance1-vsftpd:
5
+ image: fikipollo/vsftpd
6
+ container_name: instance1-vsftpd
7
+ environment:
8
+ - FTP_USER=ftpuser
9
+ - FTP_PASS=supersecret
10
+ - ONLY_UPLOAD=NO
11
+ - PASV_ENABLE=YES
12
+ - PASV_ADDRESS=127.0.0.1
13
+ - PASV_MIN=21200
14
+ - PASV_MAX=21210
15
+ depends_on:
16
+ - instance1-vsftpd-data
17
+ volumes_from:
18
+ - instance1-vsftpd-data
19
+ ports:
20
+ - "8021:21"
21
+ - "21200-21210:21200-21210"
22
+
23
+ instance1-vsftpd-data:
24
+ image: busybox
25
+ container_name: instance1-vsftpd-data
26
+ volumes:
27
+ - /home/foo/dockers/vsftpd/data:/home
@@ -0,0 +1,42 @@
1
+ ############################################################
2
+ # Launcher for vsFTPd container
3
+ # This is a template, the following values must be replaced:
4
+ # - $${INSTANCE_NAME}, name for the instance
5
+ # - $${FTP_USER}, name for FTP user
6
+ # - $${FTP_PASS}, password for FTP user
7
+ # - $${INSTANCE_PORT_1}, port number for FTP instance
8
+ # - $${ONLY_UPLOAD}, YES/NO. Defines if the users can download files from server.
9
+ # - $${PASV_ENABLE}, YES/NO for enabling/disabling PASV
10
+ # - $${PASV_ADDRESS}, URL for PASIVE MODE
11
+ # - $${PASV_MIN}, min port number for PASIVE MODE
12
+ # - $${PASV_MAX}, max port number for PASIVE MODE
13
+ # - $${DATA_LOCATION}, location for the application data
14
+ ############################################################
15
+
16
+ version: '2'
17
+ services:
18
+
19
+ $${INSTANCE_NAME}-vsftpd:
20
+ image: fikipollo/vsftpd
21
+ container_name: $${INSTANCE_NAME}-vsftpd
22
+ environment:
23
+ - FTP_USER=$${FTP_USER}
24
+ - FTP_PASS=$${FTP_PASS}
25
+ - ONLY_UPLOAD=$${ONLY_UPLOAD}
26
+ - PASV_ENABLE=$${PASV_ENABLE}
27
+ - PASV_ADDRESS=$${PASV_ADDRESS}
28
+ - PASV_MIN=$${PASV_MIN}
29
+ - PASV_MAX=$${PASV_MAX}
30
+ depends_on:
31
+ - $${INSTANCE_NAME}-vsftpd-data
32
+ volumes_from:
33
+ - $${INSTANCE_NAME}-vsftpd-data
34
+ ports:
35
+ - "$${INSTANCE_PORT_1}:21"
36
+ - "$${PASV_MIN}-$${PASV_MAX}:$${PASV_MIN}-$${PASV_MAX}"
37
+
38
+ $${INSTANCE_NAME}-vsftpd-data:
39
+ image: busybox
40
+ container_name: $${INSTANCE_NAME}-vsftpd-data
41
+ volumes:
42
+ - $${DATA_LOCATION}/$${INSTANCE_NAME}-vsftpd/data:/home
@@ -0,0 +1,33 @@
1
+ # require "bundler/setup"
2
+ # require "infrataster/plugin/ftp"
3
+ #
4
+ # RSpec.configure do |config|
5
+ # # Enable flags like --only-failures and --next-failure
6
+ # config.example_status_persistence_file_path = ".rspec_status"
7
+ #
8
+ # # Disable RSpec exposing methods globally on `Module` and `main`
9
+ # config.disable_monkey_patching!
10
+ #
11
+ # config.expect_with :rspec do |c|
12
+ # c.syntax = :expect
13
+ # end
14
+ # end
15
+
16
+ require 'infrataster/rspec'
17
+ require 'infrataster-plugin-ftp'
18
+
19
+ Infrataster::Server.define(
20
+ :ftp_server,
21
+ '192.168.0.6',
22
+ ftp: { user: 'ftpuser', pass: 'supersecret', passive: true },
23
+ )
24
+
25
+ RSpec.configure do |config|
26
+ config.expect_with :rspec do |expectations|
27
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
28
+ end
29
+
30
+ config.mock_with :rspec do |mocks|
31
+ mocks.verify_partial_doubles = true
32
+ end
33
+ end
data/spec/test_spec.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe server(:ftp_server) do
4
+ describe ftp('welcome') do
5
+ it 'check accessible' do
6
+ expect(result.chomp).to eq('230 Login successful.')
7
+ end
8
+ end
9
+
10
+ describe ftp('pwd') do
11
+ it 'check `chroot` enabled' do
12
+ expect(result).to eq('/')
13
+ end
14
+ end
15
+
16
+ describe ftp('mkdir test_dir') do
17
+ it 'run `mkdir`' do
18
+ expect(result).to include '/test_dir'
19
+ end
20
+ end
21
+
22
+ describe ftp('ls') do
23
+ it 'run ls' do
24
+ expect(result).to include 'sample.txt'
25
+ end
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: infrataster-plugin-ftp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Yohei Kawahara
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-10-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: infrataster
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: FTP Plugin for Infrataster.
70
+ email:
71
+ - inokara@gmail.com
72
+ executables:
73
+ - console
74
+ - setup
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - Gemfile
82
+ - Gemfile.lock
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/setup
88
+ - docker-compose.yml
89
+ - infrataster-plugin-ftp.gemspec
90
+ - lib/infrataster-plugin-ftp.rb
91
+ - lib/infrataster/contexts/ftp_context.rb
92
+ - lib/infrataster/helpers/ftp_helper.rb
93
+ - lib/infrataster/plugin/ftp.rb
94
+ - lib/infrataster/plugin/ftp/version.rb
95
+ - lib/infrataster/resources/ftp_resource.rb
96
+ - spec/docker/rspec/Dockerfile
97
+ - spec/docker/rspec/Gemfile
98
+ - spec/docker/vsftpd/Dockerfile
99
+ - spec/docker/vsftpd/LICENSE
100
+ - spec/docker/vsftpd/README.md
101
+ - spec/docker/vsftpd/configs/entrypoint.sh
102
+ - spec/docker/vsftpd/docker-compose_no_pasv.yml
103
+ - spec/docker/vsftpd/docker-compose_pasv.yml
104
+ - spec/docker/vsftpd/docker-compose_template.yml
105
+ - spec/spec_helper.rb
106
+ - spec/test_spec.rb
107
+ homepage: https://github.com/inokappa/infrataster-plugin-ftp
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.7.6
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: FTP Plugin for Infrataster.
131
+ test_files:
132
+ - spec/docker/rspec/Dockerfile
133
+ - spec/docker/rspec/Gemfile
134
+ - spec/docker/vsftpd/Dockerfile
135
+ - spec/docker/vsftpd/LICENSE
136
+ - spec/docker/vsftpd/README.md
137
+ - spec/docker/vsftpd/configs/entrypoint.sh
138
+ - spec/docker/vsftpd/docker-compose_no_pasv.yml
139
+ - spec/docker/vsftpd/docker-compose_pasv.yml
140
+ - spec/docker/vsftpd/docker-compose_template.yml
141
+ - spec/spec_helper.rb
142
+ - spec/test_spec.rb