Server : Apache System : Linux copper.netcy.com 2.6.32-754.27.1.el6.centos.plus.x86_64 #1 SMP Thu Jan 30 13:54:25 UTC 2020 x86_64 User : montcaro ( 581) PHP Version : 7.4.28 Disable Function : NONE Directory : /scripts/ |
#!/bin/sh eval 'if [ -x /usr/local/cpanel/3rdparty/bin/perl ]; then exec /usr/local/cpanel/3rdparty/bin/perl -x -- $0 ${1+"$@"}; else exec /usr/bin/perl -x $0 ${1+"$@"}; fi;' ## no critic qw(ProhibitStringyEval RequireUseStrict) if 0; #!/usr/bin/perl # cpanel - scripts/dump_databases_and_users Copyright(c) 2014 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; BEGIN { unshift @INC, '/usr/local/cpanel'; } our $VERSION = '1.2'; # # No USE statements so this runs on other platforms # We must require everything in AFTER the version line # if ( @ARGV && grep( m/version/, @ARGV ) ) { print "dump_databases_and_users VERSION $VERSION\n"; exit(0); } require Cpanel::Config::Users; require Cpanel::DB::Map::Reader; require Cpanel::JSON; my @cpusers = Cpanel::Config::Users::getcpusers(); my $master_map = {}; foreach my $cpuser ( Cpanel::Config::Users::getcpusers() ) { my $dbmap = eval { Cpanel::DB::Map::Reader->new( cpuser => $cpuser, engine => 'mysql' ) }; if ($dbmap) { my @myusers = $dbmap->get_dbusers(); my @mydbs = $dbmap->get_databases(); my @pgusers = $dbmap->get_dbusers(); my @pgdbs = $dbmap->get_databases(); @{ $master_map->{'dbs'}{'PGSQL'} }{@pgdbs} = ( ( { 'owner' => $cpuser } ) x scalar @pgdbs ); @{ $master_map->{'dbs'}{'MYSQL'} }{@mydbs} = ( ( { 'owner' => $cpuser } ) x scalar @mydbs ); @{ $master_map->{'users'}{'PGSQL'} }{@pgusers} = ( ( { 'owner' => $cpuser } ) x scalar @pgusers ); @{ $master_map->{'users'}{'MYSQL'} }{@myusers} = ( ( { 'owner' => $cpuser } ) x scalar @myusers ); } } delete $master_map->{'users'}{'PGSQL'}{''}; delete $master_map->{'users'}{'MYSQL'}{''}; delete $master_map->{'dbs'}{'PGSQL'}{''}; delete $master_map->{'dbs'}{'MYSQL'}{''}; print Cpanel::JSON::Dump($master_map);