-- Define basic color printing functions function cprintln(text, color) prev = term.getTextColor() term.setTextColor(color) print(text) term.setTextColor(prev) end function cprint(text, color) prev = term.getTextColor() term.setTextColor(color) write(text) term.setTextColor(prev) end -- Load the WGET API os.loadAPI("wget") -- Clear the terminal term.clear() term.setCursorPos(1, 1) function update() cprintln("Updating Maunium Controller...", colors.cyan) os.sleep(1) suc = wget.download("http://dl.maunium.net/cc/maunium", "startup") if suc == 0 then cprintln("Update complete, rebooting...", colors.green) os.sleep(1) os.reboot() elseif suc == -1 then cprintln("Couldn't download update (HTTP error)!", colors.red) elseif suc == 1 then cprintln("Couldn't read update body!", colors.red) end end function updateWget() wget.download("http://dl.maunium.net/cc/wget", "wget") os.unloadAPI("wget") os.loadAPI("wget") cprintln("WGET updated successfully!", colors.green) end cprintln("Maunium Controller started", colors.lime) protocol = "mauminers" rednet.open("back") selected_miner = 6 while true do cprint("> ", colors.lime) inp = read() args = {} for word in inp:gmatch("%w+") do table.insert(args, word) end if args[1] == "update" then if args[2] then if args[2] == "wget" then updateWget() elseif args[2] == "maunium" or args[2] == "os" or args[2] == "system" then update() end else update() end elseif args[1] == "miner" then if args[1] == "update" then rednet.send(selected_miner, "update", protocol) local id, text = rednet.read(protocol) if text == "10" then print("Update complete, miner rebooting", colors.green) end elseif args[1] == "select" then if not args[2] then cprintln("Usage: miner select ", colors.red) else if args[2] == "one" or args[2] == "1" then selected_miner = 6 cprintln("Successfully selected Mauminer One", colors.green) elseif args[2] == "two" or args[2] == "2" then selected_miner = 7 cprintln("Successfully selected Mauminer Two", colors.green) end end end elseif args[1] == "shutdown" then cprintln("Maunium Controller shutting down...", colors.cyan) os.sleep(2) os.shutdown() elseif args[1] == "reboot" then cprintln("Maunium Controller rebooting...", colors.cyan) os.sleep(1) os.reboot() else cprintln("Unknown command!", colors.red) end end