From cfe4db88e1cc9e24e3fccee1e80001e5a85fcc56 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Wed, 31 Mar 2021 09:12:14 +0200 Subject: [PATCH] pdist: Add option --set-pdist-status Add option --set-pdist-status. This option make the client write a status file /.pdist_status when everything completed successfully. It is supposed to be used only during full dists from the distmaster. The idea is that health check scripts can look at the status file and the embededed time tag to find out when a system was successfully updated and generate an alarm if this is to long in the past. --- pdist/pdist | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pdist/pdist b/pdist/pdist index f474963..bdc21cc 100755 --- a/pdist/pdist +++ b/pdist/pdist @@ -187,7 +187,7 @@ $SIG{PIPE} = sub {clean_tmp();exit 1;}; # options -our ($debug,$quiet,$fileop_noop,$fileop_debug,$delete); +our ($debug,$quiet,$fileop_noop,$fileop_debug,$delete,$set_pdist_status); our ($verbose,$timeout,@files,$ssh_tunnel,$post_command,$parallel,$prompt,$msg_prefix); our ($distfilename) = (DISTFILE); @@ -829,6 +829,13 @@ sub prog_update warn "$fn: $!\n"; } } + + if ( !$fileop_noop && $set_pdist_status) { + my $t=time; + open L,'>','/.pdist_status' or die "/.pdist_status: $!\n"; + print L 'OK',$t,scalar(localtime($t)); + close L; + } } if ($function==F_REQUEST) { @@ -1014,6 +1021,8 @@ sub push_single $fileop_debug and push @remote_opts,'--fileop_debug'; $debug and push @remote_opts,'--debug'; push @remote_opts,$delete ? '--delete' : '--nodelete'; + $set_pdist_status and push @remote_opts,'--set-pdist-status'; + $post_command and push @remote_opts,'--post-command='.quotemeta($post_command); $parallel && $parallel>1 and push @remote_opts,'--msg-prefix',$client; @@ -1186,6 +1195,7 @@ usage: $0 cmd [options] --fileop_debug # log all file operations --[no]delete # do or do not clean up additional files on client. # default is delete unless --files is used + --set-pdist-status # force creation of /.pdist_status on target --verbose # be more verbose --fileop_noop # DEPRECATED: now --noop @@ -1222,6 +1232,7 @@ use constant OPTIONS => ( 'fileop_debug' => \$fileop_debug, 'delete!' => \$delete, + 'set-pdist-status' => \$set_pdist_status, 'verbose' => \$verbose, 'debug' => \$debug,