dokku-installer-cli 0.0.9.1 → 0.0.9.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c5179bf5289d296ba2a1e33360b026302996985
4
- data.tar.gz: c038a76fda5e4e58724758f1d535203bdc1c040e
3
+ metadata.gz: 0c945b34c9882b87432e855b86f5612a760abe39
4
+ data.tar.gz: c393ae67b9aec13d04aa2db8702eb3d601c23d14
5
5
  SHA512:
6
- metadata.gz: 6faf86460a56e7fdf7d19a1f47ce9ce9c85d6a0430dceda21d875420c3ed9922e6aec0ce24e0f54159b71ca1e4e65f97932b9d2fa915461b823bd4d0002542e8
7
- data.tar.gz: 81d3b6820e604e364c14a23da4e4a69e9b3c0f7ef52702ae662f6f3840786de2f25026948f47e4f49e0540f84e2629c3e1f302ae67f1cee659c2943dd936f337
6
+ metadata.gz: 7b2d401fab02a575e21f1d8ea86213981244beaf752947666996ef0008b04e9e94e2d790d72117dc9eceed8097ed89cc448974357cc387119d05dc58acecfe1b
7
+ data.tar.gz: 6abaad81c6af7c6121b27ed408940caf86098b6cb2c22e1c78b242e55d1090c9570cf3661b5ef35e1b8b61e614eb1c66fd5cfea3109502a1bbab928c15c7a6fb
data/bin/dokku CHANGED
@@ -1,42 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "shellwords"
4
3
  require "thor"
5
4
  require "YAML"
5
+ require_relative "../lib/dokku_installer"
6
6
 
7
7
  module DokkuInstaller
8
8
  class Cli < Thor
9
9
 
10
- desc "config", "Display the app's environment variables"
11
- def config
12
- run_command "config #{app_name}"
13
- end
14
-
15
- desc "config:get KEY", "Display an environment variable value"
16
- def config_get(*args)
17
- run_command "config:get #{app_name} #{args.first}"
18
- end
19
-
20
- desc "config:set KEY1=VALUE1 [KEY2=VALUE2 ...]", "Set one or more environment variables"
21
- def config_set(*args)
22
- run_command "config:set #{app_name} #{args.join(' ')}"
23
- end
24
-
25
- desc "config:unset KEY1 [KEY2 ...]", "Unset one or more environment variables"
26
- def config_unset(*args)
27
- run_command "config:unset #{app_name} #{args.join(' ')}"
28
- end
29
-
30
- desc "domains", "Display the app's domains"
31
- def domains(*args)
32
- run_command "domains #{app_name}"
33
- end
34
-
35
- desc "domains:set DOMAIN1 [DOMAIN2 ...]", "Set one or more domains"
36
- def domains_set(*args)
37
- run_command "domains:set #{app_name} #{args.join(' ')}"
38
- end
39
-
40
10
  desc "logs [-t]", "Show the last logs for the application (-t follows)"
41
11
  def logs(*args)
42
12
  if args.first && args.first.strip == "-t"
@@ -53,70 +23,6 @@ module DokkuInstaller
53
23
  exec("open http://#{app_name}.#{domain}")
54
24
  end
55
25
 
56
- desc "postgres:backups", "List available PostgreSQL backups"
57
- def postgres_backups
58
- command = "ssh -t dokku@#{domain} postgres:backups #{app_name}"
59
- puts "Running #{command}..."
60
- backups = `#{command}`
61
- backups.split("\n").reverse.each_with_index do |line, index|
62
- number = "#{index + 1}"
63
- if number.length < 2
64
- number = " #{number}"
65
- end
66
- puts "#{number}. #{line}"
67
- end
68
- end
69
-
70
- desc "postgres:backups:create", "Create a new PostgreSQL backup"
71
- def postgres_backups_create
72
- run_command "postgres:backups:create #{app_name}"
73
- end
74
-
75
- desc "postgres:backups:disable", "Disable daily PostgreSQL backups"
76
- def postgres_backups_disable
77
- run_command "postgres:backups:disable #{app_name}"
78
- end
79
-
80
- desc "postgres:backups:download <number>", "Download the numbered PostgreSQL backup"
81
- def postgres_backups_download(*args)
82
- number = args.first ? args.first : 1
83
-
84
- if backup = backup_filename(number)
85
- command = "postgres:backups:download #{app_name} #{backup} > #{backup}"
86
- puts "Saving to local file: #{backup}"
87
- run_command(command)
88
- else
89
- puts "Invalid backup number"
90
- end
91
- end
92
-
93
- desc "postgres:backups:enable", "Enable daily PostgreSQL backups"
94
- def postgres_backups_enable
95
- run_command "postgres:backups:enable #{app_name}"
96
- end
97
-
98
- desc "postgres:backups:restore:local <number>", "Restore the numbered PostgreSQL backup locally"
99
- def postgres_backups_restore_local(*args)
100
- # Download the backup file
101
- number = args.first ? args.first : 1
102
-
103
- if backup = backup_filename(number)
104
- command = "ssh -t dokku@#{domain} postgres:backups:download #{app_name} #{backup} > #{backup}"
105
- puts "Saving to local file: #{backup}"
106
- `#{command}`
107
-
108
- if psql_options
109
- command = "psql #{psql_options} --file=#{backup}"
110
- puts "Running #{command}..."
111
- `#{command}`
112
- puts "Deleting #{backup}..."
113
- `rm #{backup}`
114
- end
115
- else
116
- puts "Invalid backup number"
117
- end
118
- end
119
-
120
26
  desc "restart", "Restart the application"
