/opt/dedrads
NameSizeModeActions
account_review/-0555rm
check_software_mods/-0555rm
cms_tools/-0555rm
etc/-0555rm
extras/-0555rm
mailparse/-0555rm
mysql/-0555rm
nlp_scripts/-0555rm
oldrads/-0555rm
perl/-0555rm
provision/-0555rm
python/-0555rm
suspended/-0555rm
__pycache__/-0555rm
account-review7990555editdlrm
allfw62590555editdlrm
alp.py165530555editdlrm
autossl_sync62670555editdlrm
check_apache92050555editdlrm
check_bandwidth45460555editdlrm
check_boxtrapper16840555editdlrm
check_cpu122120555editdlrm
check_crons18270555editdlrm
check_dcpumon19730555editdlrm
check_dns18270555editdlrm
check_domlogs610555editdlrm
check_exim37310555editdlrm
check_hacks226040555editdlrm
check_imap52490555editdlrm
check_io66350555editdlrm
check_max_children163410555editdlrm
check_mem16600555editdlrm
check_misc15100555editdlrm
check_pacct52010555editdlrm
check_php43440555editdlrm
check_pop322950555editdlrm
check_prov.py47140555editdlrm
check_server6960555editdlrm
check_size4900555editdlrm
check_software98490555editdlrm
check_spamd24260555editdlrm
check_traffic19330555editdlrm
check_user18870555editdlrm
clean_exim.py63900555editdlrm
clusterfix53430555editdlrm
cmspass.py39700555editdlrm
cms_check.py98250555editdlrm
cms_counter.py367340555editdlrm
cms_creds7130555editdlrm
cms_dumpdb44850555editdlrm
cms_pw14160555editdlrm
cpanel-api70400555editdlrm
cpanel_postgres_manager.py290040555editdlrm
cpmerge46310555editdlrm
cpumon21950555editdlrm
dcpumon.pl12390555editdlrm
dedcheck181270555editdlrm
dns-sync143860555editdlrm
docroot.py44250555editdlrm
du-tree74500555editdlrm
envinfo.py66330555editdlrm
exclude_rbl.py52490555editdlrm
extract-vhost26910555editdlrm
filescan35660555editdlrm
find_warez14600555editdlrm
first_setup.py191200555editdlrm
fixwpcron.py48220555editdlrm
fix_dns_cluster3530555editdlrm
goaccess12177200555editdlrm
hostsfilemods44670555editdlrm
imap_io23230555editdlrm
innodb_converter.py93430555editdlrm
killall9115300555editdlrm
killdns9410555editdlrm
lastcommcache.sh13740555editdlrm
legal_lock_down.sh74500555editdlrm
lil-cpanel520020555editdlrm
listacct45750555editdlrm
mailscan45440555editdlrm
mail_sources.py74070555editdlrm
megaclisas-status386640555editdlrm
migrate2central.sh144180555editdlrm
modify-account406310555editdlrm
modsec_disable.py114610555editdlrm
monarxctl89120555editdlrm
msp.pl277140555editdlrm
mysql_dstat4740555editdlrm
mysql_selector.py731020555editdlrm
nlp45820555editdlrm
procscrape18630555editdlrm
quarantine110830555editdlrm
radsfunctions.sh8630555editdlrm
recent-cp161480555editdlrm
remote_dump183470555editdlrm
reset_cpanel32050555editdlrm
server-load21920555editdlrm
show-conns201050555editdlrm
show-conns-adv.py546670555editdlrm
sparta.py3824980555editdlrm
sqltop271290555editdlrm
telcheck24110555editdlrm
temprootreset1860555editdlrm
unsuspend_user13070555editdlrm
unsusprunner.sh18400555editdlrm
updatednsadmin5260555editdlrm
update_spf149720555editdlrm
upgrade-check92160555editdlrm
vhost_data.py62210555editdlrm
wp-xray.sh858160555editdlrm
Edit: /opt/dedrads/cpanel-api (7040B)
#!/usr/bin/perl # encoding: utf-8 # # author: Kyle Yetter # =begin =head1 call-api call-api - Change the basic configuration of a cPanel account. =head1 SYNOPSIS call-api [options] I I=I ... call-api [options] -1 I I I I ... I call-api [options] -2 I I I I=I ... =head1 DESCRIPTION Run a cPanel remote API call and dump the server response in a variety of formats See the following documenation pages for the cPanel API to learn more about API calls and the functions they provide. http://docs.cpanel.net/twiki/bin/view/SoftwareDevelopmentKit/XmlApi http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api1/WebHome http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api2/WebHome =head1 OPTIONS =over 8 =item B<-1>, B<--modular-v1> Specify the call as being a v1 module API function. =item B<-2>, B<--module-v2> Specify the call as being a v2 module API function. =item B<-D>, B<--debug> Print the WHM API URI sent to the server and dump the resulting data structure =item B<-x>, B<--xml> Run the call through cPanel's XML API and output the XML result =item B<-j>, B<--json> Run the call through cPanel's JSON API and output the raw JSON result =item B<-y>, B<--yaml> Run the call through cPanel's JSON API and dump the output data in YAML format =item B<-b>, B<--bleach>, B<--no-color> Do not use color escapes in the output =item B<-h>, B<--help> You know the drill =item B<-v>, B<--version> Ditto =back =cut # to skip certificate verification $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; our $VERSION = 1.3; use strict; use LWP::UserAgent; use URI; use File::Basename; use File::Slurp qw( slurp read_dir ); use Getopt::Long; use JSON::Syck; use Term::ANSIColor; use Pod::Usage; our $BASIC = 0; our $MODULAR_V1 = 1; our $MODULAR_V2 = 2; our $API_TYPE = 'json'; our $FORMAT = 'yaml'; our $BASE_PATH = undef; # display extra debugging info if true our $DEBUG = 0; # if true, don't colorize output with ANSI escape sequences our $BLEACH = 0; # specifies whether this is a basic or modular API call our $CALL_MODE = $BASIC; # set to 1 if we had to generate an access key our $CREATED_ACCESS_HASH = 0; our $ACCESS_KEY; END { # # If we had to create a temporary access hash to make this work, # make sure it gets trashed # if ( -f '/root/.accesshash' && $CREATED_ACCESS_HASH ) { unlink( '/root/.accesshash' ) or die( "failed to remove /root/.accesshash" ); } } sub c($$) { my ( $str, $style ) = @_; $str = colored( $str, $style ) unless $BLEACH; return $str; } sub d { if ( $DEBUG ) { my ( $fmt, @params ) = @_; local $\ = "\n"; my $message = c( sprintf( $fmt, @params ), 'cyan' ); print STDERR "DEBUG: $message"; } } sub access_key { if ( $ACCESS_KEY ) { return $ACCESS_KEY; } unless ( -f '/root/.accesshash' ) { $ENV{ REMOTE_USER } = 'root'; `/usr/local/cpanel/bin/mkaccesshash`; delete $ENV{ REMOTE_USER }; $CREATED_ACCESS_HASH = 1; } if ( -f '/root/.accesshash' ) { $ACCESS_KEY = slurp( "/root/.accesshash" ) or die "could not read /root/.accesshash: $!"; $ACCESS_KEY =~ s/\n//g; } else { die "could not read /root/.accesshash: $!"; } return $ACCESS_KEY; } sub load_json($) { my ( $source ) = @_; my $data; eval { $data = JSON::Syck::Load( $source ); }; if ( $@ ) { die( $@ . "\nJSON SOURCE:\n" . $source ); } return $data; } sub api_call($%) { my $function = shift; my %params = @_; my $uri_base = ( $BASE_PATH || "$API_TYPE-api" ); my $uri = URI->new( "https://127.0.0.1:2087/$uri_base/$function" ); $uri->query_form( %params ); d "query URI: %s", $uri; my $auth = "WHM root:" . access_key(); my $ua = LWP::UserAgent->new; my $request = HTTP::Request->new( GET => "$uri" ); $request->header( Authorization => $auth ); my $response = $ua->request( $request ); return $response->content; } sub modular_api_v1($$$@) { my $user = shift; my $module = shift; my $func = shift; my @args = @_; my %opts = ( "cpanel_${API_TYPE}api_user" => $user, "cpanel_${API_TYPE}api_module" => $module, "cpanel_${API_TYPE}api_func" => $func, "cpanel_${API_TYPE}api_apiversion" => 1 ); for my $i ( 0 .. $#args ) { $opts{ "arg-$i" } = $args[ $i ]; } return api_call( 'cpanel', %opts ); } sub modular_api_v2($$$%) { my $user = shift; my $module = shift; my $func = shift; my %opts = ( "cpanel_${API_TYPE}api_user" => $user, "cpanel_${API_TYPE}api_module" => $module, "cpanel_${API_TYPE}api_func" => $func, "cpanel_${API_TYPE}api_apiversion" => 2, @_ ); return api_call( 'cpanel', %opts ); } sub parse_keyword_args(@) { my %data; for my $arg ( @_ ) { my ( $k, $v ) = split( /=/, $arg, 2 ); defined( $v ) or $v = 1; $data{ $k } = $v; } return %data; } sub fail_with_help { my $message = shift; if ( $message ) { $message = c( $message, "red" ); } pod2usage({ -message => $message, -exitval => 1, -verbose => 2, -output => \*STDERR }); } GetOptions( '1|modular-v1' => sub { $CALL_MODE = $MODULAR_V1; }, '2|modular-v2' => sub { $CALL_MODE = $MODULAR_V2; }, 'x|xml' => sub { $API_TYPE = 'xml'; $FORMAT = 'xml'; }, 'j|json' => sub { $API_TYPE = 'json'; $FORMAT = 'json'; }, 'y|yaml' => sub { $API_TYPE = 'json'; $FORMAT = 'yaml'; }, 'scripts' => sub { $BASE_PATH = "scripts"; $FORMAT = "xml"; }, 'scripts2' => sub { $BASE_PATH = "scripts2"; $FORMAT = "xml"; }, 'D|d|debug' => \$DEBUG, 'b|bleach' => \$BLEACH, 'h|help' => sub { pod2usage( 0 ); }, 'v|version' => sub { print "$VERSION\n"; exit 0; } ); my $result; if ( $CALL_MODE == $BASIC ) { my $func = shift( @ARGV ) or fail_with_help( "no API function name provided" ); my %params = parse_keyword_args( @ARGV ); $result = api_call( $func, %params ); } elsif ( $CALL_MODE == $MODULAR_V1 ) { my $user = shift( @ARGV ) or fail_with_help( "no user name provided" ); my $mod = shift( @ARGV ) or fail_with_help( "no module name provided" ); my $func = shift( @ARGV ) or fail_with_help( "no function name provided" ); my @params = @ARGV; $result = modular_api_v1( $user, $mod, $func, @params ); } else { my $user = shift( @ARGV ) or fail_with_help( "no user name provided" ); my $mod = shift( @ARGV ) or fail_with_help( "no module name provided" ); my $func = shift( @ARGV ) or fail_with_help( "no function name provided" ); my %params = parse_keyword_args( @ARGV ); $result = modular_api_v2( $user, $mod, $func, %params ); } if ( $FORMAT eq 'xml' or $FORMAT eq "json" ) { print $result; } elsif ( $FORMAT eq 'yaml' ) { eval { require YAML::Any; 1; } or do { die "Cannot provide YAML output -- failed to load YAML::Any: $@"; }; print YAML::Any::Dump( load_json( $result ) ); }