From fdc8852fcd2ba933c3d79573f1031c62cf507f5f Mon Sep 17 00:00:00 2001 From: absurdo Date: Fri, 24 Nov 2023 23:02:05 +0100 Subject: [PATCH] Added files --- .gitignore | 5 + composer.json | 16 ++ vendor/phangoapp/leviathanutils/composer.json | 20 +++ vendor/phangoapp/leviathanutils/src/Linux.php | 157 ++++++++++++++++++ .../leviathanutils/tests/LinuxTest.php | 21 +++ 5 files changed, 219 insertions(+) create mode 100644 .gitignore create mode 100644 composer.json create mode 100644 vendor/phangoapp/leviathanutils/composer.json create mode 100644 vendor/phangoapp/leviathanutils/src/Linux.php create mode 100644 vendor/phangoapp/leviathanutils/tests/LinuxTest.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b23c332 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*~ +composer.lock +vendor/* +!vendor/phangoapp +settings/ diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..b6e6ab6 --- /dev/null +++ b/composer.json @@ -0,0 +1,16 @@ +{ + "repositories": [ + { + "type": "path", + "url": "./vendor/phangoapp/leviathanutils" + } + + ], + "require": { + "phangoapp/leviathanutils": "dev-main", + "symfony/process": "^6.3" + }, + "require-dev": { + "phpunit/phpunit": "^10.4" + } +} diff --git a/vendor/phangoapp/leviathanutils/composer.json b/vendor/phangoapp/leviathanutils/composer.json new file mode 100644 index 0000000..08b3eb2 --- /dev/null +++ b/vendor/phangoapp/leviathanutils/composer.json @@ -0,0 +1,20 @@ +{ + "name": "phangoapp/leviathanutils", + "description": "A set of classes and methods for make shell operations in linux", + "require-dev": { + "phpunit/phpunit": "~4.8@dev" + }, + "license": "GPL3", + "authors": [ + { + "name": "Antonio de la Rosa", + "email": "antonio.delarosa@cuchulu.com" + } + ], + "minimum-stability": "stable", + "autoload": { + "psr-4": { + "PhangoApp\\LeviathanUtils\\": "src" + } + } +} diff --git a/vendor/phangoapp/leviathanutils/src/Linux.php b/vendor/phangoapp/leviathanutils/src/Linux.php new file mode 100644 index 0000000..6344390 --- /dev/null +++ b/vendor/phangoapp/leviathanutils/src/Linux.php @@ -0,0 +1,157 @@ +run(function ($type, $buffer): bool { + + if (Process::ERR === $type) { + + echo $buffer; + + $error=1; + + } else { + + echo $buffer; + + } + + }); + + if($error && $exit_if_error) { + + exit(1); + + } + echo 'Error'.$error; + return $error;*/ + + $cmd=implode(' ', $arr_command); + + $a = popen($cmd, 'r'); + + while($b = fgets($a, 2048)) { + + echo $b."\n"; + + //ob_flush();flush(); + + } + + if(pclose($a)>0) { + + echo 'Error executing command '.$cmd."\n"; + + exit(1); + + } + + } + + static public function get_linux_distro() { + + $file_distro=__DIR__.'/../../../../settings/distro.php'; + + $dir_distro=__DIR__.'/../../../../settings/'; + + if(!is_file($file_distro)) { + + ob_start(); + + Linux::shell_command(['python', '-c', '"import distro;print(distro.id())"']); + + $distro=trim(ob_get_contents()); + + ob_end_clean(); + + $distro_data=" 0: + Linux::shell_command('sudo dnf install -y '.$package[$distro]); + + } + else if($distro=='arch') { + + //sudo pacman -S --noconfirm + Linux::shell_command('sudo pacman -S --noconfirm '.$package[$distro]); + + } + + } + + static public function patch_file() { + + } + +} diff --git a/vendor/phangoapp/leviathanutils/tests/LinuxTest.php b/vendor/phangoapp/leviathanutils/tests/LinuxTest.php new file mode 100644 index 0000000..f794839 --- /dev/null +++ b/vendor/phangoapp/leviathanutils/tests/LinuxTest.php @@ -0,0 +1,21 @@ +assertEquals($distro, 'manjaro'); + + unlink('./settings/distro.php'); + + rmdir('./settings'); + + } + +}