11 |
SexiGraf Package Update Runner
12 | (.*)<\/version>/', $tempVersionOutput, $matches);
17 | $newVersion = (is_array($matches) && count($matches) > 0) ? $matches[0] : 'Unknown';
18 | echo '
Current installed version: ' . $SexiGrafVersion . '
New package version: ' . $newVersion . '
19 |
Warning: Upgrade process check!
The upgrade process will be launched after you click on the \'Upgrade Me\' button.
After the upgrade process is succeeded, SexiGraf services will be restarted.
The following file will be used for upgrade process: '.$_POST['input-file'].'
';
20 | } else {
21 | echo "
";
22 | unlinkRecursive("/tmp/sexigraf-update/");
23 | $messageOutput = "Starting update process on " . (new DateTime())->format('Y-m-d H:i:s') . "\n";
24 | $tempMessageOutput = shell_exec("/usr/bin/unzip \"".$dir.$_POST['input-file']."\" -d /tmp/sexigraf-update/ 2>&1");
25 | if (file_exists($xmlPath)) {
26 | $domXML = new DomDocument();
27 | $domXML->load($xmlPath);
28 | $listeCommands = $domXML->getElementsByTagName('command');
29 | $SexiGrafNewVersion = $domXML->getElementsByTagName("version")->item(0)->nodeValue;
30 | $messageOutput .= "Updating from version " . trim($SexiGrafVersion) . " to version $SexiGrafNewVersion\n";
31 | $messageOutput .= "Unpacking SexiGraf Update Package in /tmp/sexigraf-update/\n";
32 | $messageOutput .= $tempMessageOutput;
33 | $errorInCommand = false;
34 | foreach($listeCommands as $command2Run){
35 | $outputCommand = [];
36 | $returnError = "";
37 | $command2sudo = $command2Run->firstChild->nodeValue;
38 | exec("sudo $command2sudo", $outputCommand, $returnError);
39 | if ($returnError) {
40 | $messageOutput .= "[ERROR] Command run with errors: $command2sudo\n";
41 | $errorInCommand = true;
42 | } else {
43 | $messageOutput .= "[INFO] Command run successfully: $command2sudo\n";
44 | }
45 | $messageOutput .= implode("\n", $outputCommand) . "\n";
46 | }
47 | } else {
48 | $messageOutput .= "!!! Missing mandatory file. Please check package integrity.\n";
49 | }
50 | $messageOutput .= "Purging temporary folder /tmp/sexigraf-update/";
51 | unlinkRecursive("/tmp/sexigraf-update/");
52 | echo $messageOutput;
53 | echo "";
54 | $updateLog = fopen("update.log", "w");
55 | fwrite($updateLog, $messageOutput);
56 | fclose($updateLog);
57 | if ($errorInCommand) {
58 | echo '
Error:There was some errors during the update process!
Some errors occured during update of your SexiGraf appliance. This shouldn\'t happen, but don\'t worry, we are here to help you!
If you want, you can take a look above to the report that can point you to the right direction, or you can send it to us at plot <at> sexigraf.fr
You can fin update log here, you can use the following button to send us an email with the details, we\'ll look into it and get back to you.
';
59 | } else {
60 | echo '
Success:Update completed successfully!
The update of your SexiGraf appliance completed successfully, you are now using version ' . $SexiGrafNewVersion . '!
Go Home
';
61 | }
62 | }
63 | }
64 | ?>
65 |
66 |