system: return uptime and reboot required
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
exports = module.exports = {
|
||||
reboot,
|
||||
isRebootRequired,
|
||||
getInfo,
|
||||
getUbuntuVersion,
|
||||
getDisks,
|
||||
getSwaps,
|
||||
@@ -279,9 +279,15 @@ async function reboot() {
|
||||
if (error) debug('reboot: could not reboot. %o', error);
|
||||
}
|
||||
|
||||
async function isRebootRequired() {
|
||||
async function getInfo() {
|
||||
// https://serverfault.com/questions/92932/how-does-ubuntu-keep-track-of-the-system-restart-required-flag-in-motd
|
||||
return fs.existsSync('/var/run/reboot-required');
|
||||
const rebootRequired = fs.existsSync('/var/run/reboot-required');
|
||||
const uptime = safe.child_process.execSync('uptime -s', { encoding: 'utf8' });
|
||||
|
||||
return {
|
||||
uptime,
|
||||
rebootRequired
|
||||
};
|
||||
}
|
||||
|
||||
async function startUpdateDiskUsage() {
|
||||
@@ -330,7 +336,7 @@ async function getBlockDevices() {
|
||||
}
|
||||
|
||||
async function checkRebootRequired() {
|
||||
const rebootRequired = await isRebootRequired();
|
||||
const { rebootRequired } = await getInfo();
|
||||
if (rebootRequired) {
|
||||
await notifications.alert(notifications.ALERT_REBOOT, 'Reboot Required', 'To finish ubuntu security updates, a reboot is necessary.', { persist: true });
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user