121
27
  def restart(*args)
122
28
  run_command "restart #{app_name}"
@@ -142,26 +48,6 @@ module DokkuInstaller
142
48
  exec(command)
143
49
  end
144
50
 
145
- desc "ssl:certificate <file path>", "Add a signed certificate for SSL (server.crt)"
146
- def ssl_certificate(*args)
147
- file_path = args.first
148
- file_contents = File.read(file_path)
149
- command = "echo \"#{file_contents}\" | ssh dokku@#{domain} ssl:certificate #{app_name}"
150
-
151
- puts "Running #{command}..."
152
- exec(command)
153
- end
154
-
155
- desc "ssl:key <file path>", "Add a private key for SSL (server.key)"
156
- def ssl_key(*args)
157
- file_path = args.first
158
- file_contents = File.read(file_path)
159
- command = "echo \"#{file_contents}\" | ssh dokku@#{domain} ssl:key #{app_name}"
160
-
161
- puts "Running #{command}..."
162
- exec(command)
163
- end
164
-
165
51
  desc "url", "Show the URL for the application"
166
52
  def url
167
53
  puts "http://#{app_name}.#{domain}"
@@ -227,32 +113,6 @@ module DokkuInstaller
227
113
  end
228
114
  end
229
115
 
230
- def psql_options
231
- @psql_options ||= begin
232
- restore_options = nil
233
-
234
- if File.exist?("./config/database.yml")
235
- if development_config = YAML::load(IO.read("./config/database.yml"))["development"]
236
- restore_options = "--host=#{development_config['host']} --dbname=#{development_config['database']}"
237
-
238
- if username = development_config["username"]
239
- restore_options += " --username=#{username}"
240
- end
241
-
242
- if port = development_config["port"]
243
- restore_options += " --port=#{port}"
244
- end
245
- else
246
- puts "Missing database.yml config for development environment"
247
- end
248
- else
249
- puts "Missing file config/database.yml"
250
- end
251
-
252
- restore_options
253
- end
254
- end
255
-
256
116
  def run_command(command)
257
117
  dokku_command = "ssh -t dokku@#{domain} #{command}"
258
118
 
