From c5083c05ff06811b88121a82916524bafab42418 Mon Sep 17 00:00:00 2001 From: Nicolas Vigier Date: Thu, 13 Jun 2013 15:21:41 +0000 Subject: Load config from home directory if file exists --- lib/MGA/Advisories.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm index ac7a734..cda9528 100644 --- a/lib/MGA/Advisories.pm +++ b/lib/MGA/Advisories.pm @@ -12,10 +12,12 @@ use Email::Simple::Creator; my $config_file = '/usr/share/mga-advisories/config'; my $config = LoadFile($ENV{MGAADV_CONF} || $config_file); -my $etc_config_file = '/etc/mga-advisories.conf'; -my $etc_config = LoadFile($etc_config_file); -foreach my $k (keys %$etc_config) { - $config->{$k} = $etc_config->{$k}; +my $home_config_file = $ENV{HOME} . '/.mga-advisories/mga-advisories.conf'; +my $custom_config_file = -f $home_config_file ? $home_config_file + : '/etc/mga-advisories.conf'; +my $custom_config = LoadFile($custom_config_file); +foreach my $k (keys %$custom_config) { + $config->{$k} = $custom_config->{$k}; } my %basename = ( -- cgit v1.2.1