mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-21 10:20:05 +00:00
change .gets to ask
This commit is contained in:
parent
c1551c7084
commit
0954f2706b
2 changed files with 18 additions and 33 deletions
|
@ -2,11 +2,6 @@
|
||||||
|
|
||||||
On Debian/Ubuntu:
|
On Debian/Ubuntu:
|
||||||
|
|
||||||
* apt-get install gpg python-gnupg sshpass
|
* apt-get install ruby sshpass ruby-gpgme ruby-highline
|
||||||
|
|
||||||
|
|
||||||
On MacOS X:
|
|
||||||
|
|
||||||
* sudo easy_install pip
|
|
||||||
* sudo pip install python-gnupg
|
|
||||||
* Install gnupg-tool and sshpass
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'gpgme'
|
require 'gpgme'
|
||||||
require 'csv'
|
require 'csv'
|
||||||
|
require 'highline/import'
|
||||||
|
|
||||||
FILE_GPG = './pass.gpg'
|
FILE_GPG = './pass.gpg'
|
||||||
KEY = 'a.waksberg@yaegashi.fr'
|
KEY = 'a.waksberg@yaegashi.fr'
|
||||||
|
@ -52,12 +53,11 @@ class ManagePasswd
|
||||||
begin
|
begin
|
||||||
passwd = IO.read(@file_pwd)
|
passwd = IO.read(@file_pwd)
|
||||||
rescue
|
rescue
|
||||||
print "Password GPG: "
|
passwd = ask("Password GPG: ") {|q| q.echo = false}
|
||||||
passwd = $stdin.gets
|
|
||||||
file_pwd = File.new(@file_pwd, 'w+')
|
file_pwd = File.new(@file_pwd, 'w+')
|
||||||
|
File.chmod(0600, @file_pwd)
|
||||||
file_pwd << passwd
|
file_pwd << passwd
|
||||||
file_pwd.close
|
file_pwd.close
|
||||||
File.chmod(0600, @file_pwd)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
@ -135,20 +135,15 @@ class ManagePasswd
|
||||||
puts "# Add a new password"
|
puts "# Add a new password"
|
||||||
puts "# --------------------"
|
puts "# --------------------"
|
||||||
row[ID] = Time.now.to_i.to_s(16)
|
row[ID] = Time.now.to_i.to_s(16)
|
||||||
print "Enter the server name or ip: "
|
row[SERVER] = ask("Enter the server name or ip: ")
|
||||||
row[SERVER] = $stdin.gets.chomp
|
row[TYPE] = ask("Enter the type of connection (ssh, web, other): ")
|
||||||
print "Enter the type of connection (ssh, web, other): "
|
row[LOGIN] = ask("Enter the login connection: ")
|
||||||
row[TYPE] = $stdin.gets.chomp
|
row[PASSWORD] = ask("Enter the the password: ")
|
||||||
print "Enter the login connection: "
|
row[PORT] = ask("Enter the connection port (optinal): ")
|
||||||
row[LOGIN] = $stdin.gets.chomp
|
row[COMMENT] = ask("Enter a comment (optinal): ")
|
||||||
print "Enter the the password: "
|
|
||||||
row[PASSWORD] = $stdin.gets.chomp
|
|
||||||
print "Enter the connection port (optinal): "
|
|
||||||
row[PORT] = $stdin.gets.chomp
|
|
||||||
print "Enter a comment (optinal): "
|
|
||||||
row[COMMENT] = $stdin.gets.chomp
|
|
||||||
|
|
||||||
@data << "#{row.join(',')}\n"
|
@data << "#{row.join(',')}\n"
|
||||||
|
puts 'Item has been added!'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Update an item
|
# Update an item
|
||||||
|
@ -162,18 +157,12 @@ class ManagePasswd
|
||||||
|
|
||||||
puts "# Add a new password"
|
puts "# Add a new password"
|
||||||
puts "# --------------------"
|
puts "# --------------------"
|
||||||
print "Enter the server name or ip [#{row[SERVER]}]: "
|
server = ask("Enter the server name or ip [#{row[SERVER]}]: ")
|
||||||
server = $stdin.gets.chomp
|
type = ask("Enter the type of connection [#{row[TYPE]}]: ")
|
||||||
print "Enter the type of connection [#{row[TYPE]}]: "
|
login = ask("Enter the login connection [#{row[LOGIN]}]: ")
|
||||||
type = $stdin.gets.chomp
|
passwd = ask("Enter the the password: ")
|
||||||
print "Enter the login connection [#{row[LOGIN]}]: "
|
port = ask("Enter the connection port [#{row[PORT]}]: ")
|
||||||
login = $stdin.gets.chomp
|
comment = ask("Enter a comment [#{row[COMMENT]}]: ")
|
||||||
print "Enter the the password: "
|
|
||||||
passwd = $stdin.gets.chomp
|
|
||||||
print "Enter the connection port [#{row[PORT]}]: "
|
|
||||||
port = $stdin.gets.chomp
|
|
||||||
print "Enter a comment [#{row[COMMENT]}]: "
|
|
||||||
comment = $stdin.gets.chomp
|
|
||||||
|
|
||||||
row_update[ID] = row[ID]
|
row_update[ID] = row[ID]
|
||||||
server.empty? ? (row_update[SERVER] = row[SERVER]) : (row_update[SERVER] = server)
|
server.empty? ? (row_update[SERVER] = row[SERVER]) : (row_update[SERVER] = server)
|
||||||
|
@ -189,6 +178,7 @@ class ManagePasswd
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@data = data_tmp
|
@data = data_tmp
|
||||||
|
puts 'Item has been updated!'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Remove an item
|
# Remove an item
|
||||||
|
|
Loading…
Add table
Reference in a new issue