From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 9D35161763 for ; Mon, 17 Jan 2022 12:36:06 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 93668199E3 for ; Mon, 17 Jan 2022 12:36:06 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 1EBA2199CE for ; Mon, 17 Jan 2022 12:36:03 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E9467460B6 for ; Mon, 17 Jan 2022 12:36:02 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Mon, 17 Jan 2022 12:35:58 +0100 Message-Id: <20220117113559.77636-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.135 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v2 manager 1/2] vzdump: example hook script: avoid undef warnings X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Jan 2022 11:36:06 -0000 Some environment variables are undef in certain scenarios. Signed-off-by: Fabian Ebner --- New in v2. vzdump-hook-script.pl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/vzdump-hook-script.pl b/vzdump-hook-script.pl index 1be440b3..60edbc04 100755 --- a/vzdump-hook-script.pl +++ b/vzdump-hook-script.pl @@ -15,11 +15,16 @@ if ($phase eq 'job-start' || $phase eq 'job-end' || $phase eq 'job-abort') { + # undef for Proxmox Backup Server storages my $dumpdir = $ENV{DUMPDIR}; + # undef when --dumpdir is used directly my $storeid = $ENV{STOREID}; - print "HOOK-ENV: dumpdir=$dumpdir;storeid=$storeid\n"; + print "HOOK-ENV: "; + print "dumpdir=$dumpdir;" if defined($dumpdir); + print "storeid=$storeid;" if defined($storeid); + print "\n"; # do what you want @@ -37,8 +42,10 @@ if ($phase eq 'job-start' || my $vmtype = $ENV{VMTYPE}; # lxc/qemu + # undef for Proxmox Backup Server storages my $dumpdir = $ENV{DUMPDIR}; + # undef when --dumpdir is used directly my $storeid = $ENV{STOREID}; my $hostname = $ENV{HOSTNAME}; @@ -47,9 +54,14 @@ if ($phase eq 'job-start' || my $target = $ENV{TARGET}; # logfile is only available in phase 'log-end' + # undef for Proxmox Backup Server storages my $logfile = $ENV{LOGFILE}; - print "HOOK-ENV: vmtype=$vmtype;dumpdir=$dumpdir;storeid=$storeid;hostname=$hostname;target=$target;logfile=$logfile\n"; + print "HOOK-ENV: "; + for my $var (qw(vmtype dumpdir storeid hostname target logfile)) { + print "$var=$ENV{uc($var)};" if defined($ENV{uc($var)}); + } + print "\n"; # example: copy resulting backup file to another host using scp if ($phase eq 'backup-end') { -- 2.30.2