From 2720ef3bc81482095f496e0e329cf4645f08daf2 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Wed, 31 Mar 2021 09:12:14 +0200 Subject: [PATCH] pdist: Add option --force_status Add option --force_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 f4749633..1f308397 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,$force_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 && $force_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'; + $force_status and push @remote_opts,'--force_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 + --force_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, + 'force_status' => \$force_status, 'verbose' => \$verbose, 'debug' => \$debug,