public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: [pve-devel] applied: [PATCH v2 manager 1/2] vzdump: example hook script: avoid undef warnings
Date: Mon, 17 Jan 2022 16:32:09 +0100	[thread overview]
Message-ID: <1642433516.hfnnhixyv0.astroid@nora.none> (raw)
In-Reply-To: <20220117113559.77636-1-f.ebner@proxmox.com>

On January 17, 2022 12:35 pm, Fabian Ebner wrote:
> Some environment variables are undef in certain scenarios.
> 
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
> 
> 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
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 




      parent reply	other threads:[~2022-01-17 15:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17 11:35 [pve-devel] " Fabian Ebner
2022-01-17 11:35 ` [pve-devel] [PATCH v2 manager 2/2] close #3476: vzdump: add job-init hook Fabian Ebner
2022-01-17 15:37   ` Fabian Grünbichler
2022-01-17 15:54     ` Thomas Lamprecht
2022-01-17 15:32 ` Fabian Grünbichler [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1642433516.hfnnhixyv0.astroid@nora.none \
    --to=f.gruenbichler@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal