Kerala Cyber Warriors
KCW Uploader V1.1

Path : /proc/thread-self/root/scripts/
File Upload :
Current File : //proc/thread-self/root/scripts/initialize_360monitoring

#!/usr/local/cpanel/3rdparty/bin/perl

#                                      Copyright 2024 WebPros International, LLC
#                                                            All rights reserved.
# copyright@cpanel.net                                          http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited.

package scripts::initialize_360monitoring;

use cPstrict;

use Getopt::Long ();
use Pod::Usage   qw(pod2usage);

=encoding utf-8

=head1 USAGE

initialize_360monitoring [options]

=head1 DESCRIPTION

The script will perform the following steps:

=over

=item -Create the 360 Monitoring SaaS user.

=item -Create and storing the SaaS API key for that user so they can access select 360 Monitoring API's.

=item -Install any missing dependencies for the agent360 service.

=item -Install the agent360 service on the server.

=item -Configure the agent360 optional plugins supported by your install of cPanel and WHM.

=item -Restart the agent360 service.

=back

NOTE: If any of the above items are missing or non-operational the script will attempt to fix those issues.


  Options

  --help      Show the help for this script.

  --verbose   Provide more output while processing the request.

=head1 EXAMPLES

    Initialize the server

        /usr/local/cpanel/scripts/initialize_360monitoring

    Show help information

      /usr/local/cpanel/scripts/initialize_360monitoring --help

=cut

my $verbose = '';    # boolean switch - not implemented
my $help    = '';    # view the help

exit run(@ARGV) if !caller;

sub run (@args) {

    my $ok;
    {
        # Capture and format errors from Getopt::Long::GetOptionsFromArray
        local $SIG{__WARN__} = sub ($text) {
            say STDERR "ERROR: $text";
        };

        $ok = Getopt::Long::GetOptionsFromArray(
            \@args,
            "verbose" => \$verbose,
            "help"    => \$help,
        );
    }

    if ( !$ok ) {
        help(1);
        return 1;
    }

    if ($help) {
        help();
        return 0;
    }

    require Whostmgr::360Monitoring::Setup;

    my $user = eval { Whostmgr::360Monitoring::Setup::initialize(); };
    if ( my $exception = $@ ) {
        say STDERR $exception;
        return 1;
    }

    return 0;
}

sub help ( $error = undef ) {
    if ($error) {
        if ( $error eq '1' ) {

            # no message, we already printed the error
            pod2usage( -exitvalue => 'NOEXIT', -verbose => 2, -output => \*STDERR );
        }
        else {
            # all other errors
            pod2usage( -message => $error, -exitvalue => 'NOEXIT', -verbose => 2, -output => \*STDERR );
        }
    }
    else {
        # non-error
        pod2usage( -exitvalue => 'NOEXIT', -verbose => 2, -output => \*STDERR );
    }

    return 0;
}

1;

-=[ KCW uplo4d3r c0ded by cJ_n4p573r ]=-
Ⓒ2017 ҠЄГѦLѦ СүѣЄГ ЩѦГГіѺГՏ