mirror of
https://github.com/unraid/api.git
synced 2025-12-31 13:39:52 -06:00
refactor(web): downgrade
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
Menu="About"
|
||||
Title="Downgrade OS"
|
||||
Icon="icon-update"
|
||||
Tag="upload"
|
||||
---
|
||||
<?php
|
||||
/**
|
||||
* @todo - need a downgrade icon
|
||||
*
|
||||
* If /boot/previous/bzroot exists, then the user has the option to downgrade to the previous version.
|
||||
* 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';
|
||||
|
||||
$diagnosticsZip = htmlspecialchars(str_replace(' ', '_', strtolower($var['NAME'])));
|
||||
|
||||
if (file_exists($restoreChangelogPath)) {
|
||||
exec("head -n4 $restoreChangelogPath", $rows);
|
||||
foreach ($rows as $row) {
|
||||
$i = stripos($row,'version');
|
||||
if ($i !== false) {
|
||||
[$restoreVersion, $restoreVersionReleaseDate] = explode(' ', trim(substr($row, $i+7)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
$restoreBranch = strpos($restoreVersion, 'rc') !== false
|
||||
? _('Next')
|
||||
: (strpos($restoreVersion, 'beta') !== false
|
||||
? _('Beta')
|
||||
: _('Stable'));
|
||||
}
|
||||
?>
|
||||
|
||||
<script>
|
||||
var diagnosticsFile = "";
|
||||
var nchan_diagnostics = new NchanSubscriber('/sub/diagnostics', { subscriber: 'websocket' });
|
||||
const args = {};
|
||||
|
||||
nchan_diagnostics.on('message', function(data) {
|
||||
if (data == '_DONE_') {
|
||||
nchan_diagnostics.stop();
|
||||
$('.sweet-alert').hide('fast').removeClass('nchan');
|
||||
swal.close();
|
||||
location = diagnosticsFile;
|
||||
setTimeout(cleanUp,4000);
|
||||
} else if (data) {
|
||||
let box = $('pre#swaltext');
|
||||
box.html(box.html() + '<br>' + data).scrollTop(box[0].scrollHeight);
|
||||
}
|
||||
});
|
||||
|
||||
function downgradeAction() {
|
||||
$.get('/plugins/dynamix.plugin.manager/include/Downgrade.php', { version: '<?=$restoreVersion?>' }, function() { refresh(); });
|
||||
}
|
||||
|
||||
function downgrade() {
|
||||
swal({
|
||||
title: "_(Diagnostics)_",
|
||||
text: "_(Please provide diagnostics when experiencing problems)_<br>_(Post these in the forums)_",
|
||||
html: true,
|
||||
type: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "<?= _('Diagnostics') ?>",
|
||||
cancelButtonText: "<?= _('Restore') ?>",
|
||||
}, function(diag) {
|
||||
if (diag) {
|
||||
// get diagnostics and then downgrade
|
||||
setTimeout(function() {
|
||||
diagnostics(zipfile());
|
||||
}, 250);
|
||||
} else {
|
||||
// downgrade immediately
|
||||
downgradeAction();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function cleanUp() {
|
||||
if (document.hasFocus()) {
|
||||
$.post('/webGui/include/Download.php', { cmd: 'delete', file: diagnosticsFile }, downgradeAction());
|
||||
} else {
|
||||
setTimeout(cleanUp,2000);
|
||||
}
|
||||
}
|
||||
function zipfile() {
|
||||
const tzoffset = (new Date()).getTimezoneOffset() * 60000; // offset in milliseconds
|
||||
const localISOTime = (new Date(Date.now() - tzoffset));
|
||||
const year = localISOTime.getFullYear();
|
||||
const month = String(localISOTime.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(localISOTime.getDate()).padStart(2, '0');
|
||||
const hours = String(localISOTime.getHours()).padStart(2, '0');
|
||||
const minutes = String(localISOTime.getMinutes()).padStart(2, '0');
|
||||
const dateOutput = `${year}${month}${day}_${hours}${minutes}`;
|
||||
return '<?=$diagnosticsZip?>-diagnostics-' + dateOutput + '.zip';
|
||||
}
|
||||
function diagnostics(file) {
|
||||
nchan_diagnostics.start();
|
||||
$.post('/webGui/include/Download.php', { cmd:'diag', file: file, anonymize: '' }, function(zip) {
|
||||
if (zip) {
|
||||
diagnosticsFile = zip;
|
||||
swal({
|
||||
title: "_(Downloading)_...",
|
||||
text: "/boot/logs" + zip + "<hr><pre id='swaltext'></pre>",
|
||||
html: true,
|
||||
animation: 'none',
|
||||
showConfirmButton: false,
|
||||
});
|
||||
$('.sweet-alert').addClass('nchan');
|
||||
$('button.confirm').prop('disabled', true);
|
||||
} else {
|
||||
nchan_diagnostics.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
function cleanUpFlashBackup(zip) {
|
||||
if (document.hasFocus()) {
|
||||
$('input[value="_(Creating Flash backup)_..."]').val("_(Flash backup)_").prop('disabled',false);
|
||||
$('div.spinner').hide('slow');
|
||||
$('#pleaseWait').hide('slow');
|
||||
$.post('/webGui/include/Download.php',{cmd:'unlink',file:zip});
|
||||
} else {
|
||||
setTimeout(function(){cleanUpFlashBackup(zip);},2000);
|
||||
}
|
||||
}
|
||||
function flashBackup() {
|
||||
$('input[value="_(Flash backup)_"]').val('_(Creating Flash backup)_...').prop('disabled',true);
|
||||
$('div.spinner').show('slow');
|
||||
$('#pleaseWait').show('slow');
|
||||
$.post('/webGui/include/Download.php',{cmd:'backup'},function(zip) {
|
||||
if (zip) {
|
||||
location = '/'+zip;
|
||||
setTimeout(function(){cleanUpFlashBackup(zip);},6000);
|
||||
} else {
|
||||
$('input[value="_(Creating Flash backup)_..."]').val("_(Flash backup)_");
|
||||
$('div.spinner').hide('slow');
|
||||
$('#pleaseWait').hide('slow');
|
||||
swal({title:"_(Creation error)_",text:"_(Insufficient free disk space available)_",type:'error',html:true,confirmButtonText:"_(Ok)_"});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<unraid-i18n-host>
|
||||
<unraid-downgrade-os
|
||||
restore-version="<?= $restoreExists && $restoreVersion != 'unknown' ? $restoreVersion : '' ?>"
|
||||
restore-release-date="<?= $restoreExists && $restoreVersionReleaseDate != 'unknown' ? $restoreVersionReleaseDate : '' ?>"></unraid-downgrade-os>
|
||||
</unraid-i18n-host>
|
||||
@@ -4,23 +4,11 @@ Icon="icon-update"
|
||||
Tag="upload"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2005-2022, Lime Technology
|
||||
* Copyright 2012-2022, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
*
|
||||
/**
|
||||
* If /boot/previous/bzroot exists, then the user has the option to downgrade to the previous version.
|
||||
* Parse the text file /boot/previous/changes.txt to get the version number of the previous version.
|
||||
* Then we move some file around and reboot.
|
||||
* Then we move some files around and reboot.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$check = $notify['unraidos'] ? 0 : 1;
|
||||
|
||||
$restoreVersion = $restoreBranch = $restoreVersionReleaseDate = 'unknown';
|
||||
@@ -46,12 +34,6 @@ if (file_exists($restoreChangelogPath)) {
|
||||
}
|
||||
?>
|
||||
|
||||
<unraid-i18n-host>
|
||||
<unraid-update-os
|
||||
restore-version="<?= $restoreExists && $restoreVersion != 'unknown' ? $restoreVersion : '' ?>"
|
||||
restore-release-date="<?= $restoreExists && $restoreVersionReleaseDate != 'unknown' ? $restoreVersionReleaseDate : '' ?>"></unraid-update-os>
|
||||
</unraid-i18n-host>
|
||||
|
||||
<script>
|
||||
var diagnosticsFile = "";
|
||||
var nchan_diagnostics = new NchanSubscriber('/sub/diagnostics', { subscriber: 'websocket' });
|
||||
@@ -160,3 +142,9 @@ function flashBackup() {
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<unraid-i18n-host>
|
||||
<unraid-update-os
|
||||
restore-version="<?= $restoreExists && $restoreVersion != 'unknown' ? $restoreVersion : '' ?>"
|
||||
restore-release-date="<?= $restoreExists && $restoreVersionReleaseDate != 'unknown' ? $restoreVersionReleaseDate : '' ?>"></unraid-update-os>
|
||||
</unraid-i18n-host>
|
||||
60
web/components/DowngradeOs.ce.vue
Normal file
60
web/components/DowngradeOs.ce.vue
Normal file
@@ -0,0 +1,60 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* @todo how are we going to update test, beta, and stable releases for internal testing?
|
||||
* @todo after install / downgrade detect if third-party drivers are installed and tell users to wait for a user to wait for a new notification
|
||||
*
|
||||
* run exec("ps aux | grep -E "inotifywait -q /boot/changes.txt -e move_self,delete_self" | grep -v "grep -E inotifywait" | awk '{print $2}'");
|
||||
* if this returns are value assume we have third-party drivers installed and tell the user to wait for a new notification
|
||||
*
|
||||
* view https://s3.amazonaws.com/dnld.lime-technology.com/stable/unRAIDServer.plg to see how the update is handled
|
||||
# ensure writes to USB flash boot device have completed
|
||||
sync -f /boot
|
||||
if [ -z "${plg_update_helper}" ]; then
|
||||
echo "Update successful - PLEASE REBOOT YOUR SERVER"
|
||||
else
|
||||
echo "Third party plugins found - PLEASE CHECK YOUR UNRAID NOTIFICATIONS AND WAIT FOR THE MESSAGE THAT IT IS SAFE TO REBOOT!"
|
||||
fi
|
||||
*/
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { useUpdateOsActionsStore } from '~/store/updateOsActions';
|
||||
|
||||
import 'tailwindcss/tailwind.css';
|
||||
import '~/assets/main.css';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
export interface Props {
|
||||
restoreReleaseDate?: string;
|
||||
restoreVersion?: string;
|
||||
}
|
||||
withDefaults(defineProps<Props>(), {
|
||||
restoreReleaseDate: '',
|
||||
restoreVersion: '',
|
||||
});
|
||||
|
||||
const updateOsActionsStore = useUpdateOsActionsStore();
|
||||
|
||||
const { rebootType } = storeToRefs(updateOsActionsStore);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UiPageContainer>
|
||||
<UpdateOsStatus :t="t" />
|
||||
<UpdateOsDowngrade
|
||||
v-if="restoreVersion && rebootType === ''"
|
||||
:release-date="restoreReleaseDate"
|
||||
:version="restoreVersion"
|
||||
:t="t" />
|
||||
<UpdateOsThirdPartyDrivers
|
||||
v-if="rebootType === 'thirdPartyDriversDownloading'"
|
||||
:t="t" />
|
||||
</UiPageContainer>
|
||||
</template>
|
||||
|
||||
<style lang="postcss">
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
</style>
|
||||
@@ -25,15 +25,6 @@ import '~/assets/main.css';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
export interface Props {
|
||||
restoreReleaseDate?: string;
|
||||
restoreVersion?: string;
|
||||
}
|
||||
withDefaults(defineProps<Props>(), {
|
||||
restoreReleaseDate: '',
|
||||
restoreVersion: '',
|
||||
});
|
||||
|
||||
const updateOsStore = useUpdateOsStore();
|
||||
const updateOsActionsStore = useUpdateOsActionsStore();
|
||||
|
||||
@@ -43,18 +34,13 @@ const { rebootType } = storeToRefs(updateOsActionsStore);
|
||||
|
||||
<template>
|
||||
<UiPageContainer>
|
||||
<UpdateOsStatus :t="t" />
|
||||
<UpdateOsStatus :showUpdateCheck="true" :t="t" />
|
||||
<UpdateOsUpdateIneligible
|
||||
v-if="availableWithRenewal && rebootType === ''"
|
||||
:t="t" />
|
||||
<UpdateOsUpdate
|
||||
v-if="available && rebootType === ''"
|
||||
:t="t" />
|
||||
<UpdateOsDowngrade
|
||||
v-if="restoreVersion && rebootType === ''"
|
||||
:release-date="restoreReleaseDate"
|
||||
:version="restoreVersion"
|
||||
:t="t" />
|
||||
<UpdateOsThirdPartyDrivers
|
||||
v-if="rebootType === 'thirdPartyDriversDownloading'"
|
||||
:t="t" />
|
||||
|
||||
@@ -29,12 +29,6 @@ const serverStore = useServerStore();
|
||||
const { dateTimeFormat } = storeToRefs(serverStore);
|
||||
const { formatDate } = useTimeHelper(dateTimeFormat.value, props.t, true);
|
||||
|
||||
const visible = ref(false);
|
||||
const toggleVisible = () => {
|
||||
visible.value = !visible.value;
|
||||
/** @todo scroll to bottom of component into view */
|
||||
};
|
||||
|
||||
const formattedReleaseDate = computed(() => {
|
||||
if (props.releaseDate) {
|
||||
return formatDate(dayjs(props.releaseDate, 'YYYY-MM-DD').valueOf());
|
||||
@@ -72,20 +66,12 @@ const downgradeButton = ref<UserProfileLink | undefined>({
|
||||
</span>
|
||||
</span>
|
||||
</h3>
|
||||
<div v-if="visible" class="text-16px leading-relaxed opacity-75 whitespace-normal">
|
||||
<div class="text-16px leading-relaxed opacity-75 whitespace-normal">
|
||||
<p>{{ t('Downgrades are only recommended if you\'re unable to solve a critical issue. In the rare event you need to downgrade we ask that you please provide us with Diagnostics so we can investigate your issue. You will be prompted with the option to download the Diagnostics zip once the downgrade process is started. From there please open a bug report on our forums with a description of the issue and include your diagnostics.') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<BrandButton
|
||||
v-if="!visible"
|
||||
@click="toggleVisible"
|
||||
:btn-style="'outline'"
|
||||
:icon="InformationCircleIcon"
|
||||
:text="t('Learn More')"
|
||||
class="flex-shrink-0" />
|
||||
|
||||
<div v-else-if="downgradeButton" class="flex flex-col sm:flex-shrink-0 items-center gap-16px">
|
||||
<div v-if="downgradeButton" class="flex flex-col sm:flex-shrink-0 items-center gap-16px">
|
||||
<BrandButton
|
||||
:btn-style="'underline'"
|
||||
:external="true"
|
||||
|
||||
@@ -101,7 +101,7 @@ export default defineNuxtConfig({
|
||||
path: '@/components/UpdateOs.ce',
|
||||
},
|
||||
{
|
||||
name: 'UnraidUpdateOs',
|
||||
name: 'UnraidDowngradeOs',
|
||||
path: '@/components/DowngradeOs.ce',
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user