Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- autoUpdate = true
- function initialize()
- settings.set("shell.allow_disk_startup", false)
- settings.save(".settings")
- getPeripherals()
- rednet.open(modem)
- initUsers()
- exists = fs.exists("saves/updater/update")
- if exists == false then
- file = fs.open("saves/updater/version", "w")
- file.writeLine("0")
- file.close()
- currentVersion = 0
- else file = fs.open("saves/updater/version", "r" )
- currentVersion = file.readLine()
- file.close()
- currentVersion = tonumber(currentVersion)
- end
- pb("r1cCb1Nn", "saves/updater/update")
- print("Updated updater")
- updater()
- multishell.setTitle(multishell.getCurrent(), "Ctrl")
- clear()
- getTime()
- write(time)
- print(": Initializing protocols")
- shell.openTab("protocols")
- getTime()
- write(time)
- print(": Booting up")
- getTime()
- write(time)
- print(": Initializing userData")
- shell.openTab("userData")
- getTime()
- write(time)
- print(": Initializing sessionKeys")
- shell.openTab("sessionKeys")
- getTime()
- write(time)
- print(": Initializing doorControl")
- shell.openTab("doorControl")
- getTime()
- write(time)
- print(": Initializing users")
- getTime()
- write(time)
- print(": Initializing toDo")
- shell.openTab("toDo")
- getTime()
- write(time)
- print(": Initializing Mail")
- shell.openTab("mail")
- getTime()
- write(time)
- print(": Initializing Voting")
- shell.openTab("voting")
- getTime()
- write(time)
- print(": Initializing Event manager")
- shell.openTab("event")
- clear()
- commandLine()
- end
- function updater()
- if autoUpdate == true then
- file = fs.open("saves/updater/update", "r" )
- file.readLine()
- file.readLine()
- file.readLine()
- newestVersion = file.readLine()
- file.close()
- newestVersion = tonumber(newestVersion)
- if newestVersion > currentVersion then
- clear()
- print("There is a new update available")
- print("Current version:", currentVersion, " Newest version", newestVersion)
- sleep(1)
- fs.delete("startup")
- fs.delete("userData")
- fs.delete("doorControl")
- fs.delete("sessionKeys")
- fs.delete("toDo")
- fs.delete("protocols")
- fs.delete("mail")
- fs.delete("voting")
- fs.delete("event")
- pb("7DszLukn", "startup")
- pb("uLg3X8mG", "userData")
- pb("zCjSRuqK", "doorControl")
- pb("HWMjqcGN", "sessionKeys")
- pb("nNNTNps2", "toDo")
- pb("fdY96RkA", "protocols")
- pb("K3b40auU", "mail")
- pb("ZrnBdvRs", "voting")
- pb("mRmQ69Gr", "event")
- file = fs.open("saves/updater/version", "w" )
- file.write(newestVersion)
- file.close()
- os.reboot()
- else
- print("The newest version is already installed")
- end
- end
- end
- function pb(paste, file)
- response = http.get("http://pastebin.com/raw/"..paste)
- sResponse = response.readAll()
- response.close()
- file = fs.open(file, "w" )
- file.write(sResponse)
- file.close()
- end
- function getPeripherals()
- sides = {"top", "bottom", "left", "right", "back"}
- for i, side in pairs(rs.getSides()) do
- local peripheral = peripheral.getType(side)
- if peripheral == "drive" then
- drive = side elseif
- peripheral == "modem" then
- modem = side
- end
- end
- if modem == nil then
- print("There is no modem attached!")
- print("Shutting down in 10 seconds")
- sleep(10)
- os.shutdown()
- end
- end
- function initUsers()
- exists = fs.exists("saves/userData")
- if exists == false then
- clear()
- line = 0
- text = "Welcome to the OverWatch OS server"
- printCentered()
- sleep(2)
- clear()
- line = 2
- text = "Please add the owner account"
- printCentered()
- sleep(2)
- fs.makeDir("saves/userData")
- clearance = 1
- addUser()
- line = 2
- text = "You have successfully added the account"
- printCentered()
- initUsers()
- sleep(2)
- end
- end
- function getTime()
- time = textutils.formatTime(os.time(), true)
- end
- function addUser()
- clear()
- line = 2
- text = "Username: "
- printCentered()
- line = 1
- text = "Password: "
- printCentered()
- line = 2
- centerY()
- a = x/2
- term.setCursorPos(a, b)
- username = read()
- line = 1
- centerY()
- a = x/2
- term.setCursorPos(a, b)
- password1 = read("*")
- clear()
- line = 2
- text = "Please re-enter the password"
- printCentered()
- line = 1
- text = "Password: "
- printCentered()
- line = 1
- centerY()
- a = x/2
- term.setCursorPos(a, b)
- password2 = read("*")
- if password1 == password2 then
- admin = fs.exists("saves/userData/user0")
- user1 = fs.exists("saves/userData/user1")
- user2 = fs.exists("saves/userData/user2")
- user3 = fs.exists("saves/userData/user3")
- user4 = fs.exists("saves/userData/user4")
- user5 = fs.exists("saves/userData/user5")
- accounts = 0
- if admin == true then
- accounts = 1 else
- print("admin is false")
- end
- if user1 == true then
- accounts = 2 else
- print("user1 is false")
- end
- if user2 == true then
- accounts = 3 else
- print("user2 is false")
- end
- if user3 == true then
- accounts = 4 else
- print("user3 is false")
- end
- if user4 == true then
- accounts = 5 else
- print("user4 is false")
- end
- if user5 == true then
- accounts = 6 else
- print("user5 is false")
- end
- if accounts == 0 then
- file = fs.open("saves/userData/user0", "w")
- file.writeLine(username)
- file.writeLine(password1)
- file.writeLine(clearance)
- file.close()
- clear()
- line = 0
- text = "User succsessfully added"
- printCentered()
- os.pullEvent() elseif
- accounts == 1 then
- file = fs.open("saves/userData/user1","w")
- file.writeLine(username)
- file.writeLine(password1)
- file.writeLine(clearance)
- file.close()
- clear()
- line = 0
- text = "User succsessfully added"
- printCentered()
- os.pullEvent() elseif
- accounts == 2 then
- file = fs.open("saves/userData/user2","w")
- file.writeLine(username)
- file.writeLine(password1)
- file.writeLine(clearance)
- file.close()
- clear()
- line = 0
- text = "User succsessfully added"
- printCentered()
- os.pullEvent() elseif
- accounts == 3 then
- file = fs.open("saves/userData/user3","w")
- file.writeLine(username)
- file.writeLine(password1)
- file.writeLine(clearance)
- file.close()
- clear()
- line = 0
- text = "User succsessfully added"
- printCentered()
- os.pullEvent() elseif
- accounts == 4 then
- file = fs.open("saves/userData/user4","w")
- file.writeLine(username)
- file.writeLine(password1)
- file.writeLine(clearance)
- file.close()
- clear()
- line = 0
- text = "User succsessfully added"
- printCentered()
- os.pullEvent() elseif
- accounts == 5 then
- file = fs.open("saves/userData/user5","w")
- file.writeLine(username)
- file.writeLine(password1)
- file.writeLine(clearance)
- file.close() elseif
- accounts == 6 then
- clear()
- line = 0
- text = "You already have the maximum number of accounts"
- printCentered()
- sleep(1)
- os.pullEvent()
- end
- initialize() else
- clear()
- line = 2
- text = "Passwords do not match"
- printCentered()
- sleep(1)
- os.pullEvent()
- addUser()
- end
- end
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function getResolution()
- x,y = term.getSize()
- end
- function centerX()
- lenght = string.len(text)/2
- a = x/2 - lenght
- end
- function centerY()
- b = y/2 - line
- end
- function printCentered()
- centerX()
- centerY()
- term.setCursorPos(a,b)
- print(text)
- end
- function listUsers()
- clear()
- print("Registered users:")
- file = fs.open("saves/userData/user0","r")
- user = file.readLine()
- pass = file.readLine()
- clearance = file.readLine()
- file.close()
- printUser()
- user1 = fs.exists("saves/userData/user1")
- user2 = fs.exists("saves/userData/user2")
- user3 = fs.exists("saves/userData/user3")
- user4 = fs.exists("saves/userData/user4")
- user5 = fs.exists("saves/userData/user5")
- if user1 == true then
- file = fs.open("saves/userData/user1","r")
- user = file.readLine()
- pass = file.readLine()
- clearance = file.readLine()
- file.close()
- printUser()
- end
- if user2 == true then
- file = fs.open("saves/userData/user2","r")
- user = file.readLine()
- pass = file.readLine()
- clearance = file.readLine()
- file.close()
- printUser()
- end
- if user3 == true then
- file = fs.open("saves/userData/user3","r")
- user = file.readLine()
- pass = file.readLine()
- clearance = file.readLine()
- file.close()
- printUser()
- end
- if user4 == true then
- file = fs.open("saves/userData/user4","r")
- user = file.readLine()
- pass = file.readLine()
- clearance = file.readLine()
- file.close()
- printUser()
- end
- if user5 == true then
- file = fs.open("saves/userData/user5","r")
- user = file.readLine()
- pass = file.readLine()
- clearance = file.readLine()
- file.close()
- printUser()
- end
- sleep(0.1)
- os.pullEvent()
- commandLine()
- end
- function printUser()
- if clearance == "1.0" then
- term.setTextColor(colors.red)
- print(user)
- term.setTextColor(colors.white) elseif
- clearance == "2" then
- term.setTextColor(colors.green)
- print(user)
- term.setTextColor(colors.white) elseif
- clearance == "3" then
- term.setTextColor(colors.lime)
- print(user)
- term.setTextColor(colors.white) elseif
- clearance == "4" then
- term.setTextColor(colors.blue)
- print(user)
- term.setTextColor(colors.white)
- end
- end
- function commandLine()
- clear()
- term.setCursorPos(1,y)
- term.clearLine()
- term.setCursorPos(1,y-1)
- term.clearLine()
- write("Command:")
- command = read()
- if command == "add user" then
- clear()
- line = 4
- text = "Add a new user"
- printCentered()
- line = 2
- text = "Select a clearance level"
- printCentered()
- line = 1
- centerY()
- a = x/2
- term.setCursorPos(a,b)
- clearance = read()
- if clearance == "1" then
- addUser() elseif
- clearance == "2" then
- addUser() elseif
- clearance == "3" then
- addUser() elseif
- clearance == "4" then
- addUser() else
- clear()
- line = 0
- text = "Invalid number. Must be between 1 and 4"
- printCentered()
- sleep(2)
- initialize()
- end elseif
- command == "list users" then
- listUsers() elseif
- command == "home" then
- commandLine()
- elseif command == "pair device" then
- clear()
- term.setCursorPos(1,1)
- getPeripherals()
- if drive == nil then
- print("To pair a device, please attach a disk drice and reboot the computer")
- sleep(2)
- commandLine()
- end
- print("Doing this will delete everything on the PoC")
- print("Are you sure you wish to proceed (type in yes or no)")
- term.setCursorPos(1,y-1)
- write("Anwser:")
- anwser = read()
- if anwser == "yes" then
- clear()
- term.setCursorPos(1,1)
- print("Insert the turned on PoC into the drive")
- present = disk.isPresent(drive)
- if present == true then
- fs.delete("disk/startup")
- print("deleted data")
- pb("jnZP4DN6", "disk/startup")
- print("Loaded OS")
- file = fs.open("disk/saves/OS files/id","w")
- file.writeLine(os.getComputerID())
- file.close()
- file = fs.open("saves/trustedIDs/IDs","w")
- file.writeLine(disk.getID(drive))
- file.close()
- print("Device paired")
- sleep(1)
- commandLine()
- else
- clear()
- print("No device detected")
- sleep(2)
- commandLine()
- end
- elseif anwser == "no" then
- print("Pairing aborted")
- sleep(1)
- commandLine()
- end
- elseif command == "wipe device" then
- fs.delete("/disk/")
- print("Disk wiped")
- sleep(1)
- commandLine()
- else
- print("Invalid command")
- sleep(1)
- commandLine()
- end
- end
- function pb(paste, file)
- response = http.get("http://pastebin.com/raw/"..paste)
- sResponse = response.readAll()
- response.close()
- file = fs.open(file, "w" )
- file.write(sResponse)
- file.close()
- end
- getResolution()
- initialize()
Add Comment
Please, Sign In to add comment