Im getting a really weird error, the reason I say that is the fact that im not using mulitshell exclusively (I know it runs automatically but im not using its features) and ive ever seen it before
So bascially when I reboot the computer or shutdown the computer, It more often than not throws the errors below. It only happens when running certain code
Here is a screen shot of the error when holding CTRL+R:
[How do I upload images, Ive seen people with many on their topics and I can only upload two on the entire SITE!]
Imgur Link: http://imgur.com/kEORhaF,gG7LzRj#0
and here is the error when holding CTRL+S:
Imgur Link: http://imgur.com/kEORhaF,gG7LzRj#1
Code Running When Crash Happens: (If I discover any others doing the same I will post them too)
Spoiler
runningProgram = shell.getRunningProgram()
LogFile.i('OpenPDetect Program Successfully Started', runningProgram)
current = {
sensor = {},
settings = {
whiteList = {}
}
}
Events ={}
current.config = false
termX, termY = term.getSize()
function drawTitle()
term.clear()
titleBar.draw('HbombOS Security Suite', 'OpenP Detector Lock', colors.cyan, 256, 128, 256, 1)
end
function setup()
LogFile.i('OpenPDetect Setup Started', runningProgram)
local function setupWelcome()
titleBar.draw('HbombOS Security Suite', 'OpenP Detector Lock Setup', colors.cyan, 256, 128, 256, 1)
end
local function Intro()
LogFile.i('OpenPDetect Setup Intro', runningProgram)
setupWelcome()
printer.centered('Welcome To OpenP Detector Setup', 6)
printer.centered('This Program Uses Open Peripherals', 8)
printer.centered('Sensor Block', 9)
printer.centered('Therefore To Use This Program You Need', 11)
printer.centered('Open Peripheral Addons Installed', 12)
printer.centered('Click Anywhere On Screen To Start Setup', 19)
os.pullEvent('mouse_click')
end
local function setupStart()
setupWelcome()
printer.centered('Welcome To The Detector Setup')
printer.centered('Click Anywhere To Begin Setup')
os.pullEvent('mouse_click')
end
local function whitelistAdd()
LogFile.i('OpenPDetect whitelist Add Start', runningProgram)
while true do
local function addNames()
while true do
inList = false
setupWelcome()
printer.centered('Enter The Names You Would Like To', 6)
printer.centered('Add To The Detector WhiteList', 7)
printer.centered('These Are The Players Who Will Have Access', 9)
printer.centered('Enter The Username, And Hit Enter To Add', 10)
printer.centered('Then Press [alt] To Continue To The Next Step',19)
term.setCursorPos(termX/2-#'Username: ', 13)
write('Username: ')
local input = read()
if input and input ~= "" then
for _, entry in ipairs(current.settings.whiteList) do
if entry == input then
inList = true
printer.centered('Username Already In Whitelist', 19)
LogFile.w('User Tried To Add Username To Whitelist That Already Existed', runningProgram)
sleep(1)
end
end
if inList == false then
printer.centered('Adding Username To whitelist', 19)
LogFile.i('Adding Username: '..input..' Into Whitelist', runningProgram)
if current.settings.whiteList then
table.insert(current.settings.whiteList, input)
printer.centered('Username Inserted Into Whitelist', 19)
sleep(0.5)
else
LogFile.e('Whitelist Table Is Missing.. Fatal', runningProgram)
error'Table Appears To Be Missing'
end
end
end
end
end
local function nextStep()
while true do
local event, key = os.pullEvent('key')
if key == keys.leftAlt or key == keys.rightAlt then
if #current.settings.whiteList <= 0 then
term.setCursorBlink(false)
printer.centered('Please Register At Least ONE Username', 19)
LogFile.w('User Tried To Skip Whitelist When 0 Usernames Are In Table', runningProgram)
sleep(0.5)
lessThanOne = true
return
else
lessThanOne = false
return key
end
end
end
end
parallel.waitForAny(nextStep, addNames)
if not lessThanOne then LogFile.i('Whitelist Complete', runningProgram) break end
end
return
end
local function ouputOption()
term.setCursorBlink(false)
setupWelcome()
printer.centered('Do You Want The Computer To Ouput', 6)
printer.centered('A Redstone Signal When The Players Is', 7)
printer.centered('On The Whitelist', 8)
printer.centered('Y/N', 10)
printer.centered('You Pick What Side It Outputs From Next Step', 19)
while true do
local event, key = os.pullEvent('key')
if key == keys.y then
current.settings.outputOption = true
LogFile.i('Output Option: true', runningProgram)
return true
elseif key == keys.n then
current.settings.outputOption = false
LogFile.i('Output Option: false', runningProgram)
return false
end
end
end
local function outputSide()
while true do
sleep(0)
setupWelcome()
printer.centered("Redstone Output Side", 6)
term.setCursorPos(termX/2-#'Output Side: ',10)
write ('Output Side: ')
local vside = false
current.settings.redstoneSide = read()
for k,v in pairs(rs.getSides()) do
if v == current.settings.redstoneSide then
vside = true
break
end
end
if vside then LogFile.i('Redstone Side Set To: '..current.settings.redstoneSide, runningProgram) break end
printer.centered("Invalid side!", 11)
sleep(0.5)
term.clear()
end
return
end
local function alarmOption()
term.setCursorBlink(false)
setupWelcome()
printer.centered('Do You Want The Computer To Ouput', 6)
printer.centered('A Redstone Signal When The Players Is', 7)
printer.centered('NOT On The Whitelist', 8)
printer.centered('Y/N', 10)
printer.centered('You Pick What Side It Outputs From Next Step', 19)
while true do
local event, key = os.pullEvent('key')
if key == keys.y then
current.settings.alarmOption = true
LogFile.i('Alarm Side Option: true', runningProgram)
return true
elseif key == keys.n then
current.settings.alarmOption = false
LogFile.i('Alarm Side Option: false', runningProgram)
return false
end
end
end
local function alarmOutput()
while true do
sleep(0)
setupWelcome()
printer.centered("Alarm Redstone Output Side", 6)
term.setCursorPos(termX/2-(#'Alarm Side: '),10)
write ('Alarm Side: ')
local vside = false
current.settings.alarmRedstoneSide = read()
for k,v in pairs(rs.getSides()) do
if v == current.settings.alarmRedstoneSide then
vside = true
break
end
end
if vside then LogFile.i('Alarm Side: '..current.settings.alarmRedstoneSide, runningProgram) break end
printer.centered("Invalid side!", 11)
sleep(0.5)
term.clear()
end
return
end
local function setupSave()
LogFile.i('Setup Complete', runningProgram)
setupWelcome()
printer.centered('Thanks For Completing Setup', 6)
printer.centered('Please Wait While Your Preferences', 8)
printer.centered('Are Saved To File', 9)
printer.centered('Saving Settings', 19)
SaveSettings()
printer.centered('Settings Saved, Click To Continue', 19)
os.pullEvent('mouse_click')
loadSettings()
current.config = false
end
Intro()
whitelistAdd()
if ouputOption() == true then outputSide() end
if alarmOption() == true then alarmOutput() end
setupSave()
term.clear()
drawTitle()
scanSensor()
eventLoop()
end
function loadSettings()
LogFile.i('Loading Settings', runningProgram)
if fs.exists('systemFiles/Programs/detectorConfig') then
local f = fs.open('systemFiles/Programs/detectorConfig', 'r')
if f then
current.settings = textutils.unserialize(f.readAll())
end
f.close()
else
setup()
end
end
function SaveSettings()
LogFile.i('Saving Settings', runningProgram)
current.settings = current.settings or {}
local f = fs.open('systemFiles/Programs/detectorConfig', 'w')
if f then
f.write(textutils.serialize(current.settings))
end
f.close()
end
--Sensor Peripheral: openperipheral_sensor
function scanSensor()
LogFile.i('Searching For OpenP Scanner', runningProgram)
localPeripherals = peripheral.getNames()
for i = 1, #localPeripherals do
if peripheral.getType(localPeripherals[i]) == 'openperipheral_sensor' then
Sensor = peripheral.find('openperipheral_sensor')
LogFile.i('Sensor Found', runningProgram)
current.sensor.isPresent = true
return true
end
end
LogFile.w('Sensor Missing', runningProgram)
current.sensor.isPresent = false
noSensor()
end
function noSensor()
LogFile.w('There Is No Sensor Present', runningProgram)
drawTitle()
if current.settings.redstoneSide then rs.setOutput(current.settings.redstoneSide, false) end
if current.settings.alarmRedstoneSide then rs.setOutput(current.settings.alarmRedstoneSide, false) end
printer.centered('It Seems There Is No OpenPeripheral Sensor', 6)
printer.centered('Attached To This Computer', 7)
printer.centered('Please Attach One', 8)
printer.centered('Well Look Automatically When You Attach One', 10)
printer.centered('Attach A Sensor To Continue', 19)
while true do
local event = os.pullEvent()
if event == 'peripheral' or event == 'peripheral_detach' then
printer.centered('Scanning For Sensor', 19)
sleep(2)
scanSensor()
drawTitle()
closeAllSides()
checkScanner()
break
end
end
end
function checkScanner()
allowPlayer = false
denyPlayer = false
nearbyPlayers = Sensor.getPlayerNames()
if nearbyPlayers then
for _, entry in ipairs(nearbyPlayers) do
for _, v in ipairs (current.settings.whiteList) do
if entry == v then
openSide()
allowPlayer = true
else
if not allowPlayer then
openAlarmSide()
denyPlayer = true
end
end
end
end
end
scanPlayers = os.startTimer(0.1)
if denyPlayer or allowPlayer then return true else return false end
end
function eventRegister(event, functionToRun)
if not Events[event] then
Events[event] = {}
end
table.insert(Events[event], functionToRun)
end
function drawScreen()
if current.status == 'System Ready' then term.setTextColor(colors.blue)
elseif current.status == 'Access Granted' then term.setTextColor(colors.lime)
elseif current.status == 'Access Denied' then term.setTextColor(colors.red) end
printer.centered(current.status, 8)
term.setTextColor(256)
term.setBackgroundColor(128)
term.setCursorPos(termX-#'[alt] Setup', 1)
write('[alt] Setup')
term.setTextColor(1)
term.setBackgroundColor(256)
printer.centered('System Monitoring Nearby Entities', 19)
printer.centered('Detector System', 6)
end
function eventLoop()
drawTitle()
current.status = 'System Ready'
allowPlayer = false
scanSensor()
checkScanner()
while true do
drawScreen()
local event, arg1, arg2, arg3, arg4, arg5, arg6 = os.pullEventRaw()
if Events[event] then
for i, e in ipairs(Events[event]) do
e(event, arg1, arg2, arg3, arg4, arg5, arg6)
end
end
end
end
function openSide()
current.status = 'Access Granted'
if current.settings.redstoneSide then rs.setOutput(current.settings.redstoneSide, true) end
end
function openAlarmSide()
current.status = 'Access Denied'
if current.settings.alarmRedstoneSide then rs.setOutput(current.settings.alarmRedstoneSide, true) end
end
function closeAllSides()
if not checkScanner() then
allowPlayer = false
denyPlayer = false
current.status = 'System Ready'
if current.settings.redstoneSide then rs.setOutput(current.settings.redstoneSide, false) end
if current.settings.alarmRedstoneSide then rs.setOutput(current.settings.alarmRedstoneSide, false) end
end
end
function timerHandle(event, timer)
if timer == closeSide then
closeAllSides()
elseif timer == scanPlayers then
closeAllSides()
checkScanner()
end
end
function whitelistAdd()
LogFile.i('Whitelist Add Called', runningProgram)
while true do
local function addNames()
while true do
titleBar.draw('HbombOS Security Suite', 'OpenP Detector Settings', colors.cyan, 256, 128, 256, 1)
inList = false
printer.centered('Enter The Names You Would Like To', 6)
printer.centered('The Detector WhiteList', 7)
printer.centered('These Are The Players Who Will Have Access', 9)
printer.centered('Enter The Username, And Hit Enter To Add', 10)
printer.centered('Then Press [alt] To Save And Return',19)
term.setCursorPos(termX/2-#'Username: ', 13)
write('Username: ')
local input = read()
if input and input ~= "" then
for _, entry in ipairs(current.settings.whiteList) do
if entry == input then
inList = true
printer.centered('Username Already In Whitelist', 19)
LogFile.w('Username: '..input..' Already In Whitelist', runningProgram)
sleep(1)
end
end
if inList == false then
printer.centered('Adding Username To whitelist', 19)
LogFile.i('Adding: '..input.. 'Into Whitelist', runningProgram)
if current.settings.whiteList then
table.insert(current.settings.whiteList, input)
printer.centered('Username Inserted Into Whitelist', 19)
sleep(0.5)
else
LogFile.i('Whitelist Table Missing!', runningProgram)
error'Table Appears To Be Missing'
end
end
end
end
end
local function nextStep()
while true do
local event, key = os.pullEvent('key')
if key == keys.leftAlt or key == keys.rightAlt then
if #current.settings.whiteList <= 0 then
term.setCursorBlink(false)
printer.centered('Please Register At Least ONE Username', 19)
LogFile.i('User Tried To Add 0 Usernames', runningProgram)
sleep(0.5)
lessThanOne = true
return
else
lessThanOne = false
return key
end
end
end
end
parallel.waitForAny(nextStep, addNames)
if not lessThanOne then break end
end
SaveSettings()
configMenu()
end
function whitelistRemove()
LogFile.i('Remove Whitelist Username Open', runningProgram)
local function removeNames()
while true do
inList = false
titleBar.draw('HbombOS Security Suite', 'OpenP Detector Lock Settings', colors.cyan, 256, 128, 256, 1)
printer.centered('Enter The Names You Would Like To', 6)
printer.centered('Remove From The Detector WhiteList', 7)
printer.centered('These Are The Players Who Will Not Have Access', 9)
printer.centered('Enter The Username, And Hit Enter To Remove', 10)
printer.centered('Then Press [alt] To Save And Return',19)
term.setCursorPos(termX/2-#'Username: ', 13)
write('Username: ')
local input = read()
if input and input ~= "" then
for _, entry in ipairs(current.settings.whiteList) do
if entry == input then
if #current.settings.whiteList - 1 >0 then
printer.centered('Removing Username From whitelist', 19)
table.remove(current.settings.whiteList, _)
SaveSettings()
printer.centered('Removed Username From Whitelist', 19)
sleep(0.5)
break
else
LogFile.i('User Tried To Remove LAST Username From Whitelist', runningProgram)
printer.centered('There Has To Be Atleast One Username', 18)
printer.centered('In Whitelist', 19)
sleep(1)
end
end
end
end
end
end
local function completeStage()
while true do
local event, key = os.pullEvent('key')
if key == keys.leftAlt or key == keys.rightAlt then
return key
end
end
end
parallel.waitForAny(completeStage, removeNames)
SaveSettings()
configMenu()
end
function configMenu()
LogFile.i('Config Menu Open', runningProgram)
term.setCursorBlink(false)
titleBar.draw('HbombOS Security Suite', 'OpenP Detector Settings', colors.cyan, 256, 128, 256, 1)
printer.centered('Pick An Option Below', 6)
local continue = false
current.config = true
local options = {
{'Edit Settings', function()
setup()
end},
{'Whitelist Users', function()
whitelistAdd()
end},
{'Un-Whitelist Users', function()
whitelistRemove()
end},
{'Reset Configuration', function()
LogFile.i('Config Reset', runningProgram)
fs.delete('systemFiles/Programs/detectorConfig')
os.reboot()
end},
{'Cancel And Return', function()
current.config = false
eventLoop()
end}
}
local selected = 1
local function draw()
for i, v in ipairs(options) do
local bg = 256
local tc = colours.white
if i == selected then
bg = 256
tc = colours.blue
end
term.setTextColor(tc)
term.setBackgroundColor(bg)
PrintCentered(' '..v[1]..' ', math.floor(#options/2) + i + 6)
end
end
local wait = true
draw()
while true do
local event, key = os.pullEvent('key')
if key == keys.up then
selected = selected - 1
if selected < 1 then
selected = 1
end
elseif key == keys.down then
selected = selected + 1
if selected > #options then
selected = #options
end
elseif key == keys.enter then
options[selected][2]()
wait = false
break
end
draw()
end
end
function ConfigLogin()
LogFile.i('Config Login', runningProgram)
closeAllSides()
current.config = true
local f = fs.open('systemFiles/Security/adminPass', 'r')
adminPassLoaded = f.readLine()
f.close()
titleBar.draw('HbombOS Security Suite', 'OpenP Detector Settings', colors.cyan, 256, 128, 256, 1)
printer.centered('Please Enter Your Admin Password', 4)
printer.centered('Linked To Your Security Suite To Access', 5)
printer.centered('The Settings Menu', 6)
printer.centered('Press [alt] To Return', 19)
local function LoginInput()
while true do
term.setCursorPos(termX/2-#'Password: ', 10)
term.clearLine()
write('Password: ')
local input = read('*')
if input == adminPassLoaded then
LogFile.i('Admin Password Correct', runningProgram)
current.config = true
break
end
end
end
local function keyExit()
while true do
local event, key = os.pullEvent('key')
if key == keys.leftAlt or keys == keys.rightAlt then
term.setCursorBlink(false)
current.config = false
break
end
end
end
parallel.waitForAny(LoginInput, keyExit)
if current.config then configMenu() else eventLoop() end
end
function keyHandler(event, key)
if event == 'key' and key == keys.leftAlt or key == keys.rightAlt then
if current.config == false then ConfigLogin() end
end
end
function init()
LogFile.i('main Init function started', runningProgram)
eventRegister('timer', timerHandle)
eventRegister('key', keyHandler)
eventRegister('terminate', function(event) errora.err('Termination Detected', 'You Attempted To Terminate The Program', true) end)
eventRegister('peripheral', scanSensor)
eventRegister('peripheral_detach', scanSensor)
loadSettings()
eventLoop()
end
local _, err = pcall(init) --Error Catching, All Functions Are Called From initialise() at some point...
if err then
term.setCursorBlink(false)
LogFile.e('Error Detected: '..err, runningProgram)
errora.err(err, 'Detector Lock Crashed, Report Error Above', true) --BSoD for protection, the 'true' is an auto-reboot option to prevent the door waiting for a prompt
end
The LogFile.blahblah want there when I discovered this although I never experienced the CTRL+S version without them, although I dont remeber testing
The file that starts this one is here:
Spoiler
-- This script loads the APIs Required as well as checks for missing files and updates via GitHub
-- The Installer Will Check If The Computer is compatible
runningProgram = shell.getRunningProgram()
os.pullEvent = os.pullEventRaw
termX, termY = term.getSize()
os.loadAPI('api/LogFile')
-- Fade In!
LogFile.Initialise()
LogFile.i('Loading Boot Screen', runningProgram)
LogFile.i('Fading Screen', runningProgram)
term.setBackgroundColour(colours.black)
term.clear()
sleep(0.1)
term.setBackgroundColour(colours.grey)
term.clear()
sleep(0.1)
term.setBackgroundColour(colours.lightGrey)
term.clear()
sleep(0.1)
function RecieveStartupKey()
while true do
local event, arg = os.pullEvent()
if event == 'BootDone' then
return nil
elseif event == "key" then
if arg == keys.leftAlt or key == keys.rightAlt then
bootKey = true
checkStartKey()
return arg
end
end
end
end
function checkStartKey()
term.setBackgroundColor(128)
term.setTextColor(256)
if bootKey then
Boottext = "Entering Setup"
else
Boottext = "[alt] Setup"
end
term.setCursorPos(termX-(#Boottext+1), 1)
write(Boottext)
term.setBackgroundColor(256)
term.setTextColor(1)
end
function initBackground(color) --Use To Quickly assemble GUI
term.setBackgroundColor(color)
term.clear()
drawTitleBar()
end
function start()
printer.centered("Password Changer", 4)
printer.centered("Here you may change your admin password", 6)
printer.centered("In just a few simple clicks and hits...", 7)
end
function newPassword2()
while newPassword2Wait do
term.clear()
start()
printer.centered("Re-type your new password", 10)
local newPassConfirm = "New Pass Again: "
term.setCursorPos(termX/2-#newPassConfirm, 12)
write (newPassConfirm)
newPass = read("*")
if newPass == newPass1 then break else printer.centered("Passwords Don't Match!", 19) sleep(0.6) newPassword() end
end
save(newPass)
end
function newPassword()
while newPassWait do
term.clear()
start()
printer.centered("Type your new password", 10)
local newPassText = "New Pass: "
term.setCursorPos(termX/2-#newPassText, 12)
write (newPassText)
newPass1 = read("*")
if newPass1 == "" or newPass1 == nil then
printer.centered("Cannot Be NIL!", 19)
elseif newPass1 ~= "" or newPass ~= nil then
printer.centered("Accepted", 19)
newPassword2()
else
errora.err("generic", "Unknown Exception, Cannot Handle Input: "..newPass1)
end
end
end
function oldPassword()
while oldPassWait do
printer.centered("Type your current password to get started", 10)
local oldPassText = "Current Pass: "
term.setCursorPos(termX/2-#oldPassText, 12)
write(oldPassText)
oldPass = read("*")
if oldPass == adminPassword then oldPassWait = false break end
end
newPassword()
end
function save(password)
if password then
printer.centered("Saving!", 18)
sleep(0)
printer.centered("Opening File Handler", 19)
sleep(0)
local f = fs.open('systemFiles/Security/adminPass', "w")
printer.centered("Preparing Write", 19)
sleep(0)
printer.centered("Writing To File", 19)
sleep(0)
f.writeLine(password)
printer.centered("File Data Written", 19)
sleep(0)
printer.centered("Closing File Handler", 19)
sleep(0)
f.close()
printer.centered("Data Saved", 19)
sleep(0)
printer.centered("Done... Rebooting", 19)
sleep(2)
os.reboot()
else
errora.err("generic", "Save Data invalid / NIL")
end
end
bootX = termX/2-7
bootY = termY/2-4
-- Loads All Boot Images
LogFile.i('Loading Boot Images', runningProgram)
BL0 = paintutils.loadImage("systemFiles/BootLogos/boot0.nfp")
BL1 = paintutils.loadImage("systemFiles/BootLogos/boot1.nfp")
BL2 = paintutils.loadImage("systemFiles/BootLogos/boot2.nfp")
BL3 = paintutils.loadImage("systemFiles/BootLogos/boot3.nfp")
BL4 = paintutils.loadImage("systemFiles/BootLogos/boot4.nfp")
BL5 = paintutils.loadImage("systemFiles/BootLogos/boot5.nfp")
BL6 = paintutils.loadImage("systemFiles/BootLogos/boot6.nfp")
BL7 = paintutils.loadImage("systemFiles/BootLogos/boot7.nfp")
BL8 = paintutils.loadImage("systemFiles/BootLogos/boot8.nfp")
BLFinal = paintutils.loadImage('systemFiles/bootFail.nfp')
function bootLogo (state, x, y, bgcolor)
if state == 0 then
paintutils.drawImage(BL0, x, y)
elseif state == 1 then
paintutils.drawImage(BL1, x, y)
elseif state == 2 then
paintutils.drawImage(BL2, x, y)
elseif state == 3 then
paintutils.drawImage(BL3, x, y)
elseif state == 4 then
paintutils.drawImage(BL4, x, y)
elseif state == 5 then
paintutils.drawImage(BL5, x, y)
elseif state == 6 then
paintutils.drawImage(BL6, x, y)
elseif state == 7 then
paintutils.drawImage(BL7, x, y)
elseif state == 8 then
paintutils.drawImage(BL8, x, y)
elseif state == 9 then
paintutils.drawImage(BLFinal, x, y)
end
term.setBackgroundColor(bgcolor)
end
function PrintCentered(text, y)
local w, h = term.getSize()
x = math.ceil(math.ceil((w / 2) - (#text / 2)), 0)+1
term.setCursorPos(x, y)
term.clearLine()
write(text)
end
if not fs.exists("systemFiles/Security/adminPass") then
LogFile.i('Admin Password Set Open', runningProgram)
while true do
PrintCentered("SECURITY VULNERABLITLTY NOTICE", 4)
PrintCentered("The Administrator Password Has Not Been Set", 6)
PrintCentered("Please Set It Below, You Can Change It", 7)
PrintCentered("Whilst Booting If You Press [ALT]", 8)
adminPassText = "Password: "
term.setCursorPos(termX/2-(#adminPassText), 10)
write(adminPassText)
adminPassIn = read("*")
if adminPassIn ~= "" then
LogFile.i('Admin Password Creation Complete', runningProgram)
PrintCentered("Saving Password...", 19)
sleep(0)
PrintCentered("Opening File Handle", 19)
local f = fs.open("systemFiles/Security/adminPass", "w")
PrintCentered("File Handle Open", 19)
PrintCentered("Writing To File", 19)
f.writeLine(adminPassIn)
PrintCentered("Complete", 19)
break
end
end
if fs.exists('systemFiles/Install/updateConfig') then
LogFile.i('Update Config Already Exists! Rebooting', runningProgram)
os.reboot()
end
else --The Files Exists
local file = fs.open("systemFiles/Security/adminPass", "r")
adminPassword = file.readLine()
file.close()
end
function saveUpdate()
local f = fs.open('systemFiles/Install/updateConfig', 'w')
f.writeLine(tostring(quietUse))
f.close()
sleep(0)
PrintCentered("Settings Saved, Setting set to: "..tostring(quietUse), 19)
sleep(1)
os.reboot()
end
if not fs.exists('systemFiles/Install/updateConfig') then
LogFile.i('Updater Selection Set Open', runningProgram)
term.clear()
PrintCentered("Updater Mode Selection", 4)
PrintCentered("Would you like the enable quiet updating", 6)
PrintCentered("which will prevent the updater asking you for", 7)
PrintCentered("your decision on whether you would like to update", 8)
PrintCentered("Instead, it will do it automatically!", 9)
PrintCentered("Press Y to enable or N to disable this setting", 11)
updateLoop = true
while updateLoop do
event, press = os.pullEvent("key")
if press == keys.y then
quietUse = true
saveUpdate()
elseif press == keys.n then
quietUse = false
saveUpdate()
end
end
end
function loadAPIs() --Auto Loads ALL APIs It Can As Long As They Are In /api
drawTitleBar()
local currentImage = -1
local total = #fs.list("/api")
term.setBackgroundColor(256)
PrintCentered("Loading APIs", 17)
for _, fileApi in pairs(fs.list('/api')) do
if string.sub(fileApi,1,1) ~= "." then
if math.floor(_*(8/total)) ~= currentImage then
currentImage = math.floor(_*(8/total))
local image = paintutils.loadImage('systemFiles/BootLogos/boot'..currentImage..'.nfp')
paintutils.drawImage(image, bootX, bootY)
end
LogFile.i('Loading: '..fileApi, runningProgram)
if os.loadAPI('/api/'..fileApi) then
sleep(0)
term.setBackgroundColor(256)
term.setTextColor(colors.white)
term.setCursorPos(1,19)
term.clearLine()
term.setCursorPos(1,18)
term.clearLine()
PrintCentered(fileApi.." Loaded!", 18)
LogFile.i(fileApi..'Api Loaded', runningProgram)
else
LogFile.e('Failed To Load API: '..fileApi, runningProgram)
error ("Error Occurred Whilst Loading API: "..fileApi)
end
end
end
sleep(0.1)
term.clear()
initBackground(256)
drawTitleBar()
return true
end
function drawTitleBar()
LogFile.i('Drew Title Bar', runningProgram)
term.setBackgroundColor(128)
term.setCursorPos(1,1)
term.clearLine()
term.setTextColor(colors.cyan)
write "HbombOS Security Suite"
term.setCursorPos(1,2)
term.clearLine()
term.setTextColor(256)
write "Startup"
checkStartKey()
end
function programMenu()
LogFile.i('Program Selection Menu Open', runningProgram)
drawTitleBar()
term.setTextColor(1)
term.setBackgroundColor(256)
term.clear()
PrintCentered("HbombOS Security Suite", 2)
PrintCentered("Programs", 3)
PrintCentered("The Suite Offers Several Programs For You To Use", 5)
PrintCentered("Select One You Would Like To Use", 6)
PrintCentered("You Can Change It At Any Time Using The BootMenu", 7)
PrintCentered("Use Your Arrow Keys To Select, Enter To Confirm", 19)
local continue = false
local options = {
{'PIN', function()
term.setTextColor(1)
printer.centered("Opening File Handler", 19)
sleep(0)
local f = fs.open('systemFiles/Programs/configuration', "w")
printer.centered("File Handler Open", 19)
sleep(0)
printer.centered("Writing To File", 19)
sleep(0)
f.writeLine('systemFiles/Programs/pin')
printer.centered("File written", 19)
sleep(0)
LogFile.i('Program: PIN Selected', runningProgram)
printer.centered("Closing Handler", 19)
f.close()
printer.centered("Saved, Rebooting!", 19)
sleep(2)
os.reboot()
end},
{'Digital Lock', function()
term.setTextColor(1)
printer.centered("Opening File Handler", 19)
sleep(0)
local f = fs.open('systemFiles/Programs/configuration', "w")
printer.centered("File Handler Open", 19)
sleep(0)
printer.centered("Writing To File", 19)
sleep(0)
f.writeLine('systemFiles/Programs/dualKey')
printer.centered("File written", 19)
sleep(0)
LogFile.i('Program: DualKey Selected', runningProgram)
printer.centered("Closing Handler", 19)
f.close()
printer.centered("Saved, Rebooting!", 19)
sleep(2)
os.reboot()
end},
{'Reactor Control', function()
term.setTextColor(1)
printer.centered("Opening File Handler", 19)
sleep(0)
local f = fs.open('systemFiles/Programs/configuration', "w")
printer.centered("File Handler Open", 19)
sleep(0)
printer.centered("Writing To File", 19)
sleep(0)
f.writeLine('systemFiles/Programs/reactor')
printer.centered("File written", 19)
sleep(0)
LogFile.i('Program: reactor Selected', runningProgram)
printer.centered("Closing Handler", 19)
f.close()
printer.centered("Saved, Rebooting!", 19)
sleep(2)
os.reboot()
end},
{'Keycard Lock', function()
term.setTextColor(1)
printer.centered("Opening File Handler", 19)
sleep(0)
local f = fs.open('systemFiles/Programs/configuration', "w")
printer.centered("File Handler Open", 19)
sleep(0)
printer.centered("Writing To File", 19)
sleep(0)
f.writeLine('systemFiles/Programs/keycard')
printer.centered("File written", 19)
sleep(0)
LogFile.i('Program" keycard Selected', runningProgram)
printer.centered("Closing Handler", 19)
f.close()
printer.centered("Saved, Rebooting!", 19)
sleep(2)
os.reboot()
end},
{'PDA Range Lock', function()
term.setTextColor(1)
printer.centered("Opening File Handler", 19)
sleep(0)
local f = fs.open('systemFiles/Programs/configuration', "w")
printer.centered("File Handler Open", 19)
sleep(0)
printer.centered("Writing To File", 19)
sleep(0)
f.writeLine('systemFiles/Programs/rangeLock')
printer.centered("File written", 19)
sleep(0)
LogFile.i('Program: rangeLock Selected', runningProgram)
printer.centered("Closing Handler", 19)
f.close()
printer.centered("Saved, Rebooting!", 19)
sleep(2)
os.reboot()
end},
{'Dual KeyCard Lock', function()
term.setTextColor(1)
printer.centered("Opening File Handler", 19)
sleep(0)
local f = fs.open('systemFiles/Programs/configuration', "w")
printer.centered("File Handler Open", 19)
sleep(0)
printer.centered("Writing To File", 19)
sleep(0)
f.writeLine('systemFiles/Programs/keycardDual')
printer.centered("File written", 19)
sleep(0)
LogFile.i('Program: keycardDual Selected', runningProgram)
printer.centered("Closing Handler", 19)
f.close()
printer.centered("Saved, Rebooting!", 19)
sleep(2)
os.reboot()
end},
{'OpenP Detector Lock', function()
term.setTextColor(1)
printer.centered("Opening File Handler", 19)
sleep(0)
local f = fs.open('systemFiles/Programs/configuration', "w")
printer.centered("File Handler Open", 19)
sleep(0)
printer.centered("Writing To File", 19)
sleep(0)
f.writeLine('systemFiles/Programs/OpenPDetect')
printer.centered("File written", 19)
sleep(0)
LogFile.i('Program: OpenPDetect Selected', runningProgram)
printer.centered("Closing Handler", 19)
f.close()
printer.centered("Saved, Rebooting!", 19)
sleep(2)
os.reboot()
end}
}
local selected = 1
local function draw()
for i, v in ipairs(options) do
local bg = 256
local tc = colours.white
if i == selected then
bg = 256
tc = colours.blue
end
term.setTextColor(tc)
term.setBackgroundColor(bg)
PrintCentered(' '..v[1]..' ', math.floor(#options/2) + i + 6)
end
end
local wait = true
draw()
while wait do
local event, key = os.pullEvent('key')
if key == keys.up then
selected = selected - 1
if selected < 1 then
selected = 1
end
elseif key == keys.down then
selected = selected + 1
if selected > #options then
selected = #options
end
elseif key == keys.enter then
options[selected][2]()
wait = false
end
draw()
end
return continue
end
function programCheckConfig()
LogFile.i('Checking Program Config', runningProgram)
if not fs.exists('systemFiles/Programs/configuration') then programMenu() else
local f = fs.open('systemFiles/Programs/configuration', "r")
programStart = f.readLine()
f.close()
if not programStart then programMenu() else
if programStart == "" then programMenu() else
local f = fs.open('systemFiles/Programs/configuration', 'r')
fileStartup = f.readLine()
f.close()
end
end
end
end
function main() --The main function, calls all child functions
--First all APIs must be loaded to perform the system checks later on
LogFile.i('Main Initialise Function Started', runningProgram)
i = 0
loadAPIs()
programCheckConfig()
term.setBackgroundColor(256)
term.setTextColor(1)
bootLogo(1, bootX, bootY, 256)
PrintCentered("Checking For Colour Support", 18)
if systemCheck.checkColor() then PrintCentered("Computer Supports Colour", 19) end
bootLogo(3, bootX, bootY, 256)
sleep(0)
bootLogo(4, bootX, bootY, 256)
PrintCentered("Checking If Pocket", 18)
sleep(0)
if systemCheck.checkPocket() then
bootLogo(6, bootX, bootY, 256)
PrintCentered("Computer Is Not Pocket", 19)
end
sleep(0)
bootLogo(7, bootX, bootY, 256)
PrintCentered("Checking If Supports HTTP", 18)
sleep(0)
bootLogo(8, bootX, bootY, 256)
if systemCheck.checkhttp() then PrintCentered("System Check Complete!", 19) end
sleep(0)
PrintCentered("", 19)
updateChecker()
return true
end
function latestVer()
PrintCentered("You Are Running The Latest STABLE Version!", 19)
printer.centered("Reading Config File..", 19)
sleep(0.1)
return true
end
function updateAvail()
PrintCentered("An Update Has Been Detected", 6)
sleep(0)
PrintCentered("Obtaining Latest Update From GitHub", 18)
PrintCentered("Seeking URL", 19)
sleep(0)
PrintCentered("Parsed", 19)
sleep(0)
PrintCentered("Downloading New Updater", 19)
if not download.git("https://raw.githubusercontent.com/hbomb79/securitySystemPro/master/systemFiles/Install/updater", "systemFiles/Install/updater") then printer.centered('Error Occured While Downloading Updater!', 19) sleep(1) os.reboot() end
PrintCentered("Download Complete, Running Updater",18)
local f = fs.open('systemFiles/Install/updateConfig', 'r')
useSettingQuiet = f.readLine()
f.close()
if useSettingQuiet == "true" then shell.run("systemFiles/Install/updater", "quiet") elseif useSettingQuiet == "false" then shell.run("systemFiles/Install/updater") else errora.err(nil, "The Updater Launch Script Failed To Launch the Updater, Returned: "..tostring(useSettingQuiet)) end
if request_code == 'Cancelled' then
return 'Cancel'
elseif request_code == 'Error' then
i = i + 1
if i < 4 then
term.setBackgroundColor(256)
term.clear()
drawTitleBar()
printer.centered('The Updater Is Experiencing Issues', 6)
printer.centered('Please Ensure You Are Connected To The Internet', 8)
printer.centered('If You Have An Active Internet Connection', 10)
printer.centered('Then Report On Forum Page', 11)
printer.centered('Retry Attempt: '..i, 19)
sleep(3)
else
term.setBackgroundColor(256)
term.clear()
drawTitleBar()
printer.centered('The Updater Isnt Able To Connect', 6)
printer.centered('Due To Retrying 3 Times, The System Has', 8)
printer.centered('Decided To Skip The Update...', 10)
printer.centered('Please Connect To Internet', 11)
for x = 3, 1, -1 do
if x == 1 then
printer.centered('Skipping In: '..x..' Second', 19)
elseif x > 1 then
printer.centered('Skipping In: '..x..'Seconds', 19)
else break end
sleep(1)
end
return 'Cancel'
end
return 'Error'
end
end
function updateChecker()
LogFile.i('Checking For Updates', runningProgram)
while true do
term.setBackgroundColor(256)
term.clear()
drawTitleBar()
printer.centered('Checking For Software Updates', 6)
printer.centered('Please Wait...', 19)
updateState = update.Check()
if updateState == true then
if updateAvail() == 'Cancel' then
break
end
elseif updateState == false then
break
elseif updateState == 'ERROR' then
LogFile.w('Updater Error Occured', runningProgram)
i = i + 1
if i < 4 then
term.setBackgroundColor(256)
term.clear()
drawTitleBar()
printer.centered('The Updater Is Experiencing Issues', 6)
printer.centered('Please Ensure You Are Connected To The Internet', 8)
printer.centered('If You Have An Active Internet Connection', 10)
printer.centered('Then Report On Forum Page', 11)
printer.centered('Retry Attempt: '..i, 19)
for x = 3, 1, -1 do
if x == 1 then
printer.centered('Retrying In: '..x..' Second', 19)
elseif x > 1 then
printer.centered('Retrying In: '..x..' Seconds', 19)
else break end
sleep(1)
end
else
LogFile.w('Updater Skipping Due To Failed Connection', runningProgram)
term.setBackgroundColor(256)
term.clear()
drawTitleBar()
printer.centered('The Updater Isnt Able To Connect', 6)
printer.centered('Due To Retrying 3 Times, The System Has', 8)
printer.centered('Decided To Skip The Update...', 10)
printer.centered('Please Connect To Internet', 11)
printer.centered('When Possible', 12)
for x = 5, 1, -1 do
if x == 1 then
printer.centered('Skipping In: '..x..' Second', 19)
elseif x > 1 then
printer.centered('Skipping In: '..x..' Seconds', 19)
else break end
sleep(1)
end
return 'Cancel'
end
else
LogFile.e('Updater Unknown Return', runningProgram)
error 'Error Occured When Updating'
end
end
return true
end
function bootMenu()
LogFile.i('Boot Menu Entered', runningProgram)
while true do
term.clear()
titleBar.draw("HbombOS Security Suite", "BIOS Login", colors.cyan, 256, 128, 256, 1)
function adminPasswordE()
PrintCentered("HbombOS Security Suite", 4)
PrintCentered("Boot Options", 5)
PrintCentered("Type In Admin Password To Continue", 18)
PrintCentered("Or Reboot (CTRL+R) To Cancel", 19)
adminPassText = "Password: "
term.setCursorPos(termX/2-#adminPassText, 7)
write (adminPassText)
local input = read("*")
if input == adminPassword then
return true
end
end
if adminPasswordE() then
return true
else
LogFile.w('Incorrect Admin Password In BootMenu', runningProgram)
printer.centered("Incorrect!", 8)
sleep(0.5)
end
end
end
function bootMenuOptions(continue)
LogFile.i('Boot Menu Option Opened', runningProgram)
if not bootMenu() then bootMenu() end
term.setTextColor(1)
term.setBackgroundColor(256)
term.clear()
titleBar.draw("HbombOS Security Suite", "Settings", colors.cyan, 256, 128, 256, 1)
PrintCentered("HbombOS Security Suite", 4)
PrintCentered("Boot Options", 5)
PrintCentered("Use Your Arrow Keys To Select, Enter To Confirm", 19)
local continue = false
local options = {
{'Reset Settings', function()
LogFile.w('Removing System Settings', runningProgram)
term.clear()
PrintCentered("Removing Settings", 6)
sleep(0)
PrintCentered("Removing Administrator Password", 18)
sleep(1)
if fs.exists('/systemFiles/Security/adminPass') then fs.delete('/systemFiles/Security/adminPass') end
PrintCentered("Removing Program Settings", 18)
sleep(0.2)
if fs.exists('/systemFiles/Programs/pinConfig') then fs.delete ('systemFiles/Programs/pinConfig') end
PrintCentered("Removing Reactor Configuration", 18)
sleep(0)
if fs.exists('/systemFiles/Programs/reactorConfig') then fs.delete ('systemFiles/Programs/reactorConfig') end
PrintCentered("Removing Keycard Configuration", 18)
sleep(0)
if fs.exists('/systemFiles/Programs/keycardConfig') then fs.delete ('systemFiles/Programs/keycardConfig') end
PrintCentered("Removing DualKey Configuration", 18)
sleep(0.5)
if fs.exists('/systemFiles/Programs/dualKeyConfig') then fs.delete ('systemFiles/Programs/dualKeyConfig') end
PrintCentered("Removing KeyCard Dual Configuration", 18)
sleep(0.5)
if fs.exists('/systemFiles/Programs/KeyDualConfig') then fs.delete ('systemFiles/Programs/KeyDualConfig') end
PrintCentered("Removing RangeLock Configuration", 18)
sleep(0.5)
if fs.exists('/systemFiles/Programs/rangeLockSettings') then fs.delete ('systemFiles/Programs/rangeLockSettings') end
PrintCentered("Removing Updater Configuration", 18)
sleep(1)
if fs.exists('/systemFiles/Install/updateConfig') then fs.delete ('systemFiles/Install/updateConfig') end
PrintCentered("Removing System Configuration", 18)
sleep(2)
if fs.exists('/systemFiles/Programs/configuration') then fs.delete ('systemFiles/Programs/configuration') end
PrintCentered("Settings Reset, Rebooting!", 18)
LogFile.i('Settings Reset', runningProgram)
sleep(2)
os.reboot()
end},
{'Uninstall Security Suite', function()
LogFile.i('Wiping Computer', runningProgram)
term.setCursorPos(1,1)
term.setBackgroundColor(256)
term.setTextColor(colours.white)
term.clear()
titleBar.draw("HbombOS BIOS", "Uninstaller", colors.cyan, 256, 128, 256, 1)
printer.centered("Please Wait While We Uninstall Security Suite 2014", 6)
sleep(4)
local function rmFold(path)
if path == '/rom' or path == "/openp" then
return
end
for i, v in ipairs(fs.list(path)) do
sleep(0.5)
term.setTextColor(1)
term.setBackgroundColor(256)
if fs.isDir(path..'/'..v) then
rmFold(path..'/'..v)
else
if fs.delete(path..'/'..v) then
term.setTextColor(1)
PrintCentered('Removed: '..path..'/'..v, 18)
LogFile.i('Removed: '..path, runningProgram)
sleep(0.5)
end
end
end
if path ~= '' then
fs.delete(path)
end
end
rmFold('')
end},
{'Use Shell/CraftOS', function() term.setBackgroundColor(colors.black) term.clear() term.setCursorPos(1,1) LogFile.i('Shell Opened', runningProgram) shell.run ("shell") end},
{'Change Admin Password', function()
term.clear()
titleBar.draw("HbombOS Security Suite", "Password Management", colors.cyan, 256, 128, 256, 1)
newPassword2Wait = true
newPassWait = true
oldPassWait = true
start()
oldPassword()
LogFile.e('Password Changer Crash', runningProgram)
error("Password Changer CRASH Report If Not Your Fault")
end},
{'Force Update', function()
LogFile.i('Force Updating Client', runningProgram)
term.clear()
titleBar.draw("HbombOS Security Suite", "Force Updating", colors.cyan, 256, 128, 256, 1)
printer.centered("Downloading New Update Firmware", 19)
printer.centered("Force Updating Client", 6)
sleep(1)
download.git("https://raw.githubusercontent.com/hbomb79/securitySystemPro/master/systemFiles/Install/updater", "systemFiles/Install/updater")
printer.centered("Running Updater", 19)
sleep(0)
shell.run("systemFiles/Install/updater")
sleep(4)
continue = true
end},
{'Change Startup File', function() programMenu() end},
{'Continue Boot', function() LogFile.i('Left Boot Menu', runningProgram) continue = true end}
}
local selected = 1
local function draw()
for i, v in ipairs(options) do
local bg = 256
local tc = colours.white
if i == selected then
bg = 256
tc = colours.blue
end
term.setTextColor(tc)
term.setBackgroundColor(bg)
PrintCentered(' '..v[1]..' ', math.floor(#options/2) + i + 4)
end
end
local wait = true
draw()
while wait do
local event, key = os.pullEvent('key')
if key == keys.up then
selected = selected - 1
if selected < 1 then
selected = 1
end
elseif key == keys.down then
selected = selected + 1
if selected > #options then
selected = #options
end
elseif key == keys.enter then
if options[selected][1] == 'Uninstall Security Suite' then
term.setTextColor(1)
term.setBackgroundColor(256)
term.clear()
titleBar.draw("HbombOS Security Suite", "Settings", colors.cyan, 256, 128, 256, 1)
PrintCentered("HbombOS Security Suite", 4)
PrintCentered("Boot Options", 5)
PrintCentered("Use Your Arrow Keys To Select, Enter To Confirm", 19)
PrintCentered("Are You Sure, ALL Files Will Be Removed", 10)
PrintCentered("Including Files Not From Security Suite", 11)
PrintCentered("Y To Continue, N To Cancel", 15)
PrintCentered("", 19)
local _ = true
while _ do
local ev, key = os.pullEvent('char')
if key == 'y' then
sleep(0)
term.clear()
term.setTextColor(1)
term.setBackgroundColor(256)
titleBar.draw("HbombOS Security Suite", "Uninstall", colors.cyan, 256, 128, 256, 1)
PrintCentered("Removing HbombOS Security Suite", 6)
options[selected][2]()
term.clear()
titleBar.draw("HbombOS Security Suite", "Uninstall", colors.cyan, 256, 128, 256, 1)
printer.centered("Thanks For Using Security Suite", 6)
printer.centered("If Bugs Made You Uninstall, Please Report Them!", 8)
printer.centered("Click Anywhere On-screen To Reboot", 19)
os.pullEvent("mouse_click")
os.reboot()
elseif key == 'n' then
_ = false
term.clear()
titleBar.draw("HbombOS Security Suite", "Settings", colors.cyan, 256, 128, 256, 1)
PrintCentered("HbombOS Security Suite", 4)
PrintCentered("Boot Options", 5)
PrintCentered("Use Your Arrow Keys To Select, Enter To Confirm", 19)
--bootMenuOptions(true)
end
end
term.setTextColor(colors.red)
term.setBackgroundColor(colors.white)
PrintCentered(' ', 0)
term.setTextColor(1)
term.setBackgroundColor(256)
else
options[selected][2]()
wait = false
end
end
draw()
end
term.setTextColor(colors.white)
printer.centered("Continuing Boot...", 19)
sleep(0.1)
printer.centered("Returning continue Variable", 19)
return continue
end
function Start()
checkStartKey()
local key = nil
local success = false
parallel.waitForAll(function()success = main() os.queueEvent('BootDone') end, function() key = RecieveStartupKey() end)
if success and key == keys.leftAlt or key == keys.rightAlt then
success = bootMenuOptions()
end
return success
end
function readFiles()
LogFile.i('Reading System Config', runningProgram)
printer.centered("Reading Configuration Files", 19)
local f = fs.open('systemFiles/Programs/configuration', 'r') --Opens Config
fileStartup = f.readLine()
f.close()
if fileStartup then --Checks If The User Has A File Chosen
printer.centered("Running: "..fileStartup, 19)
LogFile.i('Running User File: '..fileStartup, runningProgram)
--shell.run(''..fileStartup..'')
shell.run(fileStartup) --Runs User Specified Program
sleep(4)
LogFile.e('Program: '..fileStartup..' Crashed', runningProgram)
error("The Program: "..fileStartup.." Appears To Have Crashed") --Preliminary BSoD Catching Program Closure
end
printer.centered("No Default File Stored", 19)
sleep(1)
os.reboot() --Reboots So User Can Pick There Program
end
function initialise() --Function Used To Trace Error Catching
term.setBackgroundColor(256)
term.clear()
drawTitleBar()
if Start() then
readFiles()
else
errora.err("Uh Oh! Booting Failed", "The start-up process failed when waiting")
end
end
local _, err = pcall(initialise) --Error Catching, All Functions Are Called From initialise() at some point...
if err then
LogFile.e('XPCALL Error Caught: '..err, runningProgram)
term.setCursorBlink(false)
errora.err(err, 'Startup Has Crashed! Please Report Above Error', true) --BSoD for protection, the 'true' is an auto-reboot option to prevent the door waiting for a prompt
end
Thanks In Advance - Harry