diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/reboot-details.php b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/reboot-details.php
new file mode 100644
index 000000000..29c91e48f
--- /dev/null
+++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/reboot-details.php
@@ -0,0 +1,97 @@
+
+
+/**
+ * RebootDetails class is responsible for detecting the type and version of a system reboot required in the context of an unRAID server.
+ *
+ * Usage:
+ * ```
+ * $rebootDetails = new RebootDetails();
+ * $rebootType = $rebootDetails->getRebootType();
+ * ```
+ */
+class RebootDetails
+{
+ /**
+ * @var string $rebootType Stores the type of reboot required, which can be 'update', 'downgrade', or 'thirdPartyDriversDownloading'.
+ */
+ private $rebootType = '';
+
+ /**
+ * Constructs a new RebootDetails object and automatically detects the reboot type during initialization.
+ */
+ public function __construct()
+ {
+ $this->detectRebootType();
+ }
+
+ /**
+ * Detects the type of reboot required based on the contents of the unRAID server's README.md file.
+ * Sets the $rebootType property accordingly.
+ */
+ private function detectRebootType()
+ {
+ $docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
+
+ $rebootReadme = @file_get_contents("$docroot/plugins/unRAIDServer/README.md", false, null, 0, 20) ?: '';
+ $rebootDetected = preg_match("/^\*\*(REBOOT REQUIRED|DOWNGRADE)/", $rebootReadme);
+
+ $rebootForDowngrade = $rebootDetected && strpos($rebootReadme, 'DOWNGRADE') !== false;
+ $rebootForUpdate = $rebootDetected && strpos($rebootReadme, 'REBOOT REQUIRED') !== false;
+
+ $this->rebootType = $rebootForDowngrade ? 'downgrade' : ($rebootForUpdate ? 'update' : '');
+
+ // Detect if third-party drivers were part of the update process
+ $processWaitingThirdParthDrivers = "inotifywait -q /boot/changes.txt -e move_self,delete_self";
+ // Run the ps command to list processes and check if the process is running
+ $ps_command = "ps aux | grep -E \"$processWaitingThirdParthDrivers\" | grep -v \"grep -E\"";
+ $output = shell_exec($ps_command) ?? '';
+ if (strpos($output, $processWaitingThirdParthDrivers) !== false) {
+ $this->rebootType = 'thirdPartyDriversDownloading';
+ }
+ }
+
+ /**
+ * Gets the type of reboot required, which can be 'update', 'downgrade', or 'thirdPartyDriversDownloading'.
+ *
+ * @return string The type of reboot required.
+ */
+ public function getRebootType()
+ {
+ return $this->rebootType;
+ }
+
+ /**
+ * Detects and retrieves the version information related to the system reboot based on the contents of the '/boot/changes.txt' file.
+ *
+ * @return string The system version information or 'Not found' if not found, or 'File not found' if the file is not present.
+ */
+ public function getRebootVersion()
+ {
+ $file_path = '/boot/changes.txt';
+
+ // Check if the file exists
+ if (file_exists($file_path)) {
+ // Open the file for reading
+ $file = fopen($file_path, 'r');
+
+ // Read the file line by line until we find a line that starts with '# Version'
+ while (($line = fgets($file)) !== false) {
+ if (strpos($line, '# Version') === 0) {
+ // Use a regular expression to extract the full version string
+ if (preg_match('/# Version\s+(\S+)/', $line, $matches)) {
+ $fullVersion = $matches[1];
+ return $fullVersion;
+ } else {
+ return 'Not found';
+ }
+ break;
+ }
+ }
+
+ // Close the file
+ fclose($file);
+ } else {
+ return 'File not found';
+ }
+ }
+}
diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php
index d8e834ab8..c83821088 100644
--- a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php
+++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php
@@ -1,4 +1,7 @@
getRebootType();
$serverState = [
"apiKey" => $myservers['upc']['apikey'] ?? '',
@@ -122,7 +78,6 @@ $serverState = [
"osVersionBranch" => $osVersionBranch,
"protocol" => $_SERVER['REQUEST_SCHEME'],
"rebootType" => $rebootType,
- "rebootVersion" => $rebootVersion,
"regDev" => @(int)$var['regDev'] ?? 0,
"regGen" => @(int)$var['regGen'],
"regGuid" => @$var['regGUID'] ?? '',
diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/Downgrade.page b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/Downgrade.page
index ff77bf336..f61c473c4 100644
--- a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/Downgrade.page
+++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/Downgrade.page
@@ -4,6 +4,11 @@ Icon="icon-update"
Tag="upload"
---
getRebootVersion();
/**
* @note icon-update is rotated via CSS in myservers1.php
*
@@ -11,8 +16,6 @@ Tag="upload"
* Parse the text file /boot/previous/changes.txt to get the version number of the previous version.
* Then we move some files around and reboot.
*/
-$check = $notify['unraidos'] ? 0 : 1;
-
$restoreVersion = $restoreBranch = $restoreVersionReleaseDate = 'unknown';
$restoreExists = file_exists('/boot/previous/bzroot');
$restoreChangelogPath = '/boot/previous/changes.txt';
@@ -158,6 +161,7 @@ function confirmDowngrade() {
\ No newline at end of file
diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/Update.page b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/Update.page
index f2d471dcf..2bcd2ec9b 100644
--- a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/Update.page
+++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/Update.page
@@ -3,6 +3,13 @@ Title="Update OS"
Icon="icon-update"
Tag="upload"
---
+getRebootVersion();
+?>
-
+
\ No newline at end of file
diff --git a/web/components/DowngradeOs.ce.vue b/web/components/DowngradeOs.ce.vue
index b14907c28..cc07c1a2d 100644
--- a/web/components/DowngradeOs.ce.vue
+++ b/web/components/DowngradeOs.ce.vue
@@ -16,8 +16,10 @@ else
fi
*/
import { storeToRefs } from 'pinia';
+import { onBeforeMount } from 'vue';
import { useI18n } from 'vue-i18n';
+import { useServerStore } from '~/store/server';
import { useUpdateOsActionsStore } from '~/store/updateOsActions';
import 'tailwindcss/tailwind.css';
@@ -26,14 +28,17 @@ import '~/assets/main.css';
const { t } = useI18n();
export interface Props {
+ rebootVersion?: string;
restoreReleaseDate?: string;
restoreVersion?: string;
}
-withDefaults(defineProps(), {
+const props = withDefaults(defineProps(), {
+ rebootVersion: '',
restoreReleaseDate: '',
restoreVersion: '',
});
+const serverStore = useServerStore();
const updateOsActionsStore = useUpdateOsActionsStore();
const { rebootType } = storeToRefs(updateOsActionsStore);
@@ -44,6 +49,10 @@ const subtitle = computed(() => {
}
return '';
});
+
+onBeforeMount(() => {
+ serverStore.setRebootVersion(props.rebootVersion);
+});
diff --git a/web/components/UpdateOs.ce.vue b/web/components/UpdateOs.ce.vue
index 16ea427cd..4fdd8ce8f 100644
--- a/web/components/UpdateOs.ce.vue
+++ b/web/components/UpdateOs.ce.vue
@@ -19,6 +19,7 @@ import { storeToRefs } from 'pinia';
import { useI18n } from 'vue-i18n';
import { WEBGUI_TOOLS_UPDATE } from '~/helpers/urls';
+import { useServerStore } from '~/store/server';
import { useUpdateOsActionsStore } from '~/store/updateOsActions';
import 'tailwindcss/tailwind.css';
@@ -26,6 +27,14 @@ import '~/assets/main.css';
const { t } = useI18n();
+export interface Props {
+ rebootVersion?: string;
+}
+const props = withDefaults(defineProps(), {
+ rebootVersion: '',
+});
+
+const serverStore = useServerStore();
const updateOsActionsStore = useUpdateOsActionsStore();
const { rebootType } = storeToRefs(updateOsActionsStore);
@@ -43,6 +52,7 @@ onBeforeMount(() => {
if (showLoader.value) {
updateOsActionsStore.executeUpdateOsCallback(true);
}
+ serverStore.setRebootVersion(props.rebootVersion);
});
diff --git a/web/store/server.ts b/web/store/server.ts
index c0ac7b66f..2eec33ccc 100644
--- a/web/store/server.ts
+++ b/web/store/server.ts
@@ -901,6 +901,10 @@ export const useServerStore = defineStore('server', () => {
});
};
+ const setRebootVersion = (version: string) => {
+ rebootVersion.value = version;
+ };
+
watchEffect(() => {
if (rebootVersion.value) {
console.debug('[server.rebootVersion]', rebootVersion.value);
@@ -968,5 +972,6 @@ export const useServerStore = defineStore('server', () => {
fetchServerFromApi,
refreshServerState,
filteredKeyActions,
+ setRebootVersion,
};
});