Local modifications to ClusterLabs/Anvil by Alteeve
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.2 KiB

#!/usr/bin/perl
#
use strict;
use warnings;
use Anvil::Tools;
use Data::Dumper;
# Disable buffering
$| = 1;
# Prevent a discrepency between UID/GID and EUID/EGID from throwing an error.
$< = $>;
$( = $);
my $THIS_FILE = ($0 =~ /^.*\/(.*)$/)[0];
my $running_directory = ($0 =~ /^(.*?)\/$THIS_FILE$/)[0];
if (($running_directory =~ /^\./) && ($ENV{PWD}))
{
$running_directory =~ s/^\./$ENV{PWD}/;
}
my $anvil = Anvil::Tools->new();
# Make sure we're running as 'root'
# $< == real UID, $> == effective UID
if (($< != 0) && ($> != 0))
{
# Not root
print $anvil->Words->string({key => "error_0005"})."\n";
$anvil->nice_exit({exit_code => 1});
}
$anvil->data->{switches}{level} = "";
$anvil->data->{switches}{message} = "";
$anvil->Get->switches;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0115", variables => { program => $THIS_FILE }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
'switches::level' => $anvil->data->{switches}{level},
'switches::message' => $anvil->data->{switches}{message},
}});
my $level = "";
if (($anvil->data->{switches}{level} eq "1") or (lc($anvil->data->{switches}{level}) eq "critical"))
{
$level = "critical";
}
elsif (($anvil->data->{switches}{level} eq "2") or (lc($anvil->data->{switches}{level}) eq "warning"))
{
$level = "warning";
}
elsif (($anvil->data->{switches}{level} eq "3") or (lc($anvil->data->{switches}{level}) eq "notice"))
{
$level = "notice";
}
elsif (($anvil->data->{switches}{level} eq "4") or (lc($anvil->data->{switches}{level}) eq "info"))
{
$level = "info";
}
if ((not $anvil->data->{switches}{level}) or (not $level))
{
print $anvil->Words->string({key => "error_0362", variables => { level => $anvil->data->{switches}{level} }})."\n";
$anvil->nice_exit({exit_code => 1});
}
$anvil->nice_exit({exit_code => 0});
#############################################################################################################
# Functions #
#############################################################################################################