Merge commits
This commit is contained in:
		
						commit
						a2546cb9ba
					
				
							
								
								
									
										55
									
								
								keypadOS.lua
									
									
									
									
									
								
							
							
						
						
									
										55
									
								
								keypadOS.lua
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -7,7 +7,7 @@ local require = function(path)
 | 
			
		|||
        return __DEFAULT_IMPORT(path)
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
rawset(__BUNDLER_FILES, "updater.lua", function ()
 | 
			
		||||
local KEYPADOS_UPDATE_HASH = "ThZGemtZHshNpaflGvUHcJoZ"rawset(__BUNDLER_FILES, "updater.lua", function ()
 | 
			
		||||
    local utils = require("utils.lua")
 | 
			
		||||
    local config = require("config.lua")
 | 
			
		||||
    local LAST_USED = os.time()
 | 
			
		||||
| 
						 | 
				
			
			@ -17,22 +17,34 @@ rawset(__BUNDLER_FILES, "updater.lua", function ()
 | 
			
		|||
        local difference = math.abs(current_time - LAST_USED)
 | 
			
		||||
        if difference > .5 then
 | 
			
		||||
            print("INFO: Updating! (diff: " .. tostring(difference) .. ")")
 | 
			
		||||
            local update_code_request = http.get(config.release_url)
 | 
			
		||||
            local update_code_request = http.get(config.release_url .. "?x=" .. tostring(math.random(11111111, 99999999))) -- I HATE CACHE REEEEEEEEEEEEEEEEE
 | 
			
		||||
            if update_code_request then
 | 
			
		||||
                local update_code_text = update_code_request.readAll()
 | 
			
		||||
                if update_code_text then
 | 
			
		||||
                    if string.find(update_code_text, "^local __BUNDLER_FILES = {}") then
 | 
			
		||||
                        fs.copy("startup.lua","backup.lua")
 | 
			
		||||
                        local file = fs.open("startup.lua", "w")
 | 
			
		||||
                        file.write(update_code_text)
 | 
			
		||||
                        file.close()
 | 
			
		||||
                        os.reboot()
 | 
			
		||||
                        if fs.exists("backup.lua") then
 | 
			
		||||
                            fs.delete("backup.lua")
 | 
			
		||||
                        end
 | 
			
		||||
                        fs.copy("startup.lua", "backup.lua")
 | 
			
		||||
                        if not string.find(update_code_text, KEYPADOS_UPDATE_HASH) then
 | 
			
		||||
                            local file = fs.open("startup.lua", "w")
 | 
			
		||||
                            file.write(update_code_text)
 | 
			
		||||
                            file.close()
 | 
			
		||||
                            os.reboot()
 | 
			
		||||
                        else
 | 
			
		||||
                            print("Nothing changed, not updating.")
 | 
			
		||||
                            LAST_USED = os.time()
 | 
			
		||||
                            return
 | 
			
		||||
                        end
 | 
			
		||||
                    else
 | 
			
		||||
                        print("Bad file download (core)")
 | 
			
		||||
                    end
 | 
			
		||||
                    print("Bad file download (core)")
 | 
			
		||||
                else
 | 
			
		||||
                    print("Bad mem read (core)")
 | 
			
		||||
                end
 | 
			
		||||
                print("Bad mem read (core)")
 | 
			
		||||
            else
 | 
			
		||||
                print("Bad download (core)")
 | 
			
		||||
            end
 | 
			
		||||
            print("Bad download (core)")
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
    function mod.UpdateChecker()
 | 
			
		||||
| 
						 | 
				
			
			@ -144,13 +156,20 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
 | 
			
		|||
        ui.enterButton = ui.main:addButton()
 | 
			
		||||
            :setText(">>>>")
 | 
			
		||||
            :setBackground(colors.blue)
 | 
			
		||||
            :setPosition(6,3)
 | 
			
		||||
            :setPosition(6,2)
 | 
			
		||||
            :setSize(1.5,3.2)
 | 
			
		||||
            :onClick(function()
 | 
			
		||||
                unlockDoor(ui)
 | 
			
		||||
            end)
 | 
			
		||||
        local btnX = 1
 | 
			
		||||
        local btnY = 3
 | 
			
		||||
        local btnY = 2
 | 
			
		||||
        ui.main:addButton()
 | 
			
		||||
            :setPosition(1, 5)
 | 
			
		||||
            :setText("0")
 | 
			
		||||
            :setSize(6,1)
 | 
			
		||||
            :onClick(function()
 | 
			
		||||
                addToPin(ui, 0)
 | 
			
		||||
            end)
 | 
			
		||||
        for i = 1, 9 do
 | 
			
		||||
            ui.main:addButton()
 | 
			
		||||
                :setPosition(btnX, btnY)
 | 
			
		||||
| 
						 | 
				
			
			@ -170,11 +189,13 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
 | 
			
		|||
        end)
 | 
			
		||||
        if not status and err ~= "Terminated" then
 | 
			
		||||
            print("Error detected: " .. err)
 | 
			
		||||
            monitor.clear()
 | 
			
		||||
            http.post("https://ntfy.sh/keypadOS_alerts", err, {Priority = "urgent"}) --exposed ntfy url no spam me pls
 | 
			
		||||
            sleep(5)
 | 
			
		||||
            utils.MonReset(0.5)
 | 
			
		||||
            fs.delete("basalt.lua")
 | 
			
		||||
            fs.delete("startup.lua")
 | 
			
		||||
            fs.copy("backup.lua", "startup.lua")
 | 
			
		||||
            os.exit()
 | 
			
		||||
            os.reboot()
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
    return mod
 | 
			
		||||
| 
						 | 
				
			
			@ -201,12 +222,12 @@ rawset(__BUNDLER_FILES, "main.lua", function ()
 | 
			
		|||
    local utils = require("utils.lua")
 | 
			
		||||
    local updater = require("updater.lua")
 | 
			
		||||
    local main = {}
 | 
			
		||||
    KEYPADOS_VERSION = "3.0"
 | 
			
		||||
    KEYPADOS_VERSION = "4.0"
 | 
			
		||||
    function main.Main()
 | 
			
		||||
        utils.MonPrint(0.5)
 | 
			
		||||
        utils.MonReset(0.5)
 | 
			
		||||
        updater.GetBasalt()
 | 
			
		||||
        utils.MonPrint("keypadOS v" .. KEYPADOS_VERSION)
 | 
			
		||||
        utils.MonPrint(1)
 | 
			
		||||
        utils.MonReset(1)
 | 
			
		||||
        require("ui.lua").InitUi()
 | 
			
		||||
    end
 | 
			
		||||
    return main
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,7 @@ local config = {
 | 
			
		|||
    correctPin = "42169",
 | 
			
		||||
    release_url = "https://git.mcorangehq.xyz/xomf/keypadOS/raw/branch/main/keypadOS.lua",
 | 
			
		||||
    basalt_url = "https://raw.githubusercontent.com/Pyroxenium/Basalt/master/docs/versions/latest.lua",
 | 
			
		||||
    ntfy_url = "https://ntfy.sh/keypadOS_alerts",
 | 
			
		||||
    config_path = "keypadOS.config.lua"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,13 +5,13 @@ local updater = require("updater.lua")
 | 
			
		|||
local main = {}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
KEYPADOS_VERSION = "3.0"
 | 
			
		||||
KEYPADOS_VERSION = "4.0"
 | 
			
		||||
 | 
			
		||||
function main.Main()
 | 
			
		||||
    utils.MonPrint(0.5)
 | 
			
		||||
    utils.MonReset(0.5)
 | 
			
		||||
    updater.GetBasalt()
 | 
			
		||||
    utils.MonPrint("keypadOS v" .. KEYPADOS_VERSION)
 | 
			
		||||
    utils.MonPrint(1)
 | 
			
		||||
    utils.MonReset(1)
 | 
			
		||||
    require("ui.lua").InitUi()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										19
									
								
								src/ui.lua
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								src/ui.lua
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -83,14 +83,22 @@ function mod.InitUi()
 | 
			
		|||
    ui.enterButton = ui.main:addButton()
 | 
			
		||||
        :setText(">>>>")
 | 
			
		||||
        :setBackground(colors.blue)
 | 
			
		||||
        :setPosition(6,3)
 | 
			
		||||
        :setPosition(6,2)
 | 
			
		||||
        :setSize(1.5,3.2)
 | 
			
		||||
        :onClick(function()
 | 
			
		||||
            unlockDoor(ui)
 | 
			
		||||
        end)
 | 
			
		||||
 | 
			
		||||
    local btnX = 1
 | 
			
		||||
    local btnY = 3
 | 
			
		||||
    local btnY = 2
 | 
			
		||||
 | 
			
		||||
    ui.main:addButton()
 | 
			
		||||
        :setPosition(1, 5)
 | 
			
		||||
        :setText("0")
 | 
			
		||||
        :setSize(6,1)
 | 
			
		||||
        :onClick(function()
 | 
			
		||||
            addToPin(ui, 0)
 | 
			
		||||
        end)
 | 
			
		||||
 | 
			
		||||
    for i = 1, 9 do
 | 
			
		||||
        ui.main:addButton()
 | 
			
		||||
| 
						 | 
				
			
			@ -114,12 +122,13 @@ function mod.InitUi()
 | 
			
		|||
 | 
			
		||||
    if not status and err ~= "Terminated" then
 | 
			
		||||
        print("Error detected: " .. err)
 | 
			
		||||
        monitor.clear()
 | 
			
		||||
        http.post(config.ntfy_url, err, {Priority = "urgent"}) --exposed ntfy url no spam me pls
 | 
			
		||||
        sleep(5)
 | 
			
		||||
        utils.MonReset(0.5)
 | 
			
		||||
        fs.delete("basalt.lua")
 | 
			
		||||
        fs.delete("startup.lua")
 | 
			
		||||
        fs.copy("backup.lua", "startup.lua")
 | 
			
		||||
        os.exit()
 | 
			
		||||
        -- os.reboot()
 | 
			
		||||
        os.reboot()
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,6 +4,11 @@ local LAST_USED = os.time()
 | 
			
		|||
 | 
			
		||||
local mod = {}
 | 
			
		||||
 | 
			
		||||
-- For lsp, shouldnt ever be check for true
 | 
			
		||||
if not __UPDATE_HASH then
 | 
			
		||||
    __UPDATE_HASH = "WHATTHEFUCK";
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function checkForUpdate()
 | 
			
		||||
    local current_time = os.time()
 | 
			
		||||
    local difference = math.abs(current_time - LAST_USED)
 | 
			
		||||
| 
						 | 
				
			
			@ -12,25 +17,36 @@ local function checkForUpdate()
 | 
			
		|||
    --therefore it's time to force an update down the users throat (microsoft moment)
 | 
			
		||||
    if difference > .5 then
 | 
			
		||||
        print("INFO: Updating! (diff: " .. tostring(difference) .. ")")
 | 
			
		||||
        local update_code_request = http.get(config.release_url)
 | 
			
		||||
        local update_code_request = http.get(config.release_url .. "?x=" .. tostring(math.random(11111111, 99999999))) -- I HATE CACHE REEEEEEEEEEEEEEEEE
 | 
			
		||||
        if update_code_request then
 | 
			
		||||
            local update_code_text = update_code_request.readAll()
 | 
			
		||||
            if update_code_text then
 | 
			
		||||
                if string.find(update_code_text, "^local __BUNDLER_FILES = {}") then
 | 
			
		||||
                    --make backup
 | 
			
		||||
                    fs.copy("startup.lua","backup.lua")
 | 
			
		||||
                    -- Make backup
 | 
			
		||||
                    if fs.exists("backup.lua") then
 | 
			
		||||
                        fs.delete("backup.lua")
 | 
			
		||||
                    end
 | 
			
		||||
                    fs.copy("startup.lua", "backup.lua")
 | 
			
		||||
 | 
			
		||||
                    --install update
 | 
			
		||||
                    local file = fs.open("startup.lua", "w")
 | 
			
		||||
                    file.write(update_code_text)
 | 
			
		||||
                    file.close()
 | 
			
		||||
                    os.reboot()
 | 
			
		||||
                    if not string.find(update_code_text, __UPDATE_HASH) then
 | 
			
		||||
                        local file = fs.open("startup.lua", "w")
 | 
			
		||||
                        file.write(update_code_text)
 | 
			
		||||
                        file.close()
 | 
			
		||||
                        os.reboot()
 | 
			
		||||
                    else
 | 
			
		||||
                        print("Nothing changed, not updating.")
 | 
			
		||||
                        LAST_USED = os.time()
 | 
			
		||||
                        return
 | 
			
		||||
                    end
 | 
			
		||||
                else
 | 
			
		||||
                    print("Bad file download (core)")
 | 
			
		||||
                end
 | 
			
		||||
                print("Bad file download (core)")
 | 
			
		||||
            else
 | 
			
		||||
                print("Bad mem read (core)")
 | 
			
		||||
            end
 | 
			
		||||
            print("Bad mem read (core)")
 | 
			
		||||
        else
 | 
			
		||||
            print("Bad download (core)")
 | 
			
		||||
        end
 | 
			
		||||
        print("Bad download (core)")
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										6
									
								
								x.py
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								x.py
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -1,5 +1,7 @@
 | 
			
		|||
#!/usr/bin/python
 | 
			
		||||
 | 
			
		||||
import string
 | 
			
		||||
import random
 | 
			
		||||
UPDATE_ID=  ''.join(random.choices(string.ascii_letters, k=24))
 | 
			
		||||
OUTPUT="keypadOS.lua";
 | 
			
		||||
FILES= [
 | 
			
		||||
    "updater.lua",
 | 
			
		||||
| 
						 | 
				
			
			@ -36,6 +38,7 @@ def minimise(buf: str) -> str:
 | 
			
		|||
 | 
			
		||||
def main():
 | 
			
		||||
    buf = ""
 | 
			
		||||
    buf += "local __UPDATE_HASH = \"" + {UPDATE_ID} + "\"";
 | 
			
		||||
    buf += "local __BUNDLER_FILES = {}\n";
 | 
			
		||||
    buf += "local __DEFAULT_IMPORT = require\n";
 | 
			
		||||
    buf += "local require = function(path)\n";
 | 
			
		||||
| 
						 | 
				
			
			@ -49,6 +52,7 @@ def main():
 | 
			
		|||
    for file in FILES:
 | 
			
		||||
        print(f"=== FILE: {file}");
 | 
			
		||||
        buf += read_file(file);
 | 
			
		||||
    print(f"=== UPDATE HASH: {UPDATE_ID}")
 | 
			
		||||
 | 
			
		||||
    buf += "require(\"main.lua\").Main()\n";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user