dokku-installer-cli 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dokku +1 -18
- data/lib/dokku_installer/config.rb +2 -2
- data/lib/dokku_installer/domains.rb +1 -1
- data/lib/dokku_installer/postgres.rb +52 -8
- data/lib/dokku_installer/ssl.rb +1 -2
- data/lib/dokku_installer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c104c86300fc07513b25c7c5588d60001ad523b
|
4
|
+
data.tar.gz: 791d4a07292db5e75cd8476160f773fcce6ba553
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2c32c98ef467298ea3cdc4c21bce5979b6efbc0a35be902050f99ebc8aa8a20a6bedc87a417255556bd464835d5a41620842df4ad2e2f4ee1735124ae4e1c4a
|
7
|
+
data.tar.gz: 0373575a4e801a9b33c3b1d76fa7a03e42de7249caeaf0230d036b7464a5f3cc076fc8875ac9660203f0ca93f8eb34b7fd15465426788ca51a61c340b7e758d0
|
data/bin/dokku
CHANGED
@@ -24,7 +24,7 @@ module DokkuInstaller
|
|
24
24
|
end
|
25
25
|
|
26
26
|
desc "restart", "Restart the application"
|
27
|
-
def restart
|
27
|
+
def restart
|
28
28
|
run_command "restart #{app_name}"
|
29
29
|
end
|
30
30
|
|
@@ -74,23 +74,6 @@ module DokkuInstaller
|
|
74
74
|
@app_name ||= git_config_match[2]
|
75
75
|
end
|
76
76
|
|
77
|
-
def backup_filename(number)
|
78
|
-
# Make sure the number is valid or use 1
|
79
|
-
number = number.to_s.gsub(/\D/, "").to_i
|
80
|
-
number = 1 if number < 1
|
81
|
-
|
82
|
-
# Get the file name for the numbered backup
|
83
|
-
puts "Getting list of backups..."
|
84
|
-
command = "ssh -t dokku@#{domain} postgres:backups #{app_name}"
|
85
|
-
backups = `#{command}`
|
86
|
-
index = number - 1
|
87
|
-
if filename = backups.split("\n").reverse[index]
|
88
|
-
filename.strip
|
89
|
-
else
|
90
|
-
nil
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
77
|
def domain
|
95
78
|
@domain ||= git_config_match[1]
|
96
79
|
end
|
@@ -7,8 +7,8 @@ module DokkuInstaller
|
|
7
7
|
end
|
8
8
|
|
9
9
|
desc "config:get KEY", "Display an environment variable value"
|
10
|
-
def config_get(
|
11
|
-
run_command "config:get #{app_name} #{
|
10
|
+
def config_get(key)
|
11
|
+
run_command "config:get #{app_name} #{key}"
|
12
12
|
end
|
13
13
|
|
14
14
|
desc "config:set KEY1=VALUE1 [KEY2=VALUE2 ...]", "Set one or more environment variables"
|
@@ -1,17 +1,17 @@
|
|
1
1
|
module DokkuInstaller
|
2
2
|
class Cli < Thor
|
3
3
|
|
4
|
-
desc "postgres:backups", "List available PostgreSQL backups"
|
4
|
+
desc "postgres:backups", "List available PostgreSQL backups as a numbered list"
|
5
5
|
def postgres_backups
|
6
6
|
command = "ssh -t dokku@#{domain} postgres:backups #{app_name}"
|
7
7
|
puts "Running #{command}..."
|
8
8
|
backups = `#{command}`
|
9
|
-
backups.split("\n").reverse.each_with_index do |line, index|
|
9
|
+
backups.split("\n").select{|backup| backup != "" }.reverse.each_with_index do |line, index|
|
10
10
|
number = "#{index + 1}"
|
11
11
|
if number.length < 2
|
12
12
|
number = " #{number}"
|
13
13
|
end
|
14
|
-
puts "#{number}
|
14
|
+
puts "[#{number}] #{line}"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -34,8 +34,8 @@ module DokkuInstaller
|
|
34
34
|
end
|
35
35
|
|
36
36
|
desc "postgres:backups:download <number>", "Download the numbered PostgreSQL backup"
|
37
|
-
def postgres_backups_download(
|
38
|
-
number
|
37
|
+
def postgres_backups_download(number = nil)
|
38
|
+
number ||= 1
|
39
39
|
|
40
40
|
if backup = backup_filename(number)
|
41
41
|
command = "postgres:backups:download #{app_name} #{backup} > #{backup}"
|
@@ -53,10 +53,25 @@ module DokkuInstaller
|
|
53
53
|
exec(command)
|
54
54
|
end
|
55
55
|
|
56
|
-
desc "postgres:backups:restore
|
57
|
-
def
|
56
|
+
desc "postgres:backups:restore <number>", "Restore a numbered PostgreSQL backup"
|
57
|
+
def postgres_backups_restore(number = nil)
|
58
|
+
if number.nil?
|
59
|
+
puts "You must specify a numbered backup."
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
|
63
|
+
if backup = backup_filename(number)
|
64
|
+
command = "postgres:backups:restore #{app_name} #{backup}"
|
65
|
+
run_command(command)
|
66
|
+
else
|
67
|
+
puts "Invalid backup number"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
desc "postgres:backups:restore:local <number>", "Restore a numbered PostgreSQL backup locally"
|
72
|
+
def postgres_backups_restore_local(number = nil)
|
58
73
|
# Download the backup file
|
59
|
-
number
|
74
|
+
number ||= 1
|
60
75
|
|
61
76
|
if backup = backup_filename(number)
|
62
77
|
command = "ssh -t dokku@#{domain} postgres:backups:download #{app_name} #{backup} > #{backup}"
|
@@ -75,8 +90,37 @@ module DokkuInstaller
|
|
75
90
|
end
|
76
91
|
end
|
77
92
|
|
93
|
+
desc "postgres:export <file.sql>", "Export Postgres data to local file"
|
94
|
+
def postgres_export(file = "export.sql")
|
95
|
+
command = "postgres:dump #{app_name} > #{file}"
|
96
|
+
run_command(command)
|
97
|
+
end
|
98
|
+
|
99
|
+
desc "postgres:import <file.sql>", "Restore database data from a local file"
|
100
|
+
def postgres_import(file)
|
101
|
+
command = "postgres:restore #{app_name} < #{file}"
|
102
|
+
run_command(command)
|
103
|
+
end
|
104
|
+
|
78
105
|
private
|
79
106
|
|
107
|
+
def backup_filename(number)
|
108
|
+
# Make sure the number is valid or use 1
|
109
|
+
number = number.to_s.gsub(/\D/, "").to_i
|
110
|
+
number = 1 if number < 1
|
111
|
+
|
112
|
+
# Get the file name for the numbered backup
|
113
|
+
puts "Getting list of backups..."
|
114
|
+
command = "ssh -t dokku@#{domain} postgres:backups #{app_name}"
|
115
|
+
backups = `#{command}`
|
116
|
+
index = number - 1
|
117
|
+
if filename = backups.split("\n").select{|backup| backup != "" }.reverse[index]
|
118
|
+
filename.strip
|
119
|
+
else
|
120
|
+
nil
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
80
124
|
def psql_options
|
81
125
|
@psql_options ||= begin
|
82
126
|
restore_options = nil
|
data/lib/dokku_installer/ssl.rb
CHANGED