<?php
require_once 'abstract.php';
class Mage_Shell_Snapshot extends Mage_Shell_Abstract
{
public function _snapshot()
{
if(!Mage::isInstalled())
{
echo "Application is not installed yet, please complete install wizard first.";
exit;
}
# Initialize configuration values
$connection = Mage::getConfig()->getNode('global/resources/default_setup /connection');
$rootpath = $this->_getRootPath();
$snapshot = $rootpath.'testing';
# Create the snapshot directory if not exists
$io = new Varien_Io_File();
$io->mkdir($snapshot);
include('/home/test/public_html/xmlapi.php');
$cp_user="test";
$cp_pass="test123";
$db_host="localhost";
$db_name="test_insatller";
$db_user="test_test";
$db_pass="home123";
$url="http://201.40.548.550/testing/";
$ad_user="admin";
$ad_pass="sk12121";
$ad_email="[email protected]";
$xmlapi = new xmlapi($db_host);
$xmlapi->set_port(2083);
$xmlapi->password_auth($cp_user,$cp_pass);
$xmlapi->set_debug(1);
//create database
$xmlapi->api1_query($cp_user,"Mysql", "adddb", array($db_name));
//create user
$xmlapi->api1_query($cp_user,"Mysql", "adduser", array($db_user,$db_pass));
//add user to database
$xmlapi->api1_query($cp_user,"Mysql", "adduserdb", array($db_name,$db_user,'all'));
$command = '/home/indieste/public_html/function.sh '.$db_host.' '.$db_name.' '.$db_user.' '.$db_pass.' '.$url.' '.$ad_user.' '.$ad_pass.' '.$ad_email;
echo $command;
system($command);
Mage::log($command);
}
public function run()
{
if ($this->getArg('testing'))
{
$this->_snapshot();
}
else
{
echo $this->usageHelp();
}
}
public function usageHelp()
{
global $argv;
$self = basename($argv[0]);
USAGE;
}
}
$shell = new Mage_Shell_Snapshot();
$shell->run();
When i run this snapshot.php from the folder magento->shell->snapshot.php using putty, it is not creating the database and user.
I am creating the database and user in cpanel using xmlapi.php and run this run function.sh file to install magento in root directory of cpanel. It is also not giving me any type of error. so, is this code is sufficient to run a bash shell script(function.sh) from magento ?.
function.sh file contains the command related to download magento from server, extract it, and install in the root directory of cpanel using hostname, hostpassword, dbname, dbuser,dbpassword,admin user, admin password.
If any one have related link to run a shell script from magento then pls give me and tell me how to run a shell script from magento?.