All I had to do was change part of my install block install everything, but only load the actual APIs as an API, skipping the startup.
My new code for the startup is as follows:
local function getVersion()
return 1.038
end
os.pullEvent = os.pullEventRaw
local defaultUser = "Admin"
local defaultPass = "Password"
local updateTable = {}
updateTable[1] = {code = "GWUUfNeh", filename = "startup"}
updateTable[2] = {code = "vphtijAh", filename = ".smartOS/smartAPI"}
updateTable[3] = {code = "dXamY7Jc", filename = ".smartOS/smartWrite"}
updateTable[4] = {code = "PFZXduDm", filename = ".smartOS/smartGUI"}
updateTable[5] = {code = "iMZH1L6p", filename = ".smartOS/smartFile"}
--file integrity check
if not fs.exists(".smartOS") then
fs.makeDir(".smartOS")
elseif not fs.exists(".smartOS/userList") then
local tUsers = {}
tUsers[1] = {}
tUsers[1].username = defaultUser
tUsers[1].password = defaultPass
tUsers[1].tZ = "utc"
tUsers[1].level = 1
local userFile = fs.open(".smartOS/userList","w")
userFile.write(textutils.serialize(tUsers))
userFile.close()
userExists = false
end
for i = 1, #updateTable do --this is the block I had to change
if not fs.exists(updateTable[i].filename) then
local updateSite = http.get("http://pastebin.com/raw.php?i="..updateTable[i].code)
local siteFile = updateSite.readAll()
local writeFile = fs.open(updateTable[i].filename,"w")
writeFile.write(siteFile)
writeFile.close()
if not updateTable[i] == "startup" then
os.unloadAPI(updateTable[i].filename)
os.loadAPI(updateTable[i].filename)
end
else
if not updateTable[i] == "startup" then
os.unloadAPI(updateTable[i].filename)
os.loadAPI(updateTable[i].filename)
end
end
end
-- boot screen
local function bootUp()
smartGUI.splash()
term.setCursorPos(4,15)
write("Checking HTTP connection...")
if http then
httpStatus = true
write("Connected")
else
httpStatus = false
write("No connection")
end
term.setCursorPos(4,16)
write("Checking for peripherals...")
smartAPI.pDetect()
write("Complete")
term.setCursorPos(4,17)
write("Checking for updates...")
local updateNum = 0
for i = 1, #updateTable do
local _update = smartAPI.update(updateTable[i].code, updateTable[i].filename)
if _update == true then
updateNum = updateNum + 1
elseif _update == "Error" then
term.setCursorPos(26,17)
write(_update)
end
term.setCursorPos(26,17)
write("Updates found: "..updateNum)
end
if updateNum > 0 then
local query = smartAPI.errorHandle("Would you like to restart now?", "Yes", "No")
if query == 1 then os.reboot() end
end
end
--login
local function login()
term.clear()
term.setCursorPos(1,1)
for i = 1, #smartGUI.loginTab do
print(smartGUI.loginTab[i])
end
term.setCursorPos(20,9)
local inputUser = smartWrite.limitRead(17)
term.setCursorPos(20,10)
local inputPass = smartWrite.limitRead(17, "*")
return inputUser, inputPass
end
-- starting script
bootUp()
logged = false
if userExists == false then
smartAPI.userCreate(2)
end
--login script
local attempt = 1
local logged = false
repeat
local user, pass = login()
local tUsers = smartAPI.loadUsers()
for i = 1, #tUsers do
if tUsers[i].username == user and tUsers[i].password == pass then
logged = true
break
end
end
if attempt >= 5 then
smartAPI.errorHandle("LOCK")
elseif logged == false then
smartAPI.errorHandle("Username or password is incorrect")
attempt = attempt + 1
end
until logged == true
Edited by Cranium, 14 November 2012 - 05:48 AM.












