mimas 0.3.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mimas/cli.rb +3 -4
- data/lib/mimas/commands/console.rb +3 -3
- data/lib/mimas/commands/provision.rb +4 -1
- data/lib/mimas/commands/push.rb +11 -4
- data/lib/mimas/commands/{install.rb → ruby/install.rb} +1 -1
- data/lib/mimas/commands/ruby.rb +8 -0
- data/lib/mimas/commands/setup/ruby.rb +2 -2
- data/lib/mimas/deployment/ruby_app.rb +1 -1
- data/lib/mimas/scripts/configure_ruby.sh +10 -11
- data/lib/mimas/scripts/harden.sh +1 -1
- data/lib/mimas/server/console.rb +2 -24
- data/lib/mimas/server/ruby.rb +11 -19
- data/lib/mimas/server/software.rb +21 -0
- data/lib/mimas/ssh/interactive.rb +33 -0
- data/lib/mimas/ssh/session.rb +74 -0
- data/lib/mimas/ssh.rb +1 -70
- data/lib/mimas/template.rb +11 -0
- data/lib/mimas/templates/mimas.env.erb +3 -0
- data/lib/mimas/templates/systemd.service.erb +1 -1
- data/lib/mimas/version.rb +1 -1
- data/lib/mimas.rb +5 -2
- metadata +8 -6
- data/lib/mimas/scripts/install_ruby_prerequisites.sh +0 -26
- data/lib/mimas/server/prerequisites.rb +0 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8dc43f51b6e12503251f7aae375c26c7231f0ae96549c675bf82b040604560d6
|
|
4
|
+
data.tar.gz: 03fbdf89bcb00a7f976cb25fe21ae3c662ad0c5abb904509bd986e5743f789bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 02ad0133e8c2d58f3b8b1d2b666da86ce006d6f7fd402e3818478e80f41a6cc226957244fd8ac7b16927b2afb722dd3b143404d597d0694dded2da8fd3e92e0a
|
|
7
|
+
data.tar.gz: 17a0cfda68a7a0e8f37479435b9efb472043447d09f126d774fd9905d53b94681a87cfcfc55cac7a6a46755d5322c7e97ced66212d11ce22c95b8181d70dfb62
|
data/lib/mimas/cli.rb
CHANGED
|
@@ -4,7 +4,7 @@ module Mimas
|
|
|
4
4
|
extend Dry::CLI::Registry
|
|
5
5
|
|
|
6
6
|
register "init", Init
|
|
7
|
-
register "install
|
|
7
|
+
register "ruby install", Ruby::Install
|
|
8
8
|
register "provision", Provision
|
|
9
9
|
register "push", Push, aliases: ["deploy"]
|
|
10
10
|
register "console", Console
|
|
@@ -19,9 +19,8 @@ module Mimas
|
|
|
19
19
|
|
|
20
20
|
Plugins.fetch.each do |plugin|
|
|
21
21
|
# Register plugin commands
|
|
22
|
-
plugin.
|
|
23
|
-
|
|
24
|
-
end if plugin.respond_to?(:commands)
|
|
22
|
+
plugin.register_commands(Mimas::CLI::Commands) \
|
|
23
|
+
if plugin.respond_to?(:register_commands)
|
|
25
24
|
|
|
26
25
|
# Add plugin template paths to lookup array
|
|
27
26
|
Mimas::Template.lookup_paths.unshift(Pathname.new(plugin.templates_dir.to_s)) \
|
|
@@ -4,12 +4,12 @@ module Mimas
|
|
|
4
4
|
class Console < BaseCommand
|
|
5
5
|
desc "Run your app's console"
|
|
6
6
|
|
|
7
|
-
argument :server_name, required: true, desc: "The name of the server to run the console on"
|
|
8
7
|
argument :site, default: :default, desc: "The site to run the console for. Uses the default site if unspecified"
|
|
8
|
+
argument :server_name, required: true, desc: "The name of the server to run the console on"
|
|
9
9
|
|
|
10
|
-
def call(
|
|
11
|
-
server = Config.current.servers[server_name.to_sym]
|
|
10
|
+
def call(site:, server_name:, **)
|
|
12
11
|
site = Config.current.sites[site.to_sym]
|
|
12
|
+
server = Config.current.servers[server_name.to_sym]
|
|
13
13
|
|
|
14
14
|
raise "Please add a `console` directive to your config file" unless site.respond_to?(:console)
|
|
15
15
|
|
|
@@ -40,9 +40,12 @@ module Mimas
|
|
|
40
40
|
server.install_caddy(sudo_user: sudo_user)
|
|
41
41
|
|
|
42
42
|
unless skip_ruby
|
|
43
|
-
server.
|
|
43
|
+
server.install_server_software(sudo_user: sudo_user)
|
|
44
44
|
server.install_ruby
|
|
45
45
|
end
|
|
46
|
+
|
|
47
|
+
say ""
|
|
48
|
+
say "Your server is provisioned and ready to serve websites."
|
|
46
49
|
end
|
|
47
50
|
end
|
|
48
51
|
end
|
data/lib/mimas/commands/push.rb
CHANGED
|
@@ -4,17 +4,24 @@ module Mimas
|
|
|
4
4
|
class Push < BaseCommand
|
|
5
5
|
desc "Push your Ruby app to the server"
|
|
6
6
|
|
|
7
|
-
argument :server_name, required: true, desc: "The name of the server to push to"
|
|
8
7
|
argument :site, default: :default, desc: "The site to push. Uses the default site if unspecified"
|
|
8
|
+
argument :server_name, required: true, desc: "The name of the server to push to"
|
|
9
9
|
|
|
10
10
|
example [
|
|
11
11
|
"production # Push the default site to the production server",
|
|
12
|
-
"production
|
|
12
|
+
"app production # Push the `:app` site to the production server"
|
|
13
13
|
]
|
|
14
14
|
|
|
15
|
-
def call(
|
|
16
|
-
server = Config.current.servers[server_name.to_sym]
|
|
15
|
+
def call(site:, server_name:, **)
|
|
17
16
|
site = Config.current.sites[site.to_sym]
|
|
17
|
+
server = Config.current.servers[server_name.to_sym]
|
|
18
|
+
|
|
19
|
+
unless server && site
|
|
20
|
+
say "Server or site not found. Please ensure you've invoked the command correctly.".red
|
|
21
|
+
say ""
|
|
22
|
+
puts Dry::CLI::Banner.call(self, "mimas push")
|
|
23
|
+
exit 1
|
|
24
|
+
end
|
|
18
25
|
|
|
19
26
|
working_copy = `git status --porcelain`
|
|
20
27
|
unless working_copy == ""
|
|
@@ -2,13 +2,13 @@ module Mimas
|
|
|
2
2
|
module CLI
|
|
3
3
|
module Commands
|
|
4
4
|
class Setup::Ruby < Setup
|
|
5
|
-
desc "Install
|
|
5
|
+
desc "Install server prerequisites and download a pre-built Ruby binary on a server"
|
|
6
6
|
|
|
7
7
|
def call(server_name:, **options)
|
|
8
8
|
server = Config.current.servers[server_name.to_sym]
|
|
9
9
|
sudo_user = options[:user]
|
|
10
10
|
|
|
11
|
-
server.
|
|
11
|
+
server.install_server_software(sudo_user: sudo_user)
|
|
12
12
|
server.install_ruby
|
|
13
13
|
end
|
|
14
14
|
end
|
|
@@ -33,7 +33,7 @@ module Mimas
|
|
|
33
33
|
|
|
34
34
|
say "Running deploy script"
|
|
35
35
|
session.upload StringIO.new(site.deploy), deploy_script_path
|
|
36
|
-
session.run "cd #{remote_destination} && /
|
|
36
|
+
session.run "cd #{remote_destination} && ~/.cargo/bin/rv run sh #{deploy_script}"
|
|
37
37
|
session.run "rm #{deploy_script_path}"
|
|
38
38
|
|
|
39
39
|
say "Setting current symlink"
|
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
set -e
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# Install RV
|
|
6
|
+
curl -LsSf https://rv.dev/install | sh
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
source /usr/local/share/chruby/auto.sh
|
|
10
|
-
STRING
|
|
11
|
-
|
|
12
|
-
source /usr/local/share/chruby/chruby.sh
|
|
13
|
-
source /usr/local/share/chruby/auto.sh
|
|
8
|
+
echo 'eval "$(~/.cargo/bin/rv shell init bash)"' >> ~/.profile
|
|
9
|
+
echo 'eval "$(~/.cargo/bin/rv shell completions bash)"' >> ~/.profile
|
|
14
10
|
|
|
15
11
|
echo 'gem: --no-document' >> ~/.gemrc
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
mkdir -p ~/.bundle/
|
|
14
|
+
cat << STRING > ~/.bundle/config
|
|
15
|
+
---
|
|
16
|
+
BUNDLE_WITHOUT: "development:test"
|
|
17
|
+
BUNDLE_FROZEN: "true"
|
|
18
|
+
STRING
|
data/lib/mimas/scripts/harden.sh
CHANGED
|
@@ -30,7 +30,7 @@ passwd -ld admin
|
|
|
30
30
|
rsync --archive --chown=admin:admin ~/.ssh /home/admin
|
|
31
31
|
|
|
32
32
|
# Allow passwordless sudo for `admin`
|
|
33
|
-
echo "%admin $(cat /etc/hostname)=(
|
|
33
|
+
echo "%admin $(cat /etc/hostname)=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/admin
|
|
34
34
|
|
|
35
35
|
# Validate the modified sudoers file
|
|
36
36
|
if ! visudo -c -f /etc/sudoers.d/admin; then
|
data/lib/mimas/server/console.rb
CHANGED
|
@@ -3,31 +3,9 @@ module Mimas
|
|
|
3
3
|
module Console
|
|
4
4
|
def start_console(site)
|
|
5
5
|
console_command = site.console
|
|
6
|
+
exec_command = "cd #{current_path(site)} && ~/.cargo/bin/rv run #{console_command}"
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
Net::SSH.start(host, user) do |session|
|
|
9
|
-
session.open_channel do |channel|
|
|
10
|
-
channel.request_pty do
|
|
11
|
-
channel.exec("cd #{current_path(site)} && /bin/bash -lc '#{console_command}'") do
|
|
12
|
-
channel.on_data do |_, data|
|
|
13
|
-
$stdout.print(data) if data
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
channel.on_extended_data do |_, data|
|
|
17
|
-
$stdout.print(data) if data
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
session.listen_to($stdin) do |stdin|
|
|
21
|
-
input = stdin.readpartial(1024)
|
|
22
|
-
channel.send_data(input) unless input.empty?
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
session.loop
|
|
28
|
-
end
|
|
29
|
-
ensure
|
|
30
|
-
system('stty sane')
|
|
8
|
+
interactive_ssh(host, user: user, command: exec_command)
|
|
31
9
|
end
|
|
32
10
|
end
|
|
33
11
|
end
|
data/lib/mimas/server/ruby.rb
CHANGED
|
@@ -1,35 +1,27 @@
|
|
|
1
1
|
module Mimas
|
|
2
2
|
class Server
|
|
3
3
|
module Ruby
|
|
4
|
-
def
|
|
4
|
+
def install_server_software(sudo_user:)
|
|
5
5
|
ssh(self, user: sudo_user) do |session|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
software_list = Software.utilities + Software.prerequisites
|
|
7
|
+
software_list = software_list.join(" ")
|
|
8
8
|
|
|
9
|
-
session.
|
|
10
|
-
sudo: true,
|
|
11
|
-
vars: { PREREQUISITES: "'#{prerequisites}'" }
|
|
12
|
-
)
|
|
9
|
+
session.run "sudo apt-get install #{software_list} -y"
|
|
13
10
|
end
|
|
14
11
|
end
|
|
15
12
|
|
|
16
13
|
def install_ruby(version: Config.current.ruby_version)
|
|
17
14
|
ssh(self) do |session|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return say "Ruby #{version} is already installed!"
|
|
24
|
-
end
|
|
15
|
+
begin
|
|
16
|
+
session.run "test -d ~/.rubies/ruby-*"
|
|
17
|
+
rescue SSH::Session::NonZeroExitCode
|
|
18
|
+
# Install `rv` for fresh installs
|
|
19
|
+
session.script "configure_ruby"
|
|
25
20
|
end
|
|
26
21
|
|
|
27
|
-
session.run "ruby
|
|
22
|
+
session.run "~/.cargo/bin/rv ruby install #{version} -i ~/.rubies"
|
|
28
23
|
session.run "echo '#{version}' > ~/.ruby-version"
|
|
29
|
-
|
|
30
|
-
if current_ruby == ""
|
|
31
|
-
session.script("configure_ruby")
|
|
32
|
-
end
|
|
24
|
+
session.run "~/.cargo/bin/rv run gem update --system"
|
|
33
25
|
end
|
|
34
26
|
end
|
|
35
27
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Mimas
|
|
2
|
+
class Server
|
|
3
|
+
module Software
|
|
4
|
+
extend self
|
|
5
|
+
|
|
6
|
+
PREREQUISITES = %w[build-essential libyaml-dev libssl-dev libjemalloc-dev]
|
|
7
|
+
private_constant :PREREQUISITES
|
|
8
|
+
|
|
9
|
+
def prerequisites
|
|
10
|
+
MUTEX.synchronize { @prerequisites ||= PREREQUISITES }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
UTILITIES = %w[curl jq]
|
|
14
|
+
private_constant :UTILITIES
|
|
15
|
+
|
|
16
|
+
def utilities
|
|
17
|
+
MUTEX.synchronize { @utilities ||= UTILITIES }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Mimas
|
|
2
|
+
module SSH
|
|
3
|
+
module Interactive
|
|
4
|
+
def interactive_ssh(host, user:, command:)
|
|
5
|
+
system('stty cbreak -echo')
|
|
6
|
+
|
|
7
|
+
Net::SSH.start(host, user) do |session|
|
|
8
|
+
session.open_channel do |channel|
|
|
9
|
+
channel.request_pty do
|
|
10
|
+
channel.exec(command) do
|
|
11
|
+
channel.on_data do |_, data|
|
|
12
|
+
$stdout.print(data) if data
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
channel.on_extended_data do |_, data|
|
|
16
|
+
$stdout.print(data) if data
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
session.listen_to($stdin) do |stdin|
|
|
20
|
+
input = stdin.readpartial(1024)
|
|
21
|
+
channel.send_data(input) unless input.empty?
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
session.loop
|
|
27
|
+
end
|
|
28
|
+
ensure
|
|
29
|
+
system('stty sane')
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
module Mimas
|
|
2
|
+
module SSH
|
|
3
|
+
class Session
|
|
4
|
+
class NonZeroExitCode < StandardError
|
|
5
|
+
attr_reader :exit_code, :output
|
|
6
|
+
def initialize(command:, exit_code:, output:)
|
|
7
|
+
@command = command
|
|
8
|
+
@exit_code = exit_code
|
|
9
|
+
@output = output
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def to_s
|
|
13
|
+
"'#{@command}' exited with code: #{@exit_code}"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def initialize(server, user:)
|
|
18
|
+
@server = server
|
|
19
|
+
@user = user || server.user
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def perform(&block)
|
|
23
|
+
@ssh = Net::SSH.start(@server.host, @user, timeout: 60, **@server.ssh_options)
|
|
24
|
+
@hostname = run("cat /etc/hostname", capture: true).chomp
|
|
25
|
+
yield(self)
|
|
26
|
+
ensure
|
|
27
|
+
@ssh&.close
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def run(command, capture: false, silent: false)
|
|
31
|
+
status = {}
|
|
32
|
+
output = ""
|
|
33
|
+
@ssh.exec!(command, status: status) do |channel, stream, data|
|
|
34
|
+
if capture
|
|
35
|
+
output << data
|
|
36
|
+
elsif stream == :stderr
|
|
37
|
+
print "#{data}".bold.red
|
|
38
|
+
else
|
|
39
|
+
print "#{data}".white
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
if status[:exit_code] != 0 && !silent
|
|
44
|
+
raise NonZeroExitCode.new(command: command, exit_code: status[:exit_code], output: output)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
return output if capture
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def upload(source_file, destination_file)
|
|
51
|
+
@ssh.scp.upload! source_file, destination_file
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def script(name, sudo: false, vars: {})
|
|
55
|
+
filename = "#{name}.sh"
|
|
56
|
+
remote_location = "/tmp/#{filename}"
|
|
57
|
+
|
|
58
|
+
source_path = File.expand_path("../scripts/#{filename}", __dir__)
|
|
59
|
+
upload source_path, remote_location
|
|
60
|
+
run "chmod +x #{remote_location}"
|
|
61
|
+
|
|
62
|
+
vars = vars.to_a.map { it.join("=") }.join(" ")
|
|
63
|
+
|
|
64
|
+
exec_command = remote_location
|
|
65
|
+
exec_command = "#{vars} #{exec_command}".strip
|
|
66
|
+
exec_command = "sudo #{exec_command}" if sudo
|
|
67
|
+
|
|
68
|
+
run exec_command
|
|
69
|
+
|
|
70
|
+
run "rm #{remote_location}"
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
data/lib/mimas/ssh.rb
CHANGED
|
@@ -4,75 +4,6 @@ module Mimas
|
|
|
4
4
|
Session.new(server, user: user).perform(&block)
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
class NonZeroExitCode < StandardError
|
|
9
|
-
attr_reader :exit_code, :output
|
|
10
|
-
def initialize(command:, exit_code:, output:)
|
|
11
|
-
@command = command
|
|
12
|
-
@exit_code = exit_code
|
|
13
|
-
@output = output
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def to_s
|
|
17
|
-
"'#{@command}' exited with code: #{@exit_code}"
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def initialize(server, user:)
|
|
22
|
-
@server = server
|
|
23
|
-
@user = user || server.user
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def perform(&block)
|
|
27
|
-
@ssh = Net::SSH.start(@server.host, @user, timeout: 60, **@server.ssh_options)
|
|
28
|
-
@hostname = run("cat /etc/hostname", capture: true).chomp
|
|
29
|
-
yield(self)
|
|
30
|
-
ensure
|
|
31
|
-
@ssh&.close
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def run(command, capture: false, silent: false)
|
|
35
|
-
status = {}
|
|
36
|
-
output = ""
|
|
37
|
-
@ssh.exec!(command, status: status) do |channel, stream, data|
|
|
38
|
-
if capture
|
|
39
|
-
output << data
|
|
40
|
-
elsif stream == :stderr
|
|
41
|
-
print "#{data}".bold.red
|
|
42
|
-
else
|
|
43
|
-
print "#{data}".white
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
if status[:exit_code] != 0 && !silent
|
|
48
|
-
raise NonZeroExitCode.new(command: command, exit_code: status[:exit_code], output: output)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
return output if capture
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def upload(source_file, destination_file)
|
|
55
|
-
@ssh.scp.upload! source_file, destination_file
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def script(name, sudo: false, vars: {})
|
|
59
|
-
filename = "#{name}.sh"
|
|
60
|
-
remote_location = "/tmp/#{filename}"
|
|
61
|
-
|
|
62
|
-
source_path = File.expand_path("./scripts/#{filename}", __dir__)
|
|
63
|
-
upload source_path, remote_location
|
|
64
|
-
run "chmod +x #{remote_location}"
|
|
65
|
-
|
|
66
|
-
vars = vars.to_a.map { it.join("=") }.join(" ")
|
|
67
|
-
|
|
68
|
-
exec_command = remote_location
|
|
69
|
-
exec_command = "#{vars} #{exec_command}".strip
|
|
70
|
-
exec_command = "sudo #{exec_command}" if sudo
|
|
71
|
-
|
|
72
|
-
run exec_command
|
|
73
|
-
|
|
74
|
-
run "rm #{remote_location}"
|
|
75
|
-
end
|
|
76
|
-
end
|
|
7
|
+
include Interactive
|
|
77
8
|
end
|
|
78
9
|
end
|
data/lib/mimas/template.rb
CHANGED
|
@@ -20,6 +20,17 @@ module Mimas
|
|
|
20
20
|
FileUtils.copy(source, File.join(destination, rename || source_file_name))
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
def find_files(glob)
|
|
24
|
+
files = []
|
|
25
|
+
|
|
26
|
+
Mimas::Template.lookup_paths.each do |path|
|
|
27
|
+
found_files = Dir.glob(path.join(glob))
|
|
28
|
+
files.push(*found_files)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
files
|
|
32
|
+
end
|
|
33
|
+
|
|
23
34
|
BASE_DIRECTORY = Pathname.new(__dir__).join("templates")
|
|
24
35
|
def self.lookup_paths
|
|
25
36
|
MUTEX.synchronize { @lookup_paths ||= [BASE_DIRECTORY] }
|
|
@@ -9,7 +9,7 @@ User=<%= user %>
|
|
|
9
9
|
EnvironmentFile=<%= site_root %>/.env
|
|
10
10
|
EnvironmentFile=<%= site_root %>/mimas/mimas.env
|
|
11
11
|
WorkingDirectory=<%= site_root %>/current
|
|
12
|
-
ExecStart
|
|
12
|
+
ExecStart=%h/.cargo/bin/rv run <%= command %>
|
|
13
13
|
StandardOutput=append:<%= site_root %>/logs/<%= service_name %>.log
|
|
14
14
|
StandardError=append:<%= site_root %>/logs/<%= service_name %>.log
|
|
15
15
|
KillMode=mixed
|
data/lib/mimas/version.rb
CHANGED
data/lib/mimas.rb
CHANGED
|
@@ -11,6 +11,8 @@ require_relative "mimas/terminal/printer"
|
|
|
11
11
|
require_relative "mimas/terminal/ansi"
|
|
12
12
|
require_relative "mimas/template"
|
|
13
13
|
require_relative "mimas/archiver"
|
|
14
|
+
require_relative "mimas/ssh/session"
|
|
15
|
+
require_relative "mimas/ssh/interactive"
|
|
14
16
|
require_relative "mimas/ssh"
|
|
15
17
|
require_relative "mimas/hooks"
|
|
16
18
|
|
|
@@ -19,7 +21,7 @@ require_relative "mimas/config"
|
|
|
19
21
|
require_relative "mimas/site/archive"
|
|
20
22
|
require_relative "mimas/site"
|
|
21
23
|
|
|
22
|
-
require_relative "mimas/server/
|
|
24
|
+
require_relative "mimas/server/software"
|
|
23
25
|
require_relative "mimas/server/harden"
|
|
24
26
|
require_relative "mimas/server/deploy_user"
|
|
25
27
|
require_relative "mimas/server/caddy"
|
|
@@ -40,9 +42,10 @@ require_relative "mimas/base_command"
|
|
|
40
42
|
require_relative "mimas/commands/archive"
|
|
41
43
|
require_relative "mimas/commands/console"
|
|
42
44
|
require_relative "mimas/commands/init"
|
|
43
|
-
require_relative "mimas/commands/install"
|
|
44
45
|
require_relative "mimas/commands/provision"
|
|
45
46
|
require_relative "mimas/commands/push"
|
|
47
|
+
require_relative "mimas/commands/ruby"
|
|
48
|
+
require_relative "mimas/commands/ruby/install"
|
|
46
49
|
require_relative "mimas/commands/setup"
|
|
47
50
|
require_relative "mimas/commands/setup/caddy"
|
|
48
51
|
require_relative "mimas/commands/setup/deploy_user"
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mimas
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ayush Newatia
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: dry-cli
|
|
@@ -107,9 +107,10 @@ files:
|
|
|
107
107
|
- lib/mimas/commands/archive.rb
|
|
108
108
|
- lib/mimas/commands/console.rb
|
|
109
109
|
- lib/mimas/commands/init.rb
|
|
110
|
-
- lib/mimas/commands/install.rb
|
|
111
110
|
- lib/mimas/commands/provision.rb
|
|
112
111
|
- lib/mimas/commands/push.rb
|
|
112
|
+
- lib/mimas/commands/ruby.rb
|
|
113
|
+
- lib/mimas/commands/ruby/install.rb
|
|
113
114
|
- lib/mimas/commands/setup.rb
|
|
114
115
|
- lib/mimas/commands/setup/caddy.rb
|
|
115
116
|
- lib/mimas/commands/setup/deploy_user.rb
|
|
@@ -127,17 +128,18 @@ files:
|
|
|
127
128
|
- lib/mimas/scripts/create_deploy_user.sh
|
|
128
129
|
- lib/mimas/scripts/harden.sh
|
|
129
130
|
- lib/mimas/scripts/install_caddy.sh
|
|
130
|
-
- lib/mimas/scripts/install_ruby_prerequisites.sh
|
|
131
131
|
- lib/mimas/server.rb
|
|
132
132
|
- lib/mimas/server/caddy.rb
|
|
133
133
|
- lib/mimas/server/console.rb
|
|
134
134
|
- lib/mimas/server/deploy_user.rb
|
|
135
135
|
- lib/mimas/server/harden.rb
|
|
136
|
-
- lib/mimas/server/prerequisites.rb
|
|
137
136
|
- lib/mimas/server/ruby.rb
|
|
137
|
+
- lib/mimas/server/software.rb
|
|
138
138
|
- lib/mimas/site.rb
|
|
139
139
|
- lib/mimas/site/archive.rb
|
|
140
140
|
- lib/mimas/ssh.rb
|
|
141
|
+
- lib/mimas/ssh/interactive.rb
|
|
142
|
+
- lib/mimas/ssh/session.rb
|
|
141
143
|
- lib/mimas/template.rb
|
|
142
144
|
- lib/mimas/templates/Caddyfile.ruby.erb
|
|
143
145
|
- lib/mimas/templates/Caddyfile.static.erb
|
|
@@ -168,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
168
170
|
- !ruby/object:Gem::Version
|
|
169
171
|
version: '0'
|
|
170
172
|
requirements: []
|
|
171
|
-
rubygems_version:
|
|
173
|
+
rubygems_version: 4.0.18
|
|
172
174
|
specification_version: 4
|
|
173
175
|
summary: Deploy Ruby apps to a single server using an omakase setup
|
|
174
176
|
test_files: []
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
set -euo pipefail
|
|
4
|
-
export DEBIAN_FRONTEND=noninteractive
|
|
5
|
-
|
|
6
|
-
# Install Ruby prerequisites
|
|
7
|
-
sudo apt-get install $PREREQUISITES -y
|
|
8
|
-
|
|
9
|
-
# Install Ruby Install
|
|
10
|
-
wget https://github.com/postmodern/ruby-install/releases/download/v0.10.2/ruby-install-0.10.2.tar.gz
|
|
11
|
-
tar -xzvf ruby-install-0.10.2.tar.gz
|
|
12
|
-
cd ruby-install-0.10.2/
|
|
13
|
-
sudo make install
|
|
14
|
-
cd ..
|
|
15
|
-
rm ruby-install-0.10.2.tar.gz
|
|
16
|
-
rm -rf ruby-install-0.10.2/
|
|
17
|
-
|
|
18
|
-
# Install chruby
|
|
19
|
-
wget https://github.com/postmodern/chruby/releases/download/v0.3.9/chruby-0.3.9.tar.gz
|
|
20
|
-
tar -xzvf chruby-0.3.9.tar.gz
|
|
21
|
-
cd chruby-0.3.9/
|
|
22
|
-
sudo make install
|
|
23
|
-
cd ..
|
|
24
|
-
rm chruby-0.3.9.tar.gz
|
|
25
|
-
rm -rf chruby-0.3.9/
|
|
26
|
-
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module Mimas
|
|
2
|
-
class Server
|
|
3
|
-
module Prerequisites
|
|
4
|
-
extend self
|
|
5
|
-
|
|
6
|
-
def for_ruby
|
|
7
|
-
%w[
|
|
8
|
-
xz-utils
|
|
9
|
-
build-essential
|
|
10
|
-
zlib1g-dev
|
|
11
|
-
libyaml-dev
|
|
12
|
-
libssl-dev
|
|
13
|
-
libncurses-dev
|
|
14
|
-
libffi-dev
|
|
15
|
-
rustc
|
|
16
|
-
libjemalloc-dev
|
|
17
|
-
]
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def utilities
|
|
21
|
-
%w[curl jq]
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|