diff options
| author | Paul Buetow <paul@buetow.org> | 2022-04-13 21:45:00 +0100 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2022-04-13 21:45:00 +0100 |
| commit | 3ba81b44973475765bb2bc7000d8d5cc9b38ec1a (patch) | |
| tree | b59e6604ced9ef457a245a2cd25495bf8f62f593 /openbsd/frontends/usr | |
| parent | 5fb38230b986bef238c74a670a678e2488bea507 (diff) | |
more on ha.pl and rexification
Diffstat (limited to 'openbsd/frontends/usr')
| -rw-r--r-- | openbsd/frontends/usr/local/bin/ha.pl | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/openbsd/frontends/usr/local/bin/ha.pl b/openbsd/frontends/usr/local/bin/ha.pl new file mode 100644 index 0000000..d227a86 --- /dev/null +++ b/openbsd/frontends/usr/local/bin/ha.pl @@ -0,0 +1,43 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use Sys::Hostname; +use Getopt::Long; + +use constant STATUS_FILE => '/var/run/failover.status'; +use constant PARTNERS => qw(blowfish.buetow.org twofish.buetow.org); + +sub slurp { + my $file_path = shift; + open my $fd, $file_path or die $!; + my $data = <$fd>; + close $fd; + return $data; +} + +sub score { + for (PARTNERS) { + next if $_ eq hostname; # Ignore self + print "Trying $_\n"; + } +} + +sub inetd_response { + my $hostname = hostname; + print "OK: All is fine on $hostname itself!\n"; + print slurp STATUS_FILE if -f STATUS_FILE; +} + +sub main { + my ($inetd, $score) = (0, 0); + GetOptions('inetd' => \$inetd, + 'score' => \$score) + or die "Error in command line arguments!\n"; + + score if $score; + inetd_response if $inetd; +} + +main; |
