Browse Source

stack type validation

feature/refactor-php
prabuddha 9 years ago
parent
commit
ec7ea113cb
  1. 20
      php/Stack/apt.php
  2. 3
      php/Stack/package_manager.php
  3. 15
      php/commands/stack.php

20
php/Stack_PKG/apt.php → php/Stack/apt.php

@ -1,14 +1,16 @@
<?php <?php
//EasyEngine package installation using apt module. //EasyEngine package installation using apt module.
include EE_CLI_ROOT . '/php/Stack/package_manager.php';
use EE_CLI\Process; use EE_CLI\Process;
class APT extends PKG_MANAGER { class APT extends PKG_MANAGER {
protected $stack_os_scope = array('UBUNTU','DEBIAN'); protected $stack_os_scope = array('Ubuntu','Debian');
private $pkg = array(); private $pkg = array();
public function __construct($data=array())
function __construct($data=array())
{ {
$this->pkg = $data; $this->pkg = $data;
@ -16,24 +18,24 @@ class APT extends PKG_MANAGER {
} }
function validate_stack_type($stacktype){ public function validate_stack_type($stacktype){
$os_type = EE_CLI\Utils\get_OS(); $os_type = EE_CLI\Utils\get_OS();
$flag = false; $flag = false;
foreach ($this->stack_os_scope as $value) { foreach ($this->stack_os_scope as $value) {
if ($value == $os_type['DISTRIB_ID']) { if ($value == trim($os_type['DISTRIB_ID'])) {
$flag = true; $flag = true;
print_r($os_type['DISTRIB_ID']);
return $flag; return $flag;
} }
} }
if (!$flag) die("Configuration doesnot match with system status"); if (!$flag) die("Configuration doesnot match with system status \n");
} }
function install() { public function install() {
$process = EE_CLI\Process::create( "apt-get install {$this->pkg['package_name']}" ); $process = EE_CLI\Process::create( "apt-get install {$this->pkg['package_name']}" );
$result = $process->run(); $result = $process->run();
@ -57,7 +59,7 @@ class APT extends PKG_MANAGER {
print_r( $this->res ); print_r( $this->res );
} }
function repo_add($repo_url){ public function repo_add($repo_url){
if (isset($repo_url)) { if (isset($repo_url)) {
$repo_file_path = "/etc/apt/sources.list.d/" . ee_repo_file ; $repo_file_path = "/etc/apt/sources.list.d/" . ee_repo_file ;
@ -92,7 +94,7 @@ class APT extends PKG_MANAGER {
} }
function repo_add_key($keyids, $keyserver) { public function repo_add_key($keyids, $keyserver) {
if (isset($keyserver)){ if (isset($keyserver)){
$this->cmd = 'gpg --keyserver ' . $keyserver . '--recv-keys ' . $keyids ; $this->cmd = 'gpg --keyserver ' . $keyserver . '--recv-keys ' . $keyids ;

3
php/pkgm/package_manager.php → php/Stack/package_manager.php

@ -5,6 +5,9 @@
* *
*/ */
abstract class PKG_MANAGER { abstract class PKG_MANAGER {
protected $stack_os_scope ; protected $stack_os_scope ;

15
php/commands/stack.php

@ -1,5 +1,6 @@
<?php <?php
/** /**
* Manage EasyEngine stack. * Manage EasyEngine stack.
* *
@ -65,8 +66,9 @@ class Stack_Command extends EE_CLI_Command {
private function install_package( $args ){ private function install_package( $args ){
print_r($args[0]); print_r($args[0]);
$Data = Spyc::YAMLLoad('/home/rtcamp/Desktop/developments/ee-cli.yml'); $Data = Spyc::YAMLLoad('/home/prabuddha/Desktop/ee4.4.0.0/ee-cli.yml');
//print_r($Data); //print_r($Data);
print_r($Data[$args[0]]);
if (isset($Data[$args[0]])) { if (isset($Data[$args[0]])) {
EE_CLI::success('installing packages from ee-config.cli: ' . $args[0]); EE_CLI::success('installing packages from ee-config.cli: ' . $args[0]);
@ -74,6 +76,17 @@ class Stack_Command extends EE_CLI_Command {
EE_CLI::success('Adding repository: ' . $Data[$args[0]]['apt_repository']); EE_CLI::success('Adding repository: ' . $Data[$args[0]]['apt_repository']);
} }
include EE_CLI_ROOT . '/php/Stack/apt.php';
$apt = new APT($Data[$args[0]]);
if($apt->validate_stack_type($Data[$args[0]]['stack_type'])){
$apt->install();
}
else {
echo "please check config";
}

Loading…
Cancel
Save