diff --git a/i18n/en.yml b/i18n/en.yml index 27a2d11..9a4781a 100644 --- a/i18n/en.yml +++ b/i18n/en.yml @@ -118,6 +118,10 @@ en: checkconfig: "Check the configuration" setup: "Setup a new configuration file" help: "Show this message help" + checkconfig: + fail: "Checkconfig failed:!" + empty: "ERROR: an importe option is missing!" + datadir: "ERROR: le data directory doesn't exist!" form: setup: title: "Serveur configuration" diff --git a/i18n/fr.yml b/i18n/fr.yml index 770dd21..74924b7 100644 --- a/i18n/fr.yml +++ b/i18n/fr.yml @@ -118,6 +118,10 @@ fr: checkconfig: "Vérifie le fichier de configuration" setup: "Permet de générer un nouveau fichier de configuration" help: "Affiche ce message d'aide" + checkconfig: + fail: "Le fichier de configuration est invalide!" + empty: "ERREUR: Une option importante est manquante!" + datadir: "ERREUR: Le répertoire des données n'existe pas!" form: setup: title: "Configuration du serveur" diff --git a/lib/Server.rb b/lib/Server.rb index 77ee2c2..699b355 100644 --- a/lib/Server.rb +++ b/lib/Server.rb @@ -15,7 +15,6 @@ class Server # Constructor def initialize() YAML::ENGINE.yamler='syck' - @error_msg = nil end # Start the server @@ -243,13 +242,20 @@ class Server @data_dir = config['config']['data_dir'] @timeout = config['config']['timeout'].to_i - if @host.empty? || @port.empty? - @error_msg = "Checkconfig failed!" + if @host.empty? || @port.empty? || @data_dir.empty? + puts I18n.t('server.checkconfig.fail') + puts I18n.t('server.checkconfig.empty') + return false + end + + if !Dir.exist?(@data_dir) + puts I18n.t('server.checkconfig.fail') + puts I18n.t('server.checkconfig.datadir') return false end rescue Exception => e - @error_msg = "Checkconfig failed!\n#{e}" + puts "#{I18n.t('server.checkconfig.fail')}\n#{e}" return false end