change configuration file name ~/.config/pveclient/config
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 15 Jun 2018 05:34:37 +0000 (07:34 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 15 Jun 2018 07:17:29 +0000 (09:17 +0200)
PVE/APIClient/Config.pm

index 249ef83..910e9c5 100644 (file)
@@ -3,7 +3,10 @@ package PVE::APIClient::Config;
 use strict;
 use warnings;
 use JSON;
+use File::Basename qw(dirname);
+use File::Path qw(make_path);
 
+use PVE::APIClient::Helpers;
 use PVE::APIClient::JSONSchema;
 use PVE::APIClient::SectionConfig;
 use PVE::APIClient::PTY;
@@ -56,11 +59,9 @@ sub private {
 sub config_filename {
     my ($class) = @_;
 
-    my $home = $ENV{HOME};
+    my $dir = PVE::APIClient::Helpers::configuration_directory();
 
-    die "environment HOME not set\n" if !defined($home);
-
-    return "$home/.pveclient";
+    return "$dir/config";
 }
 
 sub format_section_header {
@@ -113,6 +114,8 @@ sub save {
 
     my $filename = $class->config_filename();
 
+    make_path(dirname($filename));
+
     $cfg->{order}->{$defaults_section} = -1; # write as first section
     my $raw = $class->write_config($filename, $cfg);