reboot command and /dev/initctl allows rebooting - forces reload of all javascript

This commit is contained in:
Lisa Milne 2023-11-14 14:31:07 +10:00
parent befc29b2c7
commit d8570be0f2
2 changed files with 37 additions and 4 deletions

View file

@ -491,6 +491,14 @@ Options:
});
clite.commands.load('reboot',function(args,env,io) {
var stdio = io.include('stdio');
var fd = stdio.open('/dev/initctl',false);
if (!fd)
return 1;
stdio.write(fd,'6'); // switch to runlevel 6, reboot
stdio.close(fd);
return 0;
});

View file

@ -177,17 +177,35 @@ var clite = {
switch (rli) {
case 0:
n.data.content.data = 0;
// TODO: do something to power off
setTimeout(function() {
var s = Array.from(document.getElementsByTagName('src'));
s.forEach(function(el) {
el.parentNode.removeChild(el);
});
clite.term.preventInput();
delete clite;
clite = null;
},10);
break;
case 1:
case 1: // essentially the booting runlevel
n.data.content.data = 1;
break;
case 3:
case 3: // really just a status change, doesn't "do" anything
n.data.content.data = 3;
break;
case 6:
n.data.content.data = 6;
// TODO: do something to reboot
setTimeout(function() {
var l = clite.core.load.script;
var s = Array.from(document.getElementsByTagName('src'));
s.forEach(function(el) {
el.parentNode.removeChild(el);
});
clite.term.preventInput();
delete clite;
clite = null;
l('clite/core.js',function() {setTimeout('clite.init();',10)});
},10);
break;
default:;
}
@ -301,6 +319,12 @@ data/about.txt:/usr/share/site/about:0:0:-rw-rw-r--`;
clite.log.write('failed');
return;
}
var fd = clite.io.open('/dev/initctl',false);
if (fd) {
clite.io.write(fd,'3');
clite.io.close(fd);
}
// check cookies for login
clite.log.write('Checking for user session');
if (clite.user.init(vfsapi)) {// if logged in:
@ -954,6 +978,7 @@ clite.vfs = {
return false;
}
vfsdata.api.remove = function(path) {
// TODO: remove vfs node
return false;
}