Modify api to get instances config + gitignore vim

This commit is contained in:
Bofh 2022-11-22 16:21:24 +01:00
parent a56fb308f8
commit 3a455d0f16
2 changed files with 22 additions and 15 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
config/usr/*
!.gitkeep
.*.swp

View File

@ -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)
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]))
$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] = [];
require "config/usr/$file";
$json['hosts'][$apsoft] []= [
'instance' => $hostn,
'config' => $config,
$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;
$instance_path = $apsoft_path.'/'.$file;
$json['hosts'][$apsoft] [] = [
'instance' => $file,
'config' => trim(
file_get_contents($instance_path.'/config')),
];
}
}