From 5287761f85087894358f445d9c7b8beff1941310 Mon Sep 17 00:00:00 2001 From: prabuddha Date: Wed, 18 Nov 2015 14:11:37 +0530 Subject: [PATCH] added variable.php and apt.php --- php/Stack_PKG/apt.php | 94 +++++++++++++++++++++++++++++++++++++++++++ php/apt.php | 26 ------------ php/variables.php | 7 ++++ 3 files changed, 101 insertions(+), 26 deletions(-) create mode 100644 php/Stack_PKG/apt.php delete mode 100644 php/apt.php create mode 100644 php/variables.php diff --git a/php/Stack_PKG/apt.php b/php/Stack_PKG/apt.php new file mode 100644 index 00000000..ea3616f5 --- /dev/null +++ b/php/Stack_PKG/apt.php @@ -0,0 +1,94 @@ +cmd = 'apt-get install '.$this->pkg ; + $this->execute_local(); + + } + + private function update(){ + $this->cmd = 'apt-get update '; + $this->execute_local(); + } + + + function execute_local() { + $output = array(); + $res = exec( $this->cmd, $output, $return ); + $this->res = $output; + print_r( $this->res ); + } + + function repo_add($repo_url){ + + if (isset($repo_url)) { + $repo_file_path = "/etc/apt/sources.list.d/" . ee_repo_file ; + } + + if (!file_exists($repo_file_path)) { + $myfile = fopen($repo_file_path , "w") or die("Unable to open file!"); + fwrite($myfile, $repo_url . '\n'); + fclose($myfile); + } else { + + $handle = @fopen($repo_file_path, "w"); + $matches = false; + if ($handle) + { + while (!feof($handle)) + { + $buffer = fgets($handle); + if(strpos($buffer, $repo_url) !== FALSE) + $matches = true; + } + + if(!$matches) { + fwrite($handle, $repo_url . '\n'); + } + + fclose($handle); + } + + + } + + } + + function repo_add_key($keyids, $keyserver) { + + if (isset($keyserver)){ + $this->cmd = 'gpg --keyserver ' . $keyserver . '--recv-keys ' . $keyids ; + $this->execute_local(); + + } + else { + $this->cmd = 'gpg --keyserver ' . 'hkp://keys.gnupg.net' . '--recv-keys ' . $keyids ; + $this->execute_local(); + } + + $this->cmd = 'gpg -a --export --armor ' . $keyids . ' | apt-key add - ' ; + $this->execute_local(); + + + } + + function repo_remove(){ + + } + /* + is_installed + auto_remove + auto_clean + update + */ + + + +} + + diff --git a/php/apt.php b/php/apt.php deleted file mode 100644 index 56433f3d..00000000 --- a/php/apt.php +++ /dev/null @@ -1,26 +0,0 @@ -cmd = 'apt-get install '.$this->pkg ; - $this->execute_local(); - - } - - - function execute_local() { - $output = array(); - $res = exec( $this->cmd, $output, $return ); - $this->res = $output; - print_r( $this->res ); - } - - - -} - - diff --git a/php/variables.php b/php/variables.php new file mode 100644 index 00000000..640e30cf --- /dev/null +++ b/php/variables.php @@ -0,0 +1,7 @@ + \ No newline at end of file