package Cpanel::API::InstallWordpress;
use strict;
our $VERSION = '1.0';
# Cpanel Dependencies
use Cpanel ();
use Cpanel::API ();
use Cpanel::Locale ();
use Cpanel::Logger ();
# Other dependencies
use JSON;
use IPC::System::Simple qw(capturex EXIT_ANY);
# Defaults go here.
# Constants go here.
# Globals
my $logger;
my $locale;
#-------------------------------------------------------------------------------------------------
# Name:
# hello
# Desc:
# A convenience method for 'pinging' this module to detect its presence.
# Returns:
# time - the current epoch time
#-------------------------------------------------------------------------------------------------
sub hello {
my ($args, $result) = @_;
$result->data({time => time});
return 1;
}
#-------------------------------------------------------------------------------------------------
# Name:
# install_wordpress - Calls the install_wordpress script, passing through arguments.
# Desc:
# Installs WordPress for the specified user
# Arguments:
# The same arguments as the install_wordpress script, but in cPanel UAPI format.
# In other words, just remove -- in front of each argument.
# Returns:
# The output of the system call to the install_wordpress script
#-------------------------------------------------------------------------------------------------
sub install_wordpress {
my ( $args, $result ) = @_;
my @value = $args->keys();
my $input_arguments = {};
foreach my $item (@value) {
$input_arguments->{$item} = $args->get($item);
}
my $json_args = encode_json($input_arguments);
my @args = (
'-f',
'/usr/local/cpanel/3rdparty/wpinstaller/install_wordpress.php',
'json', $json_args,
);
my $output = capturex(EXIT_ANY, "/usr/local/cpanel/3rdparty/bin/php", @args);
my $return_code = $IPC::System::Simple::EXITVAL;
if ($return_code) {
# non-zero exit from installer
$result->error($output);
return;
}
$result->data($output);
return 1;
}
1;