mirror of
https://codeberg.org/TicklishHoneyBee/CLIte.git
synced 2026-03-11 09:04:37 +00:00
start setting up for runlevels via /dev/initctl
This commit is contained in:
parent
3dbefb93da
commit
befc29b2c7
2 changed files with 40 additions and 0 deletions
|
|
@ -490,5 +490,9 @@ Options:
|
|||
return 0;
|
||||
});
|
||||
|
||||
clite.commands.load('reboot',function(args,env,io) {
|
||||
return 0;
|
||||
});
|
||||
|
||||
// insert commands above this line
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,6 +160,42 @@ var clite = {
|
|||
};
|
||||
n.perms = 'crw-rw-rw-';
|
||||
n.data.isdev = true;
|
||||
// /dev/initctl - writing to it sets the runlevel, reading from it returns the current runlevel
|
||||
vfsapi.mkFile('/dev/initctl');
|
||||
n = vfsapi.getNode('/dev/initctl');
|
||||
if (!n) {
|
||||
clite.log.write('initctl device failure');
|
||||
return false;
|
||||
}
|
||||
n.data.content = {
|
||||
data:1,
|
||||
read:function() {
|
||||
return n.data.content.data.toString();
|
||||
},
|
||||
write:function(rl) {
|
||||
var rli = parseInt(rl);
|
||||
switch (rli) {
|
||||
case 0:
|
||||
n.data.content.data = 0;
|
||||
// TODO: do something to power off
|
||||
break;
|
||||
case 1:
|
||||
n.data.content.data = 1;
|
||||
break;
|
||||
case 3:
|
||||
n.data.content.data = 3;
|
||||
break;
|
||||
case 6:
|
||||
n.data.content.data = 6;
|
||||
// TODO: do something to reboot
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
n.perms = 'crw-rw-rw-';
|
||||
n.data.isdev = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue