1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-23 05:47:53 +00:00

add a directory conf

This commit is contained in:
nishiki 2014-04-27 18:53:20 +02:00
parent b52443f9f1
commit d17a8b557e
4 changed files with 18 additions and 7 deletions

View file

@ -27,13 +27,22 @@ module MPW
attr_accessor :sync_pwd
attr_accessor :sync_path
attr_accessor :last_update
attr_accessor :dir_config
# Constructor
# @args: file_config -> the specify config file
def initialize(file_config=nil)
@error_msg = nil
@file_config = "#{Dir.home}/.mpw.cfg"
@error_msg = nil
if /darwin/ =~ RUBY_PLATFORM
@dir_config = "#{Dir.home}/Library/Preferences/mpw"
elsif /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
@dir_config = "#{Dir.home}/AppData/Local/mpw"
else
@dir_config = "#{Dir.home}/.config/mpw"
end
@file_config = "#{@dir_config}/conf/default.cfg"
if !file_config.nil? && !file_config.empty?
@file_config = file_config
end
@ -64,7 +73,7 @@ module MPW
end
if file_gpg.empty?
file_gpg = "#{Dir.home}/.mpw.gpg"
file_gpg = "#{@dir_config}/db/default.gpg"
end
timeout_pwd = timeout_pwd.empty? ? 60 : timeout_pwd.to_i
@ -82,6 +91,8 @@ module MPW
'sync_path' => sync_path,
'last_update' => 0 }}
Dir.mkdir("#{@config_dir}/conf", 700)
Dir.mkdir("#{@config_dir}/db", 700)
File.open(@file_config, 'w') do |file|
file << config.to_yaml
end

View file

@ -77,7 +77,7 @@ class Cli
language = ask(I18n.t('form.setup.lang', :lang => lang)).to_s
key = ask(I18n.t('form.setup.gpg_key')).to_s
share_keys = ask(I18n.t('form.setup.share_gpg_keys')).to_s
file_gpg = ask(I18n.t('form.setup.gpg_file', :home => Dir.home)).to_s
file_gpg = ask(I18n.t('form.setup.gpg_file', :home => @conf.dir_home)).to_s
timeout_pwd = ask(I18n.t('form.setup.timeout')).to_s
sync_type = ask(I18n.t('form.setup.sync_type')).to_s

View file

@ -73,7 +73,7 @@ en:
lang: "Choose your language (en, fr, ...): "
gpg_key: "Enter the GPG key: "
share_gpg_keys: "Enter the GPG keys with who you want to share the passwords: "
gpg_file: "Enter the path to encrypt file [default=%{home}/.mpw.gpg]: "
gpg_file: "Enter the path to encrypt file [default=%{home}/db/default.gpg]: "
timeout: "Enter the timeout (in seconde) to GPG password [default=60]: "
sync_type: "Synchronization type (mpw, ssh, ftp, or nil): "
sync_host: "Synchronization server: "

View file

@ -73,7 +73,7 @@ fr:
lang: "Choisissez votre langue (en, fr, ...) [défaut=%{lang}]: "
gpg_key: "Entrez la clé GPG: "
share_gpg_keys: "Entrez les clés GPG avec qui vous voulez partager les mots de passe: "
gpg_file: "Entrez le chemin du fichier qui sera chiffré [défaut=%{home}/.mpw.gpg]: "
gpg_file: "Entrez le chemin du fichier qui sera chiffré [défaut=%{home}/db/default.gpg]: "
timeout: "Entrez le temps (en seconde) du mot de passe GPG [défaut=60]: "
sync_type: "Type de synchronisation (mpw, ssh, ftp, or nil): "
sync_host: "Serveur de synchronisation: "