/
opt
/
dedrads
/
/opt/dedrads
mkdir
upload
Name
Size
Mode
Actions
account_review/
-
0555
rm
check_software_mods/
-
0555
rm
cms_tools/
-
0555
rm
etc/
-
0555
rm
extras/
-
0555
rm
mailparse/
-
0555
rm
mysql/
-
0555
rm
nlp_scripts/
-
0555
rm
oldrads/
-
0555
rm
perl/
-
0555
rm
provision/
-
0555
rm
python/
-
0555
rm
suspended/
-
0555
rm
__pycache__/
-
0555
rm
account-review
799
0555
edit
dl
rm
allfw
6259
0555
edit
dl
rm
alp.py
16553
0555
edit
dl
rm
autossl_sync
6267
0555
edit
dl
rm
check_apache
9205
0555
edit
dl
rm
check_bandwidth
4546
0555
edit
dl
rm
check_boxtrapper
1684
0555
edit
dl
rm
check_cpu
12212
0555
edit
dl
rm
check_crons
1827
0555
edit
dl
rm
check_dcpumon
1973
0555
edit
dl
rm
check_dns
1827
0555
edit
dl
rm
check_domlogs
61
0555
edit
dl
rm
check_exim
3731
0555
edit
dl
rm
check_hacks
22604
0555
edit
dl
rm
check_imap
5249
0555
edit
dl
rm
check_io
6635
0555
edit
dl
rm
check_max_children
16341
0555
edit
dl
rm
check_mem
1660
0555
edit
dl
rm
check_misc
1510
0555
edit
dl
rm
check_pacct
5201
0555
edit
dl
rm
check_php
4344
0555
edit
dl
rm
check_pop3
2295
0555
edit
dl
rm
check_prov.py
4714
0555
edit
dl
rm
check_server
696
0555
edit
dl
rm
check_size
490
0555
edit
dl
rm
check_software
9849
0555
edit
dl
rm
check_spamd
2426
0555
edit
dl
rm
check_traffic
1933
0555
edit
dl
rm
check_user
1887
0555
edit
dl
rm
clean_exim.py
6390
0555
edit
dl
rm
clusterfix
5343
0555
edit
dl
rm
cmspass.py
3970
0555
edit
dl
rm
cms_check.py
9825
0555
edit
dl
rm
cms_counter.py
36734
0555
edit
dl
rm
cms_creds
713
0555
edit
dl
rm
cms_dumpdb
4485
0555
edit
dl
rm
cms_pw
1416
0555
edit
dl
rm
cpanel-api
7040
0555
edit
dl
rm
cpanel_postgres_manager.py
29004
0555
edit
dl
rm
cpmerge
4631
0555
edit
dl
rm
cpumon
2195
0555
edit
dl
rm
dcpumon.pl
1239
0555
edit
dl
rm
dedcheck
18127
0555
edit
dl
rm
dns-sync
14386
0555
edit
dl
rm
docroot.py
4425
0555
edit
dl
rm
du-tree
7450
0555
edit
dl
rm
envinfo.py
6633
0555
edit
dl
rm
exclude_rbl.py
5249
0555
edit
dl
rm
extract-vhost
2691
0555
edit
dl
rm
filescan
3566
0555
edit
dl
rm
find_warez
1460
0555
edit
dl
rm
first_setup.py
19120
0555
edit
dl
rm
fixwpcron.py
4822
0555
edit
dl
rm
fix_dns_cluster
353
0555
edit
dl
rm
goaccess
1217720
0555
edit
dl
rm
hostsfilemods
4467
0555
edit
dl
rm
imap_io
2323
0555
edit
dl
rm
innodb_converter.py
9343
0555
edit
dl
rm
killall911
530
0555
edit
dl
rm
killdns
941
0555
edit
dl
rm
lastcommcache.sh
1374
0555
edit
dl
rm
legal_lock_down.sh
7450
0555
edit
dl
rm
lil-cpanel
52002
0555
edit
dl
rm
listacct
4575
0555
edit
dl
rm
mailscan
4544
0555
edit
dl
rm
mail_sources.py
7407
0555
edit
dl
rm
megaclisas-status
38664
0555
edit
dl
rm
migrate2central.sh
14418
0555
edit
dl
rm
modify-account
40631
0555
edit
dl
rm
modsec_disable.py
11461
0555
edit
dl
rm
monarxctl
8912
0555
edit
dl
rm
msp.pl
27714
0555
edit
dl
rm
mysql_dstat
474
0555
edit
dl
rm
mysql_selector.py
73102
0555
edit
dl
rm
nlp
4582
0555
edit
dl
rm
procscrape
1863
0555
edit
dl
rm
quarantine
11083
0555
edit
dl
rm
radsfunctions.sh
863
0555
edit
dl
rm
recent-cp
16148
0555
edit
dl
rm
remote_dump
18347
0555
edit
dl
rm
reset_cpanel
3205
0555
edit
dl
rm
server-load
2192
0555
edit
dl
rm
show-conns
20105
0555
edit
dl
rm
show-conns-adv.py
54667
0555
edit
dl
rm
sparta.py
382498
0555
edit
dl
rm
sqltop
27129
0555
edit
dl
rm
telcheck
2411
0555
edit
dl
rm
temprootreset
186
0555
edit
dl
rm
unsuspend_user
1307
0555
edit
dl
rm
unsusprunner.sh
1840
0555
edit
dl
rm
updatednsadmin
526
0555
edit
dl
rm
update_spf
14972
0555
edit
dl
rm
upgrade-check
9216
0555
edit
dl
rm
vhost_data.py
6221
0555
edit
dl
rm
wp-xray.sh
85816
0555
edit
dl
rm
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<function> I<arg-name>=I<val> ... call-api [options] -1 I<user> I<module> I<function> I<arg1> ... I<argN> call-api [options] -2 I<user> I<module> I<function> I<arg-name>=I<val> ... =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 ) ); }
Save
cmd:
run