Modify api to get instances config + gitignore vim
This commit is contained in:
parent
a56fb308f8
commit
3a455d0f16
|
@ -1,2 +1,3 @@
|
|||
config/usr/*
|
||||
!.gitkeep
|
||||
.*.swp
|
||||
|
|
|
@ -3,22 +3,28 @@
|
|||
<?php
|
||||
|
||||
$json = ['hosts' => []];
|
||||
foreach (scandir('config/usr') as $file) {
|
||||
$file = trim($file);
|
||||
if (strrpos($file,'.php') !== false) {
|
||||
if (strpos($file, '-') === false)
|
||||
|
||||
$instances_path = $appconf['data_dir'].'/instances';
|
||||
if (!file_exists($instances_path)) {
|
||||
mkdir($instances_path);
|
||||
apiresult($json);
|
||||
}
|
||||
|
||||
foreach ($supported_ap_software as $apsoft) {
|
||||
$json['hosts'][$apsoft] = [];
|
||||
$apsoft_path = $instances_path.'/'.$apsoft;
|
||||
if (!file_exists($apsoft_path)) {
|
||||
mkdir($apsoft_path);
|
||||
continue;
|
||||
}
|
||||
foreach (scandir($apsoft_path) as $file) {
|
||||
if (in_array($file,['.','..']))
|
||||
continue;
|
||||
$name = substr($file, 0, -4);
|
||||
$hostn = substr($name, strpos($name, '-')+1);
|
||||
$apsoft = strtolower(substr($name, 0, strpos($name, '-')));
|
||||
if (!in_array($apsoft, $supported_ap_software))
|
||||
continue;
|
||||
if (!isset($json['hosts'][$apsoft]))
|
||||
$json['hosts'][$apsoft] = [];
|
||||
require "config/usr/$file";
|
||||
$json['hosts'][$apsoft] []= [
|
||||
'instance' => $hostn,
|
||||
'config' => $config,
|
||||
$instance_path = $apsoft_path.'/'.$file;
|
||||
$json['hosts'][$apsoft] [] = [
|
||||
'instance' => $file,
|
||||
'config' => trim(
|
||||
file_get_contents($instance_path.'/config')),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue