[pve-devel] [PATCH pve-client 2/2] change configuration file name ~/.config/pveclient/config

Dietmar Maurer dietmar at proxmox.com
Fri Jun 15 07:46:44 CEST 2018


Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 PVE/APIClient/Config.pm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/PVE/APIClient/Config.pm b/PVE/APIClient/Config.pm
index 249ef83..910e9c5 100644
--- a/PVE/APIClient/Config.pm
+++ b/PVE/APIClient/Config.pm
@@ -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);
 
-- 
2.11.0




More information about the pve-devel mailing list