I made a script in JQuery for installing software by mei of a PHP script.
JQuery takes the installation request through a button created in an HTML script and calls PHP that does the installation by shell_exec
.
This part works perfectly, now I needed to check if the software is already installed on the machine and disable only the button for the installed software.
What I had thought was to check through a PHP script and send a JSON script to a JQuery script installed so that this script disables the button for them, but I'm not sure how to do it, if anyone can help thanks.
Following are the JQuery and PHP tags that install.
//Jquery
function instalaSoftware(software){
console.log(software.data.software)
$.get("instalaSoftware.php?software="+software.data.software)
}
$(document).ready(function(){
$("#soft1").click({software:'soft-1'},instalaSoftware)
$("#soft2").click({software:'soft-2'},instalaSoftware)
$("#soft3").click({software:'soft-3'},instalaSoftware)
$("#soft4").click({software:'soft-4'},instalaSoftware)
$("#soft5").click({software:'soft-5'},instalaSoftware)
}
// PHP script (installSoftware)
<?php
$softwareId = $_GET ["software"];
if($softwareId != ""){
$up = shell_exec("sudo apt-get update");
$softwareInstall = shell_exec("sudo apt-get -y --force-yes install $softwareId");
echo $softwareInstall;
}
?>