Viewing/Stopping/Restarting Services from external webpage

Budde

Registered
Aug 25, 2008
2
0
51
I'd like to view, start, stop or restart services from cpanel on an external page of my site, instead of going to cpanel.. Is this possible?
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,212
13
313
Houston, TX
cPanel Access Level
Root Administrator
I'd like to view, start, stop or restart services from cpanel on an external page of my site, instead of going to cpanel.. Is this possible?
At this time, our XML-API does support restarting of services. Viewing service status can be done independently of our APIs.

As for starting/stopping services, are you encountering any issues with your server that would make you desire to do this?
 

Budde

Registered
Aug 25, 2008
2
0
51
As for starting/stopping services, are you encountering any issues with your server that would make you desire to do this?
I was just wondering, since I'd like to create a Services page that would allow certain people to stop, start or restart services.
 

wsenter

Well-Known Member
Aug 5, 2003
88
0
156
Texas
Take a look into writing specific interfaces with php and curl. I've done it in the past for a few additional remote server functions (like add account/modify account etc..). I've included the code below to give you a starting point. You should be able to use php and curl to be able to create something you want. Again the following is just an example as to how php/curl works. It will not solve your problem without heavy modifications...

Code:
<?php 
// start the session and pass the Session parameter
session_start(); 
header("Cache-control: private"); //IE 6 Fix

######### Set up basic variables #########
$serverIPaddress="192.168.1.1:2087";
$whmusername="root";
$whmpassword="123456";
$server="https://$whmusername:[email protected]$serverIPaddress";

//set the username of the account you are working with
$user = "bobby12";
$agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";



######### Here are few example of many of the items that you could do with curl.  It will not execute until the very bottom #########

//change user's password
$url="$server/scripts/passwd?password=$passwd&domain=$user&user=$user";

//enable shell access		
$url="$server/scripts2/domanageshells?user=$user&shell=Enable+Jailed+Shell&user=$user";

//bandlimit increase		
$url="$server/scripts2/dolimitbw?user=$user&bwlimit=$bndwidth";
		
//suspend an account
$url="$server/scripts2/suspendacct?domain=$user&user=$user&suspend-domain=Suspend&reason=";

//UN-suspend an account
$url="$server/scripts2/suspendacct?domain=$user&user=$user&unsuspend-domain=UnSuspend&reason=";

//add front page extensions
$url="$server/scripts/installfp?domain=$user&user=$user&submit-domain=Install";

//remove front page extensions
$url="$server/scripts/uninstallfp?domain=$user&user=$user&submit-domain=UnInstall";

//modify the quota on the account		
$url="$server/scripts/editquota?user=$user&quota=$quota";

//add a domain pointer
$url="$server/scripts/park?txtdomain=&domain=$domain&ndomain=$NewDomain";
		
//modify the account
$url="$server/scripts/saveedituser?user=$user&BWLIMIT";
$url.="=$BWLIMIT&FEATURELIST=$FEATURELIST&IP=$IP&OWNER";
$url.="=$OWNER&PLAN=$PLAN&STARTDATE=$STARTDATE&DNS=$domain";
$url.="&RS=$RS&LANG=english&newuser=$user&seeshell=$shell&MAXPOP";
$url.="=$MAXPOP&MAXFTP=$MAXFTP&MAXLST=$MAXLST&MAXSUB=$MAXSUB&MAXSQL";
$url.="=$MAXSQL&MAXPARK=$MAXPARK&MAXADDON=$MAXADDON";

//generate a csr
 //need to replace spaces in all of the variables with the '+' sign
$host = str_replace(" ","+",$host);
$country = str_replace(" ","+",$country);
$state = str_replace(" ","+",$state);
$city = str_replace(" ","+",$city);
$cod = str_replace(" ","+",$cod);
$co = str_replace(" ","+",$co);
$email = str_replace(" ","+",$email);
$pass = str_replace(" ","+",$pass);
$url="$server/scripts/gencrt?xemail=$xemail&host=$host&country";
$url.="=$country&state=$state&city=$city&co=$co&cod=$cod&email=$email&pass=$pass";
		
######### execute curl #########

$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_MAXREDIRS, 4);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
$buffer = curl_exec($ch);
curl_close($ch);

?>
If you are not able to do this on your own and are looking to hire someone to do this then we could talk. I am a US based programmer that could do something for you. If so write out a very detailed list of what exactly you want it to do and/or look like and we will proceed from there.