summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo <mo.khan@gmail.com>2018-06-13 19:36:57 -0600
committermo <mo.khan@gmail.com>2018-06-13 19:36:57 -0600
commitcef776a2483cac92c03f344ccf316c609aef3b1e (patch)
tree057f32b14c90bc2b9652f5d9a09af1518bdc5f1c
parent72e58677b7f0f98c036290b551c2a64445cd4dfe (diff)
warn when private key already created.
-rw-r--r--lib/trunk/cli.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/trunk/cli.rb b/lib/trunk/cli.rb
index 9c3d90d..d06a5d5 100644
--- a/lib/trunk/cli.rb
+++ b/lib/trunk/cli.rb
@@ -21,6 +21,7 @@ module Trunk
method_option :algorithm, type: :string, default: 'AES-256-CBC'
def setup
FileUtils.mkdir_p(dir)
+ exit(0) unless yes?("Private key already exists. Overwrite?", :yellow) if File.exist?(private_key_path)
IO.write(private_key_path, OpenSSL::PKey::RSA.new(4096).export(options[:algorithm], passphrase))
FileUtils.touch(database_path)
[database_path, private_key_path].each { |x| FileUtils.chmod(0600, x) }
@@ -49,7 +50,7 @@ module Trunk
end
def passphrase
- ENV['TRUNK_PASSPHRASE'] || ask("passphrase?", echo: false)
+ ENV['TRUNK_PASSPHRASE'] || ask("passphrase:", echo: false)
end
end
end