#!/usr/bin/perl

=head1 pfupdate

Update configuration values to prevent some services to run on slave member

=cut

use constant INSTALL_DIR => '/usr/local/pf';
use lib (INSTALL_DIR . "/lib", INSTALL_DIR . "/lib_perl/lib/perl5");

use Getopt::Long;
use pf::util;
use pf::config qw(
    %Config
);

my $mode;
my $vip;
my $custom_script_path = $Config{'advanced'}{'pfupdate_custom_script_path'};

GetOptions(
    "mode=s" => \$mode,
    "vip=s" => \$vip,
) ;

if (! ($mode =~ /^master|slave$/)) {
    exit;
}

pf_run("pkill -1 pfdhcplistener");

if (-e "$custom_script_path" && -x "$custom_script_path") {
    print "Running $custom_script_path\n";
    pf_run("$custom_script_path $mode $vip");
}
