%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/scripts/
Upload File :
Create Path :
Current File : //proc/self/root/scripts/initialize_comet_backup

#!/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_comet_backup;

use cPstrict;

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

=encoding utf-8

=head1 USAGE

initialize_comet_backup [options]

=head1 DESCRIPTION

The script will perform the following steps:

=over

=item -Install the Comet Backup agent service on the server.

=item -Start the Comet Backup 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_comet_backup

    Show help information

      /usr/local/cpanel/scripts/initialize_comet_backup --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::CometBackup::Setup;

    my $user = eval { Whostmgr::CometBackup::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;

Zerion Mini Shell 1.0