Update sPhone.lua

This commit is contained in:
Ale32bit 2015-11-18 16:54:17 +01:00
parent 974dcb72f8
commit 55db5b3c12

View file

@ -50,6 +50,7 @@ local function recovery()
print("[2] Update sPhone") print("[2] Update sPhone")
print("[3] Reset User Config") print("[3] Reset User Config")
print("[4] Continue Booting") print("[4] Continue Booting")
print("[5] Boot in safe mode")
while true do while true do
local _, k = os.pullEvent("key") local _, k = os.pullEvent("key")
if k == 2 then if k == 2 then
@ -79,6 +80,10 @@ local function recovery()
os.reboot() os.reboot()
elseif k == 5 then elseif k == 5 then
break break
elseif k == 6 then
recoverym = {}
recoverym.safemode = true
break
end end
end end
end end
@ -133,6 +138,16 @@ local function kernel()
f.close() f.close()
end end
if not fs.exists("/.sPhone/apis") then
fs.makeDir("/.sPhone/apis")
end
for k, v in pairs(fs.list("/.sPhone/apis")) do
if not fs.isDir("/.sPhone/apis/"..v) then
os.loadAPI("/.sPhone/apis/"..v)
end
end
if not fs.exists("/.sPhone/autorun") then if not fs.exists("/.sPhone/autorun") then
fs.makeDir("/.sPhone/autorun") fs.makeDir("/.sPhone/autorun")
end end
@ -140,10 +155,10 @@ local function kernel()
term.setBackgroundColor(colors.white) term.setBackgroundColor(colors.white)
term.clear() term.clear()
term.setCursorPos(1,1) term.setCursorPos(1,1)
for k, v in pairs(fs.list("/.sPhone/autorun")) do for k, v in pairs(fs.list("/.sPhone/autorun")) do
term.setTextColor(colors.black) term.setTextColor(colors.black)
if not fs.isDir("/.sPhone/autorun/"..v) then if not fs.isDir("/.sPhone/autorun/"..v) then
if not recoverym.safemode then
local f = fs.open("/.sPhone/autorun/"..v,"r") local f = fs.open("/.sPhone/autorun/"..v,"r")
local script = f.readAll() local script = f.readAll()
f.close() f.close()
@ -158,8 +173,10 @@ local function kernel()
print(v.." disabled to prevent errors") print(v.." disabled to prevent errors")
sleep(0.5) sleep(0.5)
end end
else
print("Script "..v.." not loaded because Safe Mode")
sleep(0)
end
end end
end end
@ -173,16 +190,6 @@ local function kernel()
u.close() u.close()
end end
if not fs.exists("/.sPhone/apis") then
fs.makeDir("/.sPhone/apis")
end
for k, v in pairs(fs.list("/.sPhone/apis")) do
if not fs.isDir("/.sPhone/apis/"..v) then
os.loadAPI("/.sPhone/apis/"..v)
end
end
if not fs.exists("/.sPhone/config/sPhone") then if not fs.exists("/.sPhone/config/sPhone") then
config.write("/.sPhone/config/sPhone","devMode",false) config.write("/.sPhone/config/sPhone","devMode",false)
end end