auto load rc.tb script

This commit is contained in:
2025-10-12 14:13:22 +02:00
parent c0f91dcced
commit 5aebc61c06
5 changed files with 8 additions and 11 deletions

View File

@ -1,3 +1,4 @@
print 'this is an init script!' print 'this is an init script!\n'
base:/bin/pctl ls $tb -m runfile -f base:/scripts/mount.tb
base:/bin/tb -m interactive -preload base:/scripts/rc.tb $pctl ls
$tb -m interactive

1
base/scripts/mount.tb Normal file
View File

@ -0,0 +1 @@
print 'Mounting filesystems...\n'

View File

@ -8,7 +8,7 @@ Dev_t termdev;
void tb_runinitscript(void) { void tb_runinitscript(void) {
devctl(&termdev, DEVCTL_GET_HANDLE, (uint8_t *)"termdev", 0, 0); devctl(&termdev, DEVCTL_GET_HANDLE, (uint8_t *)"termdev", 0, 0);
char *tbargs[] = { "-m", "runfile", "-f", "base:/scripts/init.tb", "-logcmds", "yes" }; char *tbargs[] = { "-m", "runfile", "-f", "base:/scripts/init.tb" };
int32_t tb = processctl(-1, PCTL_SPAWN, (uint64_t)"base:/bin/tb", (uint64_t)(char **)tbargs, ARRLEN(tbargs)); int32_t tb = processctl(-1, PCTL_SPAWN, (uint64_t)"base:/bin/tb", (uint64_t)(char **)tbargs, ARRLEN(tbargs));
processctl(tb, PCTL_RUN, 0, 0, 0); processctl(tb, PCTL_RUN, 0, 0, 0);

View File

@ -21,8 +21,6 @@ struct {
bool logcmds; bool logcmds;
char *preloadpath;
char *runstring; char *runstring;
} CONFIG; } CONFIG;
@ -30,7 +28,6 @@ static Arg ARGS[] = {
ARG("-m", ARG_STRING, &CONFIG.modestr), ARG("-m", ARG_STRING, &CONFIG.modestr),
ARG("-f", ARG_STRING, &CONFIG.filepath), ARG("-f", ARG_STRING, &CONFIG.filepath),
ARG("-logcmds", ARG_BOOL, &CONFIG.logcmds), ARG("-logcmds", ARG_BOOL, &CONFIG.logcmds),
ARG("-preload", ARG_STRING, &CONFIG.preloadpath),
ARG("-rs", ARG_STRING, &CONFIG.runstring), ARG("-rs", ARG_STRING, &CONFIG.runstring),
ARG_END(), ARG_END(),
}; };
@ -153,9 +150,7 @@ void main(void) {
set_config(); set_config();
if (CONFIG.preloadpath != NULL) { do_file("base:/scripts/rc.tb");
do_file(CONFIG.preloadpath);
}
if (CONFIG.mode == MODE_INTERACTIVE) { if (CONFIG.mode == MODE_INTERACTIVE) {
devctl(&ps2kbdev, DEVCTL_GET_HANDLE, (uint8_t *)"ps2kbdev", 0, 0); devctl(&ps2kbdev, DEVCTL_GET_HANDLE, (uint8_t *)"ps2kbdev", 0, 0);

View File

@ -86,7 +86,7 @@ bool rt_PID(Token *tks) {
bool rt_do(Token *tks) { bool rt_do(Token *tks) {
bool ok = true; bool ok = true;
char *prepended_args[] = { "-m", "runstring", "-preload", "base:/scripts/rc.tb", "-rs" }; char *prepended_args[] = { "-m", "runstring", "-rs" };
#define SUBSH_MAX_STRING PROC_ARG_MAX #define SUBSH_MAX_STRING PROC_ARG_MAX
char *s = umalloc(SUBSH_MAX_STRING); char *s = umalloc(SUBSH_MAX_STRING);