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