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 3C1A6617F6 for ; Mon, 17 Jan 2022 16:32:18 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 31C7B1CCDD for ; Mon, 17 Jan 2022 16:32:18 +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 752D91CCD0 for ; Mon, 17 Jan 2022 16:32:16 +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 4C0F0460C0 for ; Mon, 17 Jan 2022 16:32:16 +0100 (CET) Date: Mon, 17 Jan 2022 16:32:09 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20220117113559.77636-1-f.ebner@proxmox.com> In-Reply-To: <20220117113559.77636-1-f.ebner@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1642433516.hfnnhixyv0.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.220 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] applied: [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 15:32:18 -0000 On January 17, 2022 12:35 pm, Fabian Ebner wrote: > Some environment variables are undef in certain scenarios. >=20 > Signed-off-by: Fabian Ebner > --- >=20 > New in v2. >=20 > vzdump-hook-script.pl | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) >=20 > 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') { > =20 > + # undef for Proxmox Backup Server storages > my $dumpdir =3D $ENV{DUMPDIR}; > =20 > + # undef when --dumpdir is used directly > my $storeid =3D $ENV{STOREID}; > =20 > - print "HOOK-ENV: dumpdir=3D$dumpdir;storeid=3D$storeid\n"; > + print "HOOK-ENV: "; > + print "dumpdir=3D$dumpdir;" if defined($dumpdir); > + print "storeid=3D$storeid;" if defined($storeid); > + print "\n"; > =20 > # do what you want > =20 > @@ -37,8 +42,10 @@ if ($phase eq 'job-start' || > =20 > my $vmtype =3D $ENV{VMTYPE}; # lxc/qemu > =20 > + # undef for Proxmox Backup Server storages > my $dumpdir =3D $ENV{DUMPDIR}; > =20 > + # undef when --dumpdir is used directly > my $storeid =3D $ENV{STOREID}; > =20 > my $hostname =3D $ENV{HOSTNAME}; > @@ -47,9 +54,14 @@ if ($phase eq 'job-start' || > my $target =3D $ENV{TARGET}; > =20 > # logfile is only available in phase 'log-end' > + # undef for Proxmox Backup Server storages > my $logfile =3D $ENV{LOGFILE}; > =20 > - print "HOOK-ENV: vmtype=3D$vmtype;dumpdir=3D$dumpdir;storeid=3D$stor= eid;hostname=3D$hostname;target=3D$target;logfile=3D$logfile\n"; > + print "HOOK-ENV: "; > + for my $var (qw(vmtype dumpdir storeid hostname target logfile)) { > + print "$var=3D$ENV{uc($var)};" if defined($ENV{uc($var)}); > + } > + print "\n"; > =20 > # example: copy resulting backup file to another host using scp > if ($phase eq 'backup-end') { > --=20 > 2.30.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20