CHips L MINI SHELL

CHips L pro

Current Path : /proc/2/cwd/scripts/
Upload File :
Current File : //proc/2/cwd/scripts/sync_contact_emails_to_cpanel_users_files

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

package scripts::sync_contact_emails_to_cpanel_users_files;

# cpanel - scripts/sync_contact_emails_to_cpanel_users_files
#                                                    Copyright 2018 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

use strict;
use warnings;

use parent qw( Cpanel::HelpfulScript );

use constant _OPTIONS => ('force');

=encoding utf-8

=head1 NAME

sync_contact_emails_to_cpanel_users_files

=head1 SYNOPSIS

sync_contact_emails_to_cpanel_users_files [ --help | --force ]

=head1 DESCRIPTION

This command will attempt to see if there are missing notification/contact related keys in all the CPUSER files
for the users on the system. If there are keys missing, it will sync data from /home/$user/.cpanel/contactinfo
to the user's CPUSER file.

If the --force flag is passed, the script will sync the notifications/contact settings from the user's homedir
even if there aren't missing keys.

=cut

if ( !caller() ) {
    __PACKAGE__->new(@ARGV)->run();
    exit 0;
}

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

    die "This must run as root!\n" if $>;

    if ( !$self->getopt('force') ) {
        require Cpanel::Config::LoadUserDomains;
        require Cpanel::ContactInfo;
        my $user_to_domains_map = Cpanel::Config::LoadUserDomains::loaduserdomains( undef, 0, 1 );
        Cpanel::ContactInfo::fetch_contactinfo($user_to_domains_map);
    }
    else {
        require Cpanel::ContactInfo::Sync;
        Cpanel::ContactInfo::Sync::sync_all_users_contact_info();
    }

    return;
}

1;

Copyright 2K16 - 2K18 Indonesian Hacker Rulez