mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-27 07:33:05 +00:00
add a directory conf
This commit is contained in:
parent
b52443f9f1
commit
d17a8b557e
4 changed files with 18 additions and 7 deletions
|
@ -27,13 +27,22 @@ module MPW
|
||||||
attr_accessor :sync_pwd
|
attr_accessor :sync_pwd
|
||||||
attr_accessor :sync_path
|
attr_accessor :sync_path
|
||||||
attr_accessor :last_update
|
attr_accessor :last_update
|
||||||
|
attr_accessor :dir_config
|
||||||
|
|
||||||
# Constructor
|
# Constructor
|
||||||
# @args: file_config -> the specify config file
|
# @args: file_config -> the specify config file
|
||||||
def initialize(file_config=nil)
|
def initialize(file_config=nil)
|
||||||
@error_msg = nil
|
@error_msg = nil
|
||||||
@file_config = "#{Dir.home}/.mpw.cfg"
|
|
||||||
|
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?
|
if !file_config.nil? && !file_config.empty?
|
||||||
@file_config = file_config
|
@file_config = file_config
|
||||||
end
|
end
|
||||||
|
@ -64,7 +73,7 @@ module MPW
|
||||||
end
|
end
|
||||||
|
|
||||||
if file_gpg.empty?
|
if file_gpg.empty?
|
||||||
file_gpg = "#{Dir.home}/.mpw.gpg"
|
file_gpg = "#{@dir_config}/db/default.gpg"
|
||||||
end
|
end
|
||||||
|
|
||||||
timeout_pwd = timeout_pwd.empty? ? 60 : timeout_pwd.to_i
|
timeout_pwd = timeout_pwd.empty? ? 60 : timeout_pwd.to_i
|
||||||
|
@ -82,6 +91,8 @@ module MPW
|
||||||
'sync_path' => sync_path,
|
'sync_path' => sync_path,
|
||||||
'last_update' => 0 }}
|
'last_update' => 0 }}
|
||||||
|
|
||||||
|
Dir.mkdir("#{@config_dir}/conf", 700)
|
||||||
|
Dir.mkdir("#{@config_dir}/db", 700)
|
||||||
File.open(@file_config, 'w') do |file|
|
File.open(@file_config, 'w') do |file|
|
||||||
file << config.to_yaml
|
file << config.to_yaml
|
||||||
end
|
end
|
||||||
|
|
|
@ -77,7 +77,7 @@ class Cli
|
||||||
language = ask(I18n.t('form.setup.lang', :lang => lang)).to_s
|
language = ask(I18n.t('form.setup.lang', :lang => lang)).to_s
|
||||||
key = ask(I18n.t('form.setup.gpg_key')).to_s
|
key = ask(I18n.t('form.setup.gpg_key')).to_s
|
||||||
share_keys = ask(I18n.t('form.setup.share_gpg_keys')).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
|
timeout_pwd = ask(I18n.t('form.setup.timeout')).to_s
|
||||||
sync_type = ask(I18n.t('form.setup.sync_type')).to_s
|
sync_type = ask(I18n.t('form.setup.sync_type')).to_s
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ en:
|
||||||
lang: "Choose your language (en, fr, ...): "
|
lang: "Choose your language (en, fr, ...): "
|
||||||
gpg_key: "Enter the GPG key: "
|
gpg_key: "Enter the GPG key: "
|
||||||
share_gpg_keys: "Enter the GPG keys with who you want to share the passwords: "
|
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]: "
|
timeout: "Enter the timeout (in seconde) to GPG password [default=60]: "
|
||||||
sync_type: "Synchronization type (mpw, ssh, ftp, or nil): "
|
sync_type: "Synchronization type (mpw, ssh, ftp, or nil): "
|
||||||
sync_host: "Synchronization server: "
|
sync_host: "Synchronization server: "
|
||||||
|
|
|
@ -73,7 +73,7 @@ fr:
|
||||||
lang: "Choisissez votre langue (en, fr, ...) [défaut=%{lang}]: "
|
lang: "Choisissez votre langue (en, fr, ...) [défaut=%{lang}]: "
|
||||||
gpg_key: "Entrez la clé GPG: "
|
gpg_key: "Entrez la clé GPG: "
|
||||||
share_gpg_keys: "Entrez les clés GPG avec qui vous voulez partager les mots de passe: "
|
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]: "
|
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_type: "Type de synchronisation (mpw, ssh, ftp, or nil): "
|
||||||
sync_host: "Serveur de synchronisation: "
|
sync_host: "Serveur de synchronisation: "
|
||||||
|
|
Loading…
Reference in a new issue