lots of cucc ...
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
root
2024-11-27 00:39:19 +01:00
parent c0d7365c0f
commit 863e744c5c
3 changed files with 171 additions and 112 deletions

View File

@@ -1,8 +1,9 @@
<?php
$REDIS_HOST='redis-server';
$SHARED_DIR = "shared";
$SHARED_DIR = "/var/tmp/shared";
$INTERFACE = "directory"; // redis OR directory
//$INTERFACE = "redis";
function ping_redis() {
@@ -282,25 +283,68 @@ function put_install_envs() {
function set_output($op,$output) {
global $SHARED_DIR;
global $INTERFACE, $SHARED_DIR;
if ($INTERFACE=="redis") {
redis_set($op,$output);
file_put_contents($SHARED_DIR."/".$op,$output);
}
else {
file_put_contents($SHARED_DIR."/input/".$op,$output);
}
return true;
}
function check_files($dir,$key) {
global $SHARED_DIR;
if (file_exists($SHARED_DIR."/{$dir}/".$key)) {
$arr[$key] = file_get_contents($SHARED_DIR."/{$dir}/".$key);
}
else $arr = "";
return $arr;
}
function check_request($key="") {
global $INTERFACE;
if ($INTERFACE=="redis") {
$arr = check_redis("web_in",$key);
}
else {
$arr = check_files("input",$key);
}
return $arr;
}
function check_response($key="") {
global $INTERFACE;
if ($INTERFACE=="redis") {
$arr = check_redis("web_out",$key);
//$arr = check_files("web_out",$key);
}
else {
$arr = check_files("output",$key);
}
return $arr;
}
function remove_response($key) {
global $INTERFACE, $SHARED_DIR;
if ($INTERFACE=="redis") {
redis_remove("$key");
}
else {
//unlink($SHARED_DIR."/".$key);
}
}
?>

View File

@@ -91,6 +91,52 @@
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.2.1/dist/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<script>
function check_deployments() {
var url = 'scan.php?op=check_deployments';
jQuery.get(url, function(data) {
console.log('check_deployments: '+data);
if (data=="WAIT" || data=="") {
setTimeout(check_deployments, 1000);
}
else jQuery("#deployments").html(data);
});
}
function get_deployments() {
var url = 'scan.php?op=deployments';
jQuery.get(url, function(data) {
console.log('deployments: '+data);
if (data=="OK") {
setTimeout(check_deployments, 1000);
}
else jQuery("#deployments").html(data);
});
}
function check_system() {
var url = 'scan.php?op=check_system&services=1';
jQuery.get(url, function(data) {
console.log('check_system: '+data);
if (data=="WAIT" || data=="") {
setTimeout(check_system, 1000);
}
else {
jQuery("#system").html(data);
}
});
}
function get_system() {
var url = 'scan.php?op=system';
jQuery.get(url, function(data) {
console.log('system: '+data);
if (data=="OK") {
setTimeout(check_system, 1000);
}
else alert(data);
});
}
function check_repositories() {
var url = 'scan.php?op=check_repositories';
jQuery.get(url, function(data) {
@@ -107,6 +153,7 @@ function check_repositories() {
function get_repositories() {
var url = 'scan.php?op=repositories';
jQuery.get(url, function(data) {
console.log('repositories: '+data);
if (data=="OK") {
setTimeout(check_repositories, 500);
}
@@ -117,37 +164,17 @@ function get_repositories() {
function add_repository() {
var url = 'scan.php?op=add_repository&repo='+jQuery('#repository').val();
jQuery.get(url, function(data) {
console.log('add_repository: '+data);
if (data=="OK") {
}
get_repositories();
});
}
function check_system() {
var url = 'scan.php?op=check_system&services=1';
jQuery.get(url, function(data) {
if (data=="WAIT" || data=="") {
setTimeout(check_system, 1000);
}
else {
jQuery("#system").html(data);
}
});
}
function get_system() {
var url = 'scan.php?op=system';
jQuery.get(url, function(data) {
if (data=="OK") {
setTimeout(check_system, 1000);
}
else alert(data);
});
}
function check_updates() {
var url = 'scan.php?op=check_updates';
jQuery.get(url, function(data) {
console.log('check_updates: '+data);
if (data=="WAIT" || data=="") {
setTimeout(check_updates, 1000);
}
@@ -160,54 +187,28 @@ function check_updates() {
function get_updates() {
var url = 'scan.php?op=updates';
jQuery.get(url, function(data) {
console.log('updates: '+data);
if (data=="OK") {
setTimeout(check_updates, 1000);
}
});
}
function check_deployments() {
var url = 'scan.php?op=check_deployments';
jQuery.get(url, function(data) {
if (data!="") {
jQuery("#deployments").html(data);
}
else setTimeout(check_deployments, 1000);
});
}
function get_deployments() {
var url = 'scan.php?op=deployments';
jQuery.get(url, function(data) {
if (data=="OK") {
setTimeout(check_deployments, 1000);
}
});
}
function load_template(additional) {
jQuery("#"+additional).html('Loading...');
jQuery("#"+additional).html('Loading '+additional+' template...');
var url = 'scan.php?op=deployment&additional='+additional;
jQuery.get(url, function(data) {
console.log('load_template: '+data);
if (data=="OK") {
setTimeout(check_deployment, 1000, additional);
}
});
}
function reinstall(additional) {
jQuery("#"+additional).html('Loading...');
var url = 'scan.php?op=reinstall&additional='+additional;
jQuery.get(url, function(data) {
if (data=="OK") {
setTimeout(check_reinstall, 1000, additional);
}
});
}
function check_reinstall(additional) {
var url = 'scan.php?op=check_reinstall';
jQuery.get(url, function(data) {
console.log('check_reinstall: '+data);
if (data!="") {
jQuery("#"+additional).html(data);
}
@@ -215,12 +216,13 @@ function check_reinstall(additional) {
});
}
function uninstall(additional) {
var url = 'scan.php?op=uninstall&additional='+additional;
function reinstall(additional) {
jQuery("#"+additional).html('Loading...');
var url = 'scan.php?op=reinstall&additional='+additional;
jQuery.get(url, function(data) {
if (data!="") {
jQuery("#"+additional).html(data);
setTimeout(check_uninstall, 1000, additional);
console.log('reinstall '+additional+': '+data);
if (data=="OK") {
setTimeout(check_reinstall, 1000, additional);
}
});
}
@@ -228,6 +230,7 @@ function uninstall(additional) {
function check_uninstall(additional) {
var url = 'scan.php?op=check_uninstall';
jQuery.get(url, function(data) {
console.log('check_uninstall '+additional+': '+data);
if (data!="") {
jQuery("#"+additional).html(data);
}
@@ -235,6 +238,28 @@ function check_uninstall(additional) {
});
}
function uninstall(additional) {
var url = 'scan.php?op=uninstall&additional='+additional;
jQuery.get(url, function(data) {
console.log('uninstall '+additional+': '+data);
if (data!="") {
jQuery("#"+additional).html(data);
setTimeout(check_uninstall, 1000, additional);
}
});
}
function check_deployment(additional) {
var url = 'scan.php?op=check_deployment';
jQuery.get(url, function(data) {
console.log('check_deployment '+additional+': '+data);
if (data!="") {
jQuery("#"+additional).html(data);
}
else setTimeout(check_deployment, 1000, additional);
});
}
function deploy(additional) {
pars = '';
jQuery('input.additional_field').each(function(index) {
@@ -244,6 +269,7 @@ function deploy(additional) {
//console.log(pars);
var url = 'scan.php?op=deploy&additional='+additional+pars;
jQuery.get(url, function(data) {
console.log('deploy '+additional+': '+data);
if (data!="") {
jQuery("#"+additional).html(data);
setTimeout(check_deployment, 1000, additional);
@@ -251,19 +277,10 @@ function deploy(additional) {
});
}
function check_deployment(additional) {
var url = 'scan.php?op=check_deployment';
jQuery.get(url, function(data) {
if (data!="") {
jQuery("#"+additional).html(data);
}
else setTimeout(check_deployment, 1000, additional);
});
}
function check_services() {
var url = 'scan.php?op=check_services';
jQuery.get(url, function(data) {
console.log('check_services: '+data);
if (data=="WAIT" || data=="") {
setTimeout(check_services, 1000);
}
@@ -276,6 +293,7 @@ function check_services() {
function get_services() {
var url = 'scan.php?op=services';
jQuery.get(url, function(data) {
console.log('services: '+data);
setTimeout(check_services, 1000);
});
}
@@ -283,6 +301,7 @@ function get_services() {
function check_containers() {
var url = 'scan.php?op=check_containers';
jQuery.get(url, function(data) {
console.log('check_containers: '+data);
if (data!="") {
jQuery("#containers").html(data);
}
@@ -293,6 +312,7 @@ function check_containers() {
function get_containers() {
var url = 'scan.php?op=containers';
jQuery.get(url, function(data) {
console.log('containers: '+data);
if (data=="OK") {
setTimeout(check_containers, 1000);
}

View File

@@ -82,7 +82,7 @@ switch ($_GET["op"]) {
else echo "ERROR";
break;
case "check_services":
$arr = check_redis("web_out","services");
$arr = check_response("services");
if (!empty($arr)) {
foreach ($arr as $key=>$data) {
if ($key=="services") {
@@ -95,7 +95,7 @@ switch ($_GET["op"]) {
}
echo "<br>";
}
redis_remove("$key");
remove_response("$key");
}
}
}
@@ -105,12 +105,11 @@ switch ($_GET["op"]) {
$arr = array("STATUS" => 0);
$json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
$op = "updates"; //"init:".date("YmdHis");
redis_set($op,$json);
echo "OK"; // TODO?
if (set_output("updates",$json)) echo "OK";
else echo "ERROR";
break;
case "check_updates":
$arr = check_redis("web_out","updates");
$arr = check_response("updates");
if (!empty($arr)) {
foreach ($arr as $key=>$data) {
if ($key=="updates") {
@@ -121,7 +120,7 @@ switch ($_GET["op"]) {
}
echo "<br>";
}
redis_remove("$key");
remove_response("$key");
}
}
}
@@ -135,7 +134,7 @@ switch ($_GET["op"]) {
else echo "ERROR";
break;
case "check_deployments":
$arr = check_redis("web_out","deployments");
$arr = check_response("deployments");
if (!empty($arr)) {
foreach ($arr as $key=>$data) {
if ($key=="deployments") {
@@ -168,24 +167,23 @@ switch ($_GET["op"]) {
}
else echo "There are no installed services.<br>";
*/
redis_remove("$key");
remove_response("$key");
}
}
}
else echo "";
else echo "WAIT";
break;
case "deployment":
$arr = array("NAME" => $_GET["additional"], "ACTION" => "ask");
$json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
$op = "deployment";
redis_set($op,$json);
echo "OK"; // TODO?
if (set_output("deployment",$json)) echo "OK";
else echo "ERROR";
break;
case "check_reinstall":
$reinstall = 1;
case "check_deployment":
$arr = check_redis("web_out","deployment");
$arr = check_response("deployment");
if (!empty($arr)) {
foreach ($arr as $key=>$data) {
if ($key=="deployment") {
@@ -224,16 +222,16 @@ switch ($_GET["op"]) {
elseif ($data["STATUS"]=="2") { // deploy
echo "Install has finished.";
}
redis_remove("$key");
remove_response("$key");
}
}
}
else {
$arr = check_redis("web_in","deployment");
$arr = check_request("deployment");
if (!empty($arr)) { // deployment in progress
foreach ($arr as $key=>$data) {
if ($key=="deployment") {
if ($data["STATUS"]=="1") { // TODO - curenct state message???
if ($data["STATUS"]=="1") { // TODO - current state message???
echo "Install in progress... Please wait...";
}
elseif ($data["STATUS"]=="2") {
@@ -275,8 +273,8 @@ switch ($_GET["op"]) {
$payload = base64_encode(json_encode($fields, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT));
$arr = array("NAME" => $_GET["additional"], "ACTION" => "deploy", "PAYLOAD" => $payload);
$json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
$op = "deployment";
redis_set($op,$json);
if (set_output("deployment",$json)) echo "OK";
else echo "ERROR";
}
echo $text;
break;
@@ -284,9 +282,8 @@ switch ($_GET["op"]) {
$arr = array("NAME" => $_GET["additional"], "ACTION" => "reinstall");
$json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
$op = "deployment";
redis_set($op,$json);
echo "OK"; // TODO?
if (set_output("deployment",$json)) echo "OK";
else echo "ERROR";
break;
case "uninstall":
if ($key=check_deploy()) {
@@ -297,7 +294,8 @@ switch ($_GET["op"]) {
$arr = array("NAME" => $_GET["additional"], "ACTION" => "uninstall");
$json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
$op = "deployment";
redis_set($op,$json);
if (set_output("deployment",$json)) echo "OK";
else echo "ERROR";
}
echo $text;
break;
@@ -305,7 +303,6 @@ switch ($_GET["op"]) {
$arr = array("STATUS" => 0);
$json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
$op = "repositories";
if (set_output("repositories",$json)) echo "OK";
else echo "ERROR";
break;
@@ -326,30 +323,28 @@ switch ($_GET["op"]) {
else echo "WAIT";
break;
case "add_repository":
redis_remove("add_repository");
remove_response("add_repository");
$arr = array("NEW_REPO" => $_GET["repo"]);
$json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
$op = "add_repository";
redis_set($op,$json);
echo "OK"; // TODO?
if (set_output("add_repository",$json)) echo "OK";
else echo "ERROR";
break;
case "containers":
$arr = array("STATUS" => 0);
$json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
$op = "containers";
redis_set($op,$json);
echo "OK"; // TODO?
if (set_output("containers",$json)) echo "OK";
else echo "ERROR";
break;
case "check_containers":
$arr = check_redis("web_out","containers");
$arr = check_response("containers");
if (!empty($arr)) {
foreach ($arr as $key=>$data) {
if ($key=="containers") {
echo base64_decode($data["RESULT"]);
redis_remove("$key");
remove_response("$key");
}
}
}