Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local event = require("event")
- local computer = require("computer")
- local io = require("io")
- local filesystem = require("filesystem")
- local m = component.modem -- get primary modem component
- function RunTasks(target)
- local file = io.open(target,"r")
- local content
- repeat
- content = file.readLine()
- if content ~= nil then shell.run(content) end
- until content == nil
- file.close()
- print("tasks Completed")
- end
- function CheckLocalStability()
- if computer.energy() < 8 then
- error("insignificant power for operations")
- elseif filesystem.exists("AFIDOS/StartupTasks.txt") == false then
- error("starting tasks missing")
- elseif filesystem.exists("AFIDOS/RoutineTasks.txt") == false then
- error("routine tasks missing")
- else
- Loop()
- end
- end
- function TranslateMessage(a,b,c,d,e,f, g)
- if e == "Alert" then
- elseif e == "update" then
- elseif e == "admin" then
- if f == "shutdown" then
- computer.shutdown()
- elseif f == "reboot" then
- computer.shutdown(true)
- elseif f == "diagnostics" then
- end
- elseif e == "system" then
- elseif e == "runTasks" then
- RunTasks(f)
- elseif e == "upload" then
- local file = io.open(g,"w")
- file.write(f)
- file.close()
- elseif e == "download" then
- local file = io.open(f,"r")
- m.send(a,c,file.readAll())
- file.close()
- end
- end
- function Loop()
- RunTasks("AFIDOS/StartupTasks.txt")
- m.open(53)
- local Reboot = false
- while true do
- local a, b, c, d, e, f, g, h = event.pull([timer: 5])
- RunTasks("AFIDOS/RoutineTasks.txt")
- if a == "modem_message" then
- TranslateMessage(b,c,d,e,f,g,h)
- elseif computer.energy() < 8 then
- Reboot = false
- break
- elseif computer.runtime() > 10800 then
- Reboot = true
- break
- end
- end
- computer.beep()
- computer.shutdown(Reboot)
- end
- CheckLocalStability()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement