MSV FM

[email protected]: ~ $
Path : /scripts/
File Upload :
Current < : //scripts/ensure_cpuser_file_ip

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

# cpanel - scripts/ensure_cpuser_file_ip           Copyright 2022 cPanel, L.L.C.
#                                                           All rights reserved.
# [email protected]                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

package scripts::ensure_cpuser_file_ip;

use strict;
use warnings;

=encoding utf-8

=head1 USAGE

    ensure_cpuser_file_ip [--help]

=head1 DESCRIPTION

This script examines each cPanel user and ensures that the
user’s IP address is recorded properly. If not, the script will examine
try to copy the IP address from the user’s web vhost configuration.

This script runs automatically on upgrade to v76 and should not normally
need to be called manually.

=cut

use parent qw( Cpanel::HelpfulScript );

use Try::Tiny;

use Cpanel::Config::CpUserGuard    ();
use Cpanel::Config::Users          ();
use Cpanel::Config::userdata::Load ();

use constant _OPTIONS => ();

*_get_all_cpusers = \*Cpanel::Config::Users::getcpusers;

__PACKAGE__->new(@ARGV)->run() if !caller;

sub run {
    my ($self) = @_;

    for my $username ( sort( _get_all_cpusers() ) ) {
        $self->say("$username …");

        try {
            my $cpuser = Cpanel::Config::CpUserGuard->new($username);

            if ( $cpuser->{'data'}{'IP'} && ( '127.0.0.1' ne $cpuser->{'data'}{'IP'} ) ) {
                $cpuser->abort();
            }
            else {
                $self->say("\tDeducing “IP” …");

                $cpuser->{'data'}{'IP'} = _deduce_user_ip( $username, $cpuser );
                $self->say("\tDeduced: $cpuser->{'data'}{'IP'}");

                $cpuser->save();
                $self->say("\tSaved!");
            }
        }
        catch {
            warn $_;
        };
    }

    return;
}

sub _deduce_user_ip {
    my ( $username, $cpuser_obj ) = @_;

    my @domains = (
        $cpuser_obj->{'data'}{'DOMAIN'},
        @{ $cpuser_obj->{'data'}{'DOMAINS'} },
    );

    for my $d (@domains) {
        next if !Cpanel::Config::userdata::Load::user_has_domain( $username, $d );

        my $ref = Cpanel::Config::userdata::Load::load_userdata_domain( $username, $d );

        if ( $ref && %$ref ) {
            return $ref->{'ip'} if $ref->{'ip'};

            warn "“$username”’s vhost “$d” file lacks “ip”!\n";
        }
        else {
            warn "“$username”’s web vhost “$d” failed to load??\n";
        }
    }

    die "Found no IP address among “$username”’s web vhosts!";
}

1;
Bethany
Bethany
0%

THE FINEST HOTEL NEAR LAKE KIVU

The Perfect Base For You

Required fields are followed by *





EC1A68011

About Us

Delicious Interior With The Pinch Of Everything

Bethany Investment group is Presbyterian church in Rwanda(EPR) company that manage Hotel and Guest house in Karongi (Bethany Hotel), ISANO branch in GIKONDO(Kigali), Kiyovu branch(Kigali), AMIZERO branch(Nyagatare-East) and Gisenyi Branch(Rubavu).

Accomodation

Get a Comfortable Room
Feel The Comfort

Get a comfortable room and feel our hotel’s comfort. Bethany Hotel features a variety of fully furnished rooms with extra space, Executive rooms, Deluxe rooms with a beautiful lake view and garden space, Deluxe rooms, comfort rooms, family rooms and standard rooms at your service.

Standard Single

Services

We Provide Top Class Facility
Especially For You

Beach BBQ Party

Kick back on the beach& and enjoy our berbecue from our masterchef

Breakfast

Kick back at our hotels& enjoy our breakfast from our masterchef

Conference Hall

Kick back at our hotels& enjoy our conference halls from all bethany branches

Enjoy with your partner

Honeymoon Package

80%

Get In Touch

Don’t Miss Any Update

    +

    Search your Room

    Required fields are followed by *