Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple sources of startup files #1796

Open
PrincessRTFM opened this issue Apr 20, 2024 · 3 comments
Open

Allow multiple sources of startup files #1796

PrincessRTFM opened this issue Apr 20, 2024 · 3 comments
Labels
area-CraftOS This affects CraftOS, or any other Lua portions of the mod. enhancement An extension of a feature or a new feature. feedback wanted Tell me what you want, what you really really want.

Comments

@PrincessRTFM
Copy link

PrincessRTFM commented Apr 20, 2024

Currently, the bios.lua handling of startup files only supports a single "source" of user startup files. Specifically, all discovered user startup files are stored in a lua table, but each location that has any such files replaces the existing table, as can be seen on line 207. This means that if you have more than one drive with startup files, only the first such drive returned by peripheral.getNames() will have its files executed (since line 208 then terminates the loop, and if any disks have startup files then any local ones will not be run.

While this isn't actually a security concern, since users can simply disable the shell.allow_disk_startup setting, it does prevent users from having a normal startup file to do things like set completion for custom programs and allow disk programs to automatically set themselves up.

Currently, the only workaround is to disable shell.allow_disk_startup and write a local startup file that then emulates that functionality, searching for attached disks and checking for any startup files on any disks that are found. This is a little clunky and may be prone to error, or at least to edge-case unexpected behaviour, because if the computer itself has multiple startup files in a /startup directory and the disk loader is only one of them, then it becomes difficult to ensure that all local startup files will run before the disk ones do.

To that end, I propose changing the bios functionality to instead append startup files from disks (if enabled via shell.allow_disk_startup, of course) so that local files are always run, and then followed by any disk files present.

@PrincessRTFM PrincessRTFM added the enhancement An extension of a feature or a new feature. label Apr 20, 2024
@Wojbie
Copy link
Contributor

Wojbie commented Apr 20, 2024

This would have side effect of making it so disk drive startup no longer overwrites normal startup. Which was a feature of it basically forever.

@PrincessRTFM
Copy link
Author

Then it could be implemented with a setting, like bios.disk_startup_overrides_local with a default of true. In that case, it would be possible to disable the override behaviour, per-computer at that, in cases where it's undesirable.

@SquidDev SquidDev added feedback wanted Tell me what you want, what you really really want. area-CraftOS This affects CraftOS, or any other Lua portions of the mod. labels Apr 21, 2024
@hugeblank
Copy link
Member

Currently, the bios.lua handling of startup files only supports a single "source" of user startup files.

Technicality here, the bios doesn't actually invoke that startup file, it's done in the shell when there's no parent shell. The routing is: bios -> multishell -> shell -> rom/autorun -> computer startup files -> (first selected) disk drive startup files -> shell input

TL;DR for below: The solution is we really shouldn't be using two booleans and instead should be using a string list of either paths to the startup files or drives with roots containing the startup files. I attempt to address them in a way that makes the two booleans backwards comptabile, but it's a downright headache.

One solution would be to define a shell.startup.path setting that gets interpreted by the shell between computer startup files and disk drive startup files, assuming allow_startup is true in the first place. The most similar setting like this would be motd.path:

settings.define("motd.path", {
default = "/rom/motd.txt:/motd.txt",
description = [[The path to load random messages from. Should be a colon (":") separated string of file paths.]],
type = "string",
})

Another idea would be something like shell.startup_boot_order, which lists the order in which drives that could have startup files are ran. The default value would be something like "rom:hdd:drive_x" where drive_x is the first drive found by getNames(). Setting it to "" would be like setting shell.allow_startup and shell.allow_disk_startup to false, with the added ability that rom startup is skipped. This would require a couple of things happen:

  1. An fs.getDriveRoot function that works in the inverse of getDrive, returning the root path for the given mount.
  2. This part of the rom startup file should be moved into the shell (and modified to properly work with this idea).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CraftOS This affects CraftOS, or any other Lua portions of the mod. enhancement An extension of a feature or a new feature. feedback wanted Tell me what you want, what you really really want.
Projects
None yet
Development

No branches or pull requests

4 participants