cavalerie_web 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/Guardfile +77 -0
- data/LICENSE.txt +21 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/bin/cavalerie +5 -0
- data/cavalerie_web.gemspec +39 -0
- data/lib/cavalerie_web/checks/file_folder_check.rb +23 -0
- data/lib/cavalerie_web/checks/vagrant_check.rb +24 -0
- data/lib/cavalerie_web/cli/command.rb +37 -0
- data/lib/cavalerie_web/cli/subcommands/new.rb +13 -0
- data/lib/cavalerie_web/cli/subcommands/server.rb +23 -0
- data/lib/cavalerie_web/configs/VirtualHost.sample +8 -0
- data/lib/cavalerie_web/configs/apache_container_ip +1 -0
- data/lib/cavalerie_web/configs/config.rb +55 -0
- data/lib/cavalerie_web/configs/docker_configs.json +22 -0
- data/lib/cavalerie_web/configs/local-config.sample.php +15 -0
- data/lib/cavalerie_web/configs/mysql_container_ip +1 -0
- data/lib/cavalerie_web/configs/setup_status.default.json +13 -0
- data/lib/cavalerie_web/configs/setup_status.json +13 -0
- data/lib/cavalerie_web/errors/container_not_running_error.rb +2 -0
- data/lib/cavalerie_web/errors/logs_folder_not_found_error.rb +2 -0
- data/lib/cavalerie_web/errors/max_retries_reach_error.rb +2 -0
- data/lib/cavalerie_web/errors/required_folder_unavailable_error.rb +2 -0
- data/lib/cavalerie_web/errors/required_plugin_missing_error.rb +2 -0
- data/lib/cavalerie_web/errors/unable_to_access_hosts_file_on_windows_os_error.rb +2 -0
- data/lib/cavalerie_web/errors/unknown_docker_container_status_error.rb +2 -0
- data/lib/cavalerie_web/errors/vagrant_not_installed_error.rb +2 -0
- data/lib/cavalerie_web/errors/vagrant_vm_already_running_error.rb +2 -0
- data/lib/cavalerie_web/errors/vagrant_vm_not_running_error.rb +2 -0
- data/lib/cavalerie_web/errors/virtual_host_file_not_found_error.rb +2 -0
- data/lib/cavalerie_web/helpers/os_helper.rb +9 -0
- data/lib/cavalerie_web/helpers/vagrant_helper.rb +73 -0
- data/lib/cavalerie_web/managers/database_manager.rb +10 -0
- data/lib/cavalerie_web/managers/file_folder_manager.rb +99 -0
- data/lib/cavalerie_web/managers/sequence_manager.rb +97 -0
- data/lib/cavalerie_web/managers/site_manager.rb +37 -0
- data/lib/cavalerie_web/managers/vagrant_manager.rb +66 -0
- data/lib/cavalerie_web/sequences/base_sequence.rb +9 -0
- data/lib/cavalerie_web/sequences/cavalerie_destroy_sequence.rb +12 -0
- data/lib/cavalerie_web/sequences/cavalerie_init_sequence.rb +71 -0
- data/lib/cavalerie_web/sequences/cavalerie_refresh_sequence.rb +21 -0
- data/lib/cavalerie_web/sequences/cavalerie_status_sequence.rb +107 -0
- data/lib/cavalerie_web/sequences/cavalerie_up_sequence.rb +24 -0
- data/lib/cavalerie_web/sequences/ensure_setup_is_correct_sequence.rb +77 -0
- data/lib/cavalerie_web/ui/banner.rb +16 -0
- data/lib/cavalerie_web/ui/message.rb +23 -0
- data/lib/cavalerie_web.rb +37 -0
- data/lib/vagrant/DockerHost.Vagrantfile +31 -0
- data/lib/vagrant/Vagrantfile +74 -0
- data/lib/vagrant/scripts/new_website.rb +54 -0
- metadata +283 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 29a657fe6a1d7a824ca68d7c2f9727b69e76b3da
|
4
|
+
data.tar.gz: 72854351f19fbe74bf11254ac4be05563227c5d1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 94bdfd19e535a244ddc3a114c1a835f1358bb88e43fd6ac70d49e8091c08ee1b3da5cf1fb941f8ac155d8e43770968b95fe579cce1c70245a465192bb199e5bb
|
7
|
+
data.tar.gz: 8934f480efe3e21be7a9b071e009187c8349e78c0dd85985a028a57d5cf8ce9030799e7b99fd80087ef90ebb6e0b815ededcbdfc49471dfb8835594c20c84ba9
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.0
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(bin lib lib/cavalerie_web spec)
|
6
|
+
|
7
|
+
## Uncomment to clear the screen before every task
|
8
|
+
clearing :on
|
9
|
+
|
10
|
+
## Guard internally checks for changes in the Guardfile and exits.
|
11
|
+
## If you want Guard to automatically start up again, run guard in a
|
12
|
+
## shell loop, e.g.:
|
13
|
+
##
|
14
|
+
## $ while bundle exec guard; do echo "Restarting Guard..."; done
|
15
|
+
##
|
16
|
+
## Note: if you are using the `directories` clause above and you are not
|
17
|
+
## watching the project directory ('.'), then you will want to move
|
18
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
19
|
+
#
|
20
|
+
# $ mkdir config
|
21
|
+
# $ mv Guardfile config/
|
22
|
+
# $ ln -s config/Guardfile .
|
23
|
+
#
|
24
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
25
|
+
|
26
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
27
|
+
# rspec may be run, below are examples of the most common uses.
|
28
|
+
# * bundler: 'bundle exec rspec'
|
29
|
+
# * bundler binstubs: 'bin/rspec'
|
30
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
31
|
+
# installed the spring binstubs per the docs)
|
32
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
33
|
+
# * 'just' rspec: 'rspec'
|
34
|
+
|
35
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
36
|
+
require "guard/rspec/dsl"
|
37
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
38
|
+
|
39
|
+
# Feel free to open issues for suggestions and improvements
|
40
|
+
|
41
|
+
# RSpec files
|
42
|
+
rspec = dsl.rspec
|
43
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
44
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
45
|
+
watch(rspec.spec_files)
|
46
|
+
|
47
|
+
# Ruby files
|
48
|
+
ruby = dsl.ruby
|
49
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
50
|
+
|
51
|
+
# Rails files
|
52
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
53
|
+
dsl.watch_spec_files_for(rails.app_files)
|
54
|
+
dsl.watch_spec_files_for(rails.views)
|
55
|
+
|
56
|
+
watch(rails.controllers) do |m|
|
57
|
+
[
|
58
|
+
rspec.spec.("routing/#{m[1]}_routing"),
|
59
|
+
rspec.spec.("controllers/#{m[1]}_controller"),
|
60
|
+
rspec.spec.("acceptance/#{m[1]}")
|
61
|
+
]
|
62
|
+
end
|
63
|
+
|
64
|
+
# Rails config changes
|
65
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
66
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
67
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
68
|
+
|
69
|
+
# Capybara features specs
|
70
|
+
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
|
71
|
+
|
72
|
+
# Turnip features and steps
|
73
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
74
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
75
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
76
|
+
end
|
77
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Arnaud Lenglet
|
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,36 @@
|
|
1
|
+
# Cavalerie Web Gem
|
2
|
+
|
3
|
+
[ ![Codeship Status for lacavalerie/cavalerie_web_gem](https://codeship.com/projects/7190ffb0-c0e1-0132-055e-6ae52d217161/status?branch=master)](https://codeship.com/projects/73341)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
In your Terminal, run the following commands:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
$ gem install cavalerie_web
|
11
|
+
|
12
|
+
$ cavalerie init
|
13
|
+
```
|
14
|
+
|
15
|
+
Then follow instructions to complete installation.
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Right after the installation is completed, you can run:
|
20
|
+
|
21
|
+
```bash
|
22
|
+
$ cavalerie up
|
23
|
+
```
|
24
|
+
|
25
|
+
This will power up a virtual machine inside VirtualBox, with:
|
26
|
+
- Apache2 web server
|
27
|
+
- MySQL server
|
28
|
+
- phpMyAdmin
|
29
|
+
|
30
|
+
At any time, to know the current status, you can run:
|
31
|
+
|
32
|
+
```bash
|
33
|
+
$ cavalerie status
|
34
|
+
```
|
35
|
+
|
36
|
+
To get help, feel free to run the command `cavalerie` without argument.
|
data/Rakefile
ADDED
data/bin/cavalerie
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "cavalerie_web"
|
7
|
+
spec.version = "1.0.0"
|
8
|
+
spec.authors = ["Arnaud Lenglet"]
|
9
|
+
spec.email = ["arlenglet@gmail.com"]
|
10
|
+
|
11
|
+
if spec.respond_to?(:metadata)
|
12
|
+
# spec.metadata['allowed_push_host'] = "http://mygemserver.com"
|
13
|
+
end
|
14
|
+
|
15
|
+
spec.summary = %q{La Cavalerie web toolbox}
|
16
|
+
spec.description = %q{Contain everything your need to create and manage websites}
|
17
|
+
spec.homepage = "https://bitbucket.org/lacavalerie/web_toolbox"
|
18
|
+
spec.license = "MIT"
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
spec.bindir = "bin"
|
22
|
+
spec.executables << "cavalerie"
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "thor", "~> 0.19"
|
26
|
+
spec.add_runtime_dependency "colorize", "~> 0.7"
|
27
|
+
spec.add_runtime_dependency "ghost", "~> 1.0"
|
28
|
+
spec.add_runtime_dependency "ptools", "~> 1.3"
|
29
|
+
spec.add_runtime_dependency "mysql2", "~> 0.3"
|
30
|
+
|
31
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
32
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
33
|
+
spec.add_development_dependency "rspec-core", '~> 3.2'
|
34
|
+
spec.add_development_dependency "rspec-mocks", "~> 3.2"
|
35
|
+
spec.add_development_dependency "rspec-expectations", '~> 3.2'
|
36
|
+
spec.add_development_dependency "rspec", '~> 3.2'
|
37
|
+
spec.add_development_dependency "guard", '~> 2.12'
|
38
|
+
spec.add_development_dependency "guard-rspec", '~> 4.5'
|
39
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module CavalerieWeb
|
2
|
+
|
3
|
+
class FileFolderCheck
|
4
|
+
|
5
|
+
def self.is_a_required_folder_unavailable?
|
6
|
+
unavailable_folders = []
|
7
|
+
|
8
|
+
Config.get_required_folders_list.each do |folder_name|
|
9
|
+
folder_path = get_folder_path folder_name
|
10
|
+
unavailable_folders << folder_path unless File.directory? folder_path
|
11
|
+
end
|
12
|
+
|
13
|
+
unavailable_folders unless unavailable_folders.empty?
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def self.get_folder_path folder_name
|
18
|
+
eval("$#{folder_name}_folder_path")
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'ptools'
|
2
|
+
|
3
|
+
module CavalerieWeb
|
4
|
+
|
5
|
+
class VagrantCheck
|
6
|
+
|
7
|
+
def self.is_vagrant_installed?
|
8
|
+
!File.which("vagrant").nil?
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.is_a_required_plugin_missing?
|
12
|
+
missing_plugins = []
|
13
|
+
|
14
|
+
installed_plugins = VagrantHelper.plugin_list
|
15
|
+
Config.get_required_plugins_list.each do |plugin|
|
16
|
+
missing_plugins << plugin unless installed_plugins.include? plugin
|
17
|
+
end
|
18
|
+
|
19
|
+
missing_plugins unless missing_plugins.empty?
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module CavalerieWeb::CLI
|
2
|
+
|
3
|
+
class Command < Thor
|
4
|
+
|
5
|
+
desc "up", "Kickoff everything! Initial checks, then Vagrant Up, followed by starting Apache/Mysql servers start inside docker containers"
|
6
|
+
def up
|
7
|
+
CavalerieWeb::Banner.cavalerie
|
8
|
+
CavalerieWeb::SequenceManager.start_sequence :cavalerie_up
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "refresh", "Update Hosts file + Apache VirtualHosts, useful after adding a new website"
|
12
|
+
def refresh
|
13
|
+
CavalerieWeb::Banner.cavalerie
|
14
|
+
CavalerieWeb::SequenceManager.start_sequence :cavalerie_refresh
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "status", "Status of Vagrant VM, Docker containers and sites"
|
18
|
+
def status
|
19
|
+
CavalerieWeb::Banner.cavalerie
|
20
|
+
CavalerieWeb::SequenceManager.start_sequence :cavalerie_status
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "destroy", "Stop Apache and MySQL server containers and poweroff virtual machine"
|
24
|
+
def destroy
|
25
|
+
CavalerieWeb::Banner.cavalerie
|
26
|
+
CavalerieWeb::SequenceManager.start_sequence :cavalerie_destroy
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "init", "Configure everything to be up and runnnig quicky"
|
30
|
+
def init
|
31
|
+
CavalerieWeb::Banner.cavalerie
|
32
|
+
CavalerieWeb::SequenceManager.start_sequence :cavalerie_init
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CavalerieWeb::CLI::Subcommand::New < Thor
|
2
|
+
|
3
|
+
desc "website", "Create a new empty website structure"
|
4
|
+
def website
|
5
|
+
p "Not implemented yet"
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "wordpress", "Same as website + install WordPress Skeleton"
|
9
|
+
def wordpress
|
10
|
+
p "Not implemented yet"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module CavalerieWeb::CLI::Subcommand
|
2
|
+
|
3
|
+
class Server < Thor
|
4
|
+
|
5
|
+
desc "start", "Run Docker containers"
|
6
|
+
def start
|
7
|
+
CavalerieWeb::SequenceManager.start_sequence :cavalerie_server_start
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "stop", "Stop Docker containers"
|
11
|
+
def stop
|
12
|
+
CavalerieWeb::SequenceManager.start_sequence :cavalerie_server_stop
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "restart", "Stop then start Docker containers"
|
16
|
+
def restart
|
17
|
+
CavalerieWeb::SequenceManager.start_sequence :cavalerie_server_start
|
18
|
+
CavalerieWeb::SequenceManager.start_sequence :cavalerie_server_stop
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<VirtualHost *:80>
|
2
|
+
ServerAdmin maintenance@agencecavalerie.com
|
3
|
+
DocumentRoot /var/www/_site_name_here_
|
4
|
+
ServerName _site_name_here_.dev
|
5
|
+
ServerAlias www._site_name_here_.dev
|
6
|
+
ErrorLog "/var/www/_site_name_here_/logs/dev-_site_name_here_-error_log"
|
7
|
+
CustomLog "/var/www/_site_name_here_/logs/dev-_site_name_here_-access_log" common
|
8
|
+
</VirtualHost>
|
@@ -0,0 +1 @@
|
|
1
|
+
172.17.0.5
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module CavalerieWeb
|
5
|
+
|
6
|
+
class Config
|
7
|
+
|
8
|
+
Thread.abort_on_exception = true
|
9
|
+
|
10
|
+
def self.get_environment_variables
|
11
|
+
{
|
12
|
+
sites: { name: "CAVALERIE_SITES_PATH", folder: "sites", description: "This is where your sites will live." },
|
13
|
+
shared: { name: "CAVALERIE_SHARED_PATH", folder: "shared", description: "This is the shared folder used by WordPress" },
|
14
|
+
mysql: { name: "CAVALERIE_MYSQL_PATH", folder: "mysql", description: "This is your main MySQL directory, used by MySQL server." },
|
15
|
+
export: { name: "CAVALERIE_EXPORT_PATH", folder: "export", description: <<-EOF
|
16
|
+
This folder will be use to share non-versionned stuff between mates, like DB dumps and assets.
|
17
|
+
This folder could be sync via rsync or Dropbox/Google Drive.
|
18
|
+
Use of NFS mount is discouraged since it could lead to stability issue
|
19
|
+
(in case of network error, when you work offline for example)."
|
20
|
+
EOF
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.get_required_plugins_list
|
26
|
+
["vagrant-hostmanager", "vagrant-share"]
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.get_required_folders_list
|
30
|
+
["sites", "shared", "mysql", "credentials", "samples", "db_dumps", "export"]
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.get_containers_names
|
34
|
+
get_docker_configs["containers_names"]
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.get_docker_configs
|
38
|
+
docker_configs_file = File.read "#{$configs_path}/docker_configs.json"
|
39
|
+
parsed = JSON.parse docker_configs_file
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.get_setup_status
|
43
|
+
setup_status_file = File.read "#{$configs_path}/setup_status.json"
|
44
|
+
parsed = JSON.parse setup_status_file
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.reset_setup_status
|
48
|
+
setup_status_file_default = "#{$configs_path}/setup_status.default.json"
|
49
|
+
setup_status_file = "#{$configs_path}/setup_status.json"
|
50
|
+
FileUtils.cp setup_status_file_default, setup_status_file
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// Variables used by Vagrantfiles to configure
|
2
|
+
// Docker containers and then completed by
|
3
|
+
// containers at runtime.
|
4
|
+
|
5
|
+
{
|
6
|
+
"containers_names": ["mysql-server", "apache-server", "phpmyadmin"],
|
7
|
+
|
8
|
+
"mysql-server_container_ip": "",
|
9
|
+
"mysql-server_user": "dev",
|
10
|
+
"mysql-server_user_password": "devpass",
|
11
|
+
"mysql-server_root_password": "cavalerie",
|
12
|
+
"mysql-server_os": "Ubuntu 4.8.2-19",
|
13
|
+
"mysql-server_version": "MySQL Community Server 5.6.24",
|
14
|
+
"mysql-server_post_start_script": false,
|
15
|
+
|
16
|
+
"apache-server_container_ip": "",
|
17
|
+
"apache-server_os": "Debian",
|
18
|
+
"apache-server_version": "Apache/2.2.22",
|
19
|
+
"apache-server_post_start_script": false,
|
20
|
+
|
21
|
+
"phpmyadmin_post_start_script": false
|
22
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
define( 'DB_NAME', '_db_name_here_' );
|
4
|
+
define( 'DB_USER', 'dev' );
|
5
|
+
define( 'DB_PASSWORD', 'cavalerie' );
|
6
|
+
define( 'DB_HOST', '_db_host_here_' );
|
7
|
+
|
8
|
+
define( 'AUTH_KEY', '_auth_key_here_' );
|
9
|
+
define( 'SECURE_AUTH_KEY', '_secure_auth_key_here_' );
|
10
|
+
define( 'LOGGED_IN_KEY', '_logged_in_key_here_' );
|
11
|
+
define( 'NONCE_KEY', '_nonce_key_here_' );
|
12
|
+
define( 'AUTH_SALT', '_auth_salt_here_' );
|
13
|
+
define( 'SECURE_AUTH_SALT', '_secure_auth_salt_here_' );
|
14
|
+
define( 'LOGGED_IN_SALT', '_logged_in_salt_here_' );
|
15
|
+
define( 'NONCE_SALT', '_nonce_salt_here_' );
|
@@ -0,0 +1 @@
|
|
1
|
+
172.17.0.1
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// File used to speed up EnsureSetupIsCorrectSequence
|
2
|
+
// When the sequence is successfully completed one,
|
3
|
+
// the result is written to this file.
|
4
|
+
// This allow us not to check for Vagrant + plugins
|
5
|
+
// installation every time we run a command.
|
6
|
+
//
|
7
|
+
// When an error is raised during a sequence, the values
|
8
|
+
// are reset to false
|
9
|
+
|
10
|
+
{
|
11
|
+
"is_vagrant_installed?": false,
|
12
|
+
"are_required_plugins_installed?": false
|
13
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// File used to speed up EnsureSetupIsCorrectSequence
|
2
|
+
// When the sequence is successfully completed one,
|
3
|
+
// the result is written to this file.
|
4
|
+
// This allow us not to check for Vagrant + plugins
|
5
|
+
// installation every time we run a command.
|
6
|
+
//
|
7
|
+
// When an error is raised during a sequence, the values
|
8
|
+
// are reset to false
|
9
|
+
|
10
|
+
{
|
11
|
+
"is_vagrant_installed?": false,
|
12
|
+
"are_required_plugins_installed?": false
|
13
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module CavalerieWeb
|
4
|
+
|
5
|
+
class VagrantHelper
|
6
|
+
|
7
|
+
def self.start_container container_name
|
8
|
+
puts Message.notice "Starting container \"#{container_name}\""
|
9
|
+
long_vagrant_command "vagrant up #{container_name}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.plugin_list
|
13
|
+
vagrant_command "vagrant plugin list"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.plugin_install plugin_name
|
17
|
+
vagrant_command "vagrant plugin install #{plugin_name}"
|
18
|
+
puts Message.success "Plugin \"#{plugin_name}\": installation completed."
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.destroy_container container_name
|
22
|
+
vagrant_command "vagrant destroy -f #{container_name}"
|
23
|
+
puts Message.notice "Container \"#{container_name}\" destroyed"
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.status container_name=nil
|
27
|
+
vagrant_command "vagrant status #{container_name}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.run_script container_name, script_path
|
31
|
+
puts Message.notice "Running script \"#{script_path}\" inside container \"#{container_name}\""
|
32
|
+
background_vagrant_command "vagrant docker-run -t #{container_name} -- /bin/bash -c #{script_path}"
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def self.move_to_vagrant_folder
|
38
|
+
vagrant_directory_path = "#{$gem_path}/lib/vagrant"
|
39
|
+
if Dir.pwd != vagrant_directory_path
|
40
|
+
Dir.chdir vagrant_directory_path
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.vagrant_command command
|
45
|
+
move_to_vagrant_folder
|
46
|
+
run_command command
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.background_vagrant_command command
|
50
|
+
move_to_vagrant_folder
|
51
|
+
run_background_command command
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.long_vagrant_command command
|
55
|
+
move_to_vagrant_folder
|
56
|
+
Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
|
57
|
+
while line = stdout.gets
|
58
|
+
puts line
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.run_command command
|
64
|
+
`#{command}`
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.run_background_command command
|
68
|
+
exec command
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|