mirror of https://github.com/dani/patrix.git
Check config readability and global /etc/patrixrc
This commit is contained in:
parent
5aec50e85e
commit
1fc700a56e
|
@ -52,13 +52,29 @@ GetOptions(
|
||||||
"perm_reset|reset-permission" => \$opt->{perm_reset}
|
"perm_reset|reset-permission" => \$opt->{perm_reset}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (-e File::HomeDir->my_home . "/.patrixrc" && !$opt->{conf}){
|
if (!$opt->{conf}){
|
||||||
$opt->{conf} = File::HomeDir->my_home . "/.patrixrc";
|
# Read global config if it exists and is readable
|
||||||
debug("Using default config file $opt->{conf}");
|
if (-f '/etc/patrixrc' && open(CONFIG, '<', '/etc/patrixrc')){
|
||||||
|
$opt->{conf} = '/etc/patrixrc';
|
||||||
|
close CONFIG;
|
||||||
|
debug("Using global config file $opt->{conf}");
|
||||||
|
}
|
||||||
|
|
||||||
|
# If there's a user defined config, use it instead
|
||||||
|
if (-f File::HomeDir->my_home . "/.patrixrc" && open(CONFIG, '<', File::HomeDir->my_home . "/.patrixrc")){
|
||||||
|
$opt->{conf} = File::HomeDir->my_home . "/.patrixrc";
|
||||||
|
close CONFIG;
|
||||||
|
debug("Using default config file $opt->{conf}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($opt->{conf} && -e $opt->{conf}){
|
if ($opt->{conf} && -e $opt->{conf}){
|
||||||
read_conf();
|
read_conf();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
die "No configuration found.\nYou should either create one in ~/.patrixrc " .
|
||||||
|
"or give the path of a custom config with --config /path/to/patrixrc";
|
||||||
|
}
|
||||||
|
|
||||||
# alias for --action=foo is --foo
|
# alias for --action=foo is --foo
|
||||||
my @actions = qw(
|
my @actions = qw(
|
||||||
|
|
Loading…
Reference in New Issue