trying new update system mayb
This commit is contained in:
		
							parent
							
								
									2e33e98e5e
								
							
						
					
					
						commit
						68a7d4eaa5
					
				
							
								
								
									
										20
									
								
								keypadOS.lua
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								keypadOS.lua
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -7,7 +7,7 @@ local require = function(path)
 | 
			
		|||
        return __DEFAULT_IMPORT(path)
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local KEYPADOS_UPDATE_HASH = "PJIEvsAncSvhKOqsLGVlxvzJ"
 | 
			
		||||
rawset(__BUNDLER_FILES, "updater.lua", function ()
 | 
			
		||||
    local utils = require("utils.lua")
 | 
			
		||||
    local LAST_USED = os.time()
 | 
			
		||||
| 
						 | 
				
			
			@ -26,10 +26,9 @@ rawset(__BUNDLER_FILES, "updater.lua", function ()
 | 
			
		|||
                    if string.find(update_code_text, "^local __BUNDLER_FILES = {}") then
 | 
			
		||||
                        -- Make backup
 | 
			
		||||
                        fs.copy("startup.lua", "backup.lua")
 | 
			
		||||
                        local startup_file = fs.open("startup.lua", "r")
 | 
			
		||||
                        local startup_contents = startup_file.readAll()
 | 
			
		||||
                        startup_file.close()
 | 
			
		||||
                        if update_code_text ~= startup_contents then
 | 
			
		||||
                        local pattern = 'local KEYPADOS_UPDATE_HASH%s*=%s*"(.-)"'
 | 
			
		||||
                        local foundUpdateHash = inputString:match(pattern)
 | 
			
		||||
                        if KEYPADOS_UPDATE_HASH ~= foundUpdateHash then
 | 
			
		||||
                            local file = fs.open("startup.lua", "w")
 | 
			
		||||
                            file.write(update_code_text)
 | 
			
		||||
                            file.close()
 | 
			
		||||
| 
						 | 
				
			
			@ -160,13 +159,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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										12
									
								
								src/ui.lua
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								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()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,11 +19,10 @@ local function checkForUpdate()
 | 
			
		|||
                    -- Make backup
 | 
			
		||||
                    fs.copy("startup.lua", "backup.lua")
 | 
			
		||||
 | 
			
		||||
                    local startup_file = fs.open("startup.lua", "r")
 | 
			
		||||
                    local startup_contents = startup_file.readAll()
 | 
			
		||||
                    startup_file.close()
 | 
			
		||||
                    local pattern = 'local KEYPADOS_UPDATE_HASH%s*=%s*"(.-)"'
 | 
			
		||||
                    local foundUpdateHash = inputString:match(pattern)
 | 
			
		||||
 | 
			
		||||
                    if update_code_text ~= startup_contents then
 | 
			
		||||
                    if KEYPADOS_UPDATE_HASH ~= foundUpdateHash then
 | 
			
		||||
                        local file = fs.open("startup.lua", "w")
 | 
			
		||||
                        file.write(update_code_text)
 | 
			
		||||
                        file.close()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								x.py
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								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",
 | 
			
		||||
| 
						 | 
				
			
			@ -31,6 +33,7 @@ def main():
 | 
			
		|||
    buf += "        return __DEFAULT_IMPORT(path)\n";
 | 
			
		||||
    buf += "    end\n";
 | 
			
		||||
    buf += "end\n";
 | 
			
		||||
    buf += f'local KEYPADOS_UPDATE_HASH = "{UPDATE_ID}"';
 | 
			
		||||
 | 
			
		||||
    for file in FILES:
 | 
			
		||||
        print(f"=== FILE: {file}");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user