Computercraft/src/startup.lua
2024-06-08 22:32:45 +02:00

66 lines
1.2 KiB
Lua

--you may change these values
local repo = "https://git.brulijam.com/brulijam/Computercraft/raw/branch/main/src"
local labelPrefix = "SPHEAL"
---------------------------------
print("[Booting]")
if not (fs.exists("brulijam/config/system.txt")) then
local systemConfig = {}
systemConfig["labelPrefix"] = labelPrefix
file = fs.open("brulijam/config/system.txt", "w")
file.write(systemConfig)
file.close()
end
local motd = settings.get("motd.enable")
if motd then
shell.run("set motd.enable false")
os.reboot()
end
--fetch sync script
getRequest = http.get(repo .. "/brulijam/sync.lua")
file = fs.open("/brulijam/sync.lua", "w")
file.write(getRequest.readAll())
file.close()
--task.lua contains stuff that should be done after boot
if not (fs.exists("brulijam/task.lua")) then
file = fs.open("brulijam/task.lua", "a")
file.writeLine("--use this file to execute programs")
file.close()
end
shell.run("brulijam/task.lua")
--execute sync script
shell.run("/brulijam/sync.lua")
--set label if not set
shell.run("/brulijam/setLabel.lua")
--create networking key
shell.run("/brulijam/lib/createNetworkingKey.lua")
--shell.run("/brulijam/systemlock.lua")
--you shall not pass systemlock
--os.reboot()