@@ -0,0 +1,5 @@
1
+ require_relative "dokku_installer/config"
2
+ require_relative "dokku_installer/domains"
3
+ require_relative "dokku_installer/postgres"
4
+ require_relative "dokku_installer/ssl"
5
+ require_relative "dokku_installer/version"
@@ -0,0 +1,47 @@
1
+ module DokkuInstaller
2
+ class Cli < Thor
3
+
4
+ desc "config", "Display the app's environment variables"
5
+ def config
6
+ run_command "config #{app_name}"
7
+ end
8
+
9
+ desc "config:get KEY", "Display an environment variable value"
10
+ def config_get(*args)
11
+ run_command "config:get #{app_name} #{args.first}"
12
+ end
13
+
14
+ desc "config:set KEY1=VALUE1 [KEY2=VALUE2 ...]", "Set one or more environment variables"
15
+ def config_set(*args)
16
+ # FIXME: Requires root to send config values with spaces
17
+ user = "dokku"
18
+
19
+ args = args.map{|arg|
20
+ key_value = arg.split("=")
21
+ if key_value.length == 2
22
+ user = "root" if key_value[1].index(" ")
23
+ return_value = "#{key_value[0]}="
24
+ return_value += '\"'
25
+ return_value += key_value[1].gsub(/"|'/, "")
26
+ return_value += '\"'
27
+ return_value
28
+ else
29
+ arg
30
+ end
31
+ }
32
+
33
+ command = "ssh #{user}@#{domain} "
34
+ command += user == "root" ? "dokku " : ""
35
+ command += "config:set #{app_name} #{args.join(' ')}"
36
+
37
+ puts "Running #{command}..."
38
+ exec(command)
39
+ end
40
+
41
+ desc "config:unset KEY1 [KEY2 ...]", "Unset one or more environment variables"
42
+ def config_unset(*args)
43
+ run_command "config:unset #{app_name} #{args.join(' ')}"
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,15 @@
1
+ module DokkuInstaller
2
+ class Cli < Thor
3
+
4
+ desc "domains", "Display the app's domains"
5
+ def domains(*args)
6
+ run_command "domains #{app_name}"
7
+ end
8
+
9
+ desc "domains:set DOMAIN1 [DOMAIN2 ...]", "Set one or more domains"
10
+ def domains_set(*args)
11
+ run_command "domains:set #{app_name} #{args.join(' ')}"
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,97 @@
1
+ module DokkuInstaller
2
+ class Cli < Thor
3
+
4
+ desc "postgres:backups", "List available PostgreSQL backups"
5
+ def postgres_backups
6
+ command = "ssh -t dokku@#{domain} postgres:backups #{app_name}"
7
+ puts "Running #{command}..."
8
+ backups = `#{command}`
9
+ backups.split("\n").reverse.each_with_index do |line, index|
10
+ number = "#{index + 1}"
11
+ if number.length < 2
12
+ number = " #{number}"
13
+ end
14
+ puts "#{number}. #{line}"
15
+ end
16
+ end
17
+
18
+ desc "postgres:backups:create", "Create a new PostgreSQL backup"
19
+ def postgres_backups_create
20
+ run_command "postgres:backups:create #{app_name}"
21
+ end
22
+
23
+ desc "postgres:backups:disable", "Disable daily PostgreSQL backups"
24
+ def postgres_backups_disable
25
+ run_command "postgres:backups:disable #{app_name}"
26
+ end
27
+
28
+ desc "postgres:backups:download <number>", "Download the numbered PostgreSQL backup"
29
+ def postgres_backups_download(*args)
30
+ number = args.first ? args.first : 1
31
+
32
+ if backup = backup_filename(number)
33
+ command = "postgres:backups:download #{app_name} #{backup} > #{backup}"
34
+ puts "Saving to local file: #{backup}"
35
+ run_command(command)
36
+ else
37
+ puts "Invalid backup number"
38
+ end
39
+ end
40
+
41
+ desc "postgres:backups:enable", "Enable daily PostgreSQL backups"
42
+ def postgres_backups_enable
43
+ run_command "postgres:backups:enable #{app_name}"
44
+ end
45
+
46
+ desc "postgres:backups:restore:local <number>", "Restore the numbered PostgreSQL backup locally"
47
+ def postgres_backups_restore_local(*args)
48
+ # Download the backup file
49
+ number = args.first ? args.first : 1
50
+
51
+ if backup = backup_filename(number)
52
+ command = "ssh -t dokku@#{domain} postgres:backups:download #{app_name} #{backup} > #{backup}"
53
+ puts "Saving to local file: #{backup}"
54
+ `#{command}`
55
+
56
+ if psql_options
57
+ command = "psql #{psql_options} --file=#{backup}"
58
+ puts "Running #{command}..."
59
+ `#{command}`
60
+ puts "Deleting #{backup}..."
61
+ `rm #{backup}`
62
+ end
63
+ else
64
+ puts "Invalid backup number"
65
+ end
66
+ end
67
+
68
+ private
69
+
70
+ def psql_options
71
+ @psql_options ||= begin
72
+ restore_options = nil
73
+
74
+ if File.exist?("./config/database.yml")
75
+ if development_config = YAML::load(IO.read("./config/database.yml"))["development"]
76
+ restore_options = "--host=#{development_config['host']} --dbname=#{development_config['database']}"
77
+
78
+ if username = development_config["username"]
79
+ restore_options += " --username=#{username}"
80
+ end
81
+
82
+ if port = development_config["port"]
83
+ restore_options += " --port=#{port}"
84
+ end
85
+ else
86
+ puts "Missing database.yml config for development environment"
87
+ end
88
+ else
89
+ puts "Missing file config/database.yml"
90
+ end
91
+
92
+ restore_options
93
+ end
94
+ end
95
+
96
+ end
97
+ end
@@ -0,0 +1,25 @@
1
+ module DokkuInstaller
2
+ class Cli < Thor
3
+
4
+ desc "ssl:certificate <file path>", "Add a signed certificate for SSL (server.crt)"
5
+ def ssl_certificate(*args)
6
+ file_path = args.first
7
+ file_contents = File.read(file_path)
8
+ command = "echo \"#{file_contents}\" | ssh dokku@#{domain} ssl:certificate #{app_name}"
9
+
10
+ puts "Running #{command}..."
11
+ exec(command)
12
+ end
13
+
14
+ desc "ssl:key <file path>", "Add a private key for SSL (server.key)"
15
+ def ssl_key(*args)
16
+ file_path = args.first
17
+ file_contents = File.read(file_path)
18
+ command = "echo \"#{file_contents}\" | ssh dokku@#{domain} ssl:key #{app_name}"
19
+
20
+ puts "Running #{command}..."
21
+ exec(command)
22
+ end
23
+
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module DokkuInstaller
2
- VERSION = "0.0.9.1"
2
+ VERSION = "0.0.9.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dokku-installer-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9.1
4
+ version: 0.0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Pattison
@@ -40,6 +40,10 @@ files:
40
40
  - bin/dokku
41
41
  - dokku_installer_cli.gemspec
42
42
  - lib/dokku_installer.rb
43
+ - lib/dokku_installer/config.rb
44
+ - lib/dokku_installer/domains.rb
45
+ - lib/dokku_installer/postgres.rb
46
+ - lib/dokku_installer/ssl.rb
43
47
  - lib/dokku_installer/version.rb
44
48
  homepage: https://github.com/brianpattison/dokku-installer-cli
45
49
  licenses: