refactor: reboot detection passed to upc

This commit is contained in:
Zack Spear
2023-09-25 14:39:22 -07:00
committed by Zack Spear
parent 297bce3a89
commit 5cf1740977

View File

@@ -2,6 +2,17 @@
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once("$docroot/plugins/dynamix.my.servers/include/state.php");
require_once("$docroot/plugins/dynamix.my.servers/include/translations.php");
/**
* Reboot detection was moved from Update.page to here as to seed the web components on every page rather than just on /Tools/Update
*/
$readme = @file_get_contents("$docroot/plugins/unRAIDServer/README.md",false,null,0,20)?:''; // read first 20 bytes of README.md
$reboot = preg_match("/^\*\*(REBOOT REQUIRED|DOWNGRADE)/", $readme);
$rebootForDowngrade = $reboot && strpos($readme, 'DOWNGRADE') !== false;
$rebootForUpgrade = $reboot && strpos($readme, 'REBOOT REQUIRED') !== false;
$rebootType = $rebootForDowngrade ? 'downgrade' : ($rebootForUpgrade ? 'upgrade' : '');
?>
<script>
window.LOCALE_DATA = '<?= rawurlencode(json_encode($webComponentTranslations, JSON_UNESCAPED_SLASHES, JSON_UNESCAPED_UNICODE)) ?>';
@@ -21,5 +32,7 @@ if (!document.getElementsByTagName(modalsWebComponent).length) {
<?
echo "
<unraid-i18n-host>
<unraid-user-profile server='" . json_encode($serverState) . "'></unraid-user-profile>
<unraid-user-profile
reboot-type='" . $rebootType . "'
server='" . json_encode($serverState) . "'></unraid-user-profile>
</unraid-i18n-host>";