From ec7ea113cbb0338a1c91fbee1af5aa4f30a6874a Mon Sep 17 00:00:00 2001 From: prabuddha Date: Fri, 20 Nov 2015 14:34:41 +0530 Subject: [PATCH] stack type validation --- php/{Stack_PKG => Stack}/apt.php | 20 +++++++++++--------- php/{pkgm => Stack}/package_manager.php | 3 +++ php/commands/stack.php | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 10 deletions(-) rename php/{Stack_PKG => Stack}/apt.php (82%) rename php/{pkgm => Stack}/package_manager.php (98%) diff --git a/php/Stack_PKG/apt.php b/php/Stack/apt.php similarity index 82% rename from php/Stack_PKG/apt.php rename to php/Stack/apt.php index 93462217..562dabcf 100644 --- a/php/Stack_PKG/apt.php +++ b/php/Stack/apt.php @@ -1,14 +1,16 @@ 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(); - $flag = false; foreach ($this->stack_os_scope as $value) { - if ($value == $os_type['DISTRIB_ID']) { + if ($value == trim($os_type['DISTRIB_ID'])) { $flag = true; + print_r($os_type['DISTRIB_ID']); 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']}" ); $result = $process->run(); @@ -57,7 +59,7 @@ class APT extends PKG_MANAGER { print_r( $this->res ); } - function repo_add($repo_url){ + public function repo_add($repo_url){ if (isset($repo_url)) { $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)){ $this->cmd = 'gpg --keyserver ' . $keyserver . '--recv-keys ' . $keyids ; diff --git a/php/pkgm/package_manager.php b/php/Stack/package_manager.php similarity index 98% rename from php/pkgm/package_manager.php rename to php/Stack/package_manager.php index def6bfa6..78aefbef 100644 --- a/php/pkgm/package_manager.php +++ b/php/Stack/package_manager.php @@ -5,6 +5,9 @@ * */ + + + abstract class PKG_MANAGER { protected $stack_os_scope ; diff --git a/php/commands/stack.php b/php/commands/stack.php index c3645868..82d4d41b 100644 --- a/php/commands/stack.php +++ b/php/commands/stack.php @@ -1,5 +1,6 @@ validate_stack_type($Data[$args[0]]['stack_type'])){ + $apt->install(); + } + else { + echo "please check config"; + }