Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- verze = "20.0829.R1"
- if fs.exists("/C/system/server/rules/AD/period.cfg") then
- local data = fs.open("/C/system/server/rules/AD/period.cfg", "r")
- updatetime = data.readLine()
- data.close()
- else
- updatetime = 3600
- end
- print("Aktualizacni server, obnova po: "..updatetime.." sek.")
- local function download( pasteid, filepath ) --#more descriptive variable names
- local handle = http.get( "https://www.pastebin.com/raw/" .. pasteid ) --#sometimes CC has problems with https
- if handle then --#if the request succeeded
- local file = fs.open( filepath, "w" )
- file.write( handle.readAll() )
- file.close()
- handle.close() --#always close web handles!
- bar("OK", "Aktualizace uspesna")
- return true --#we succeeded, return true
- end
- bar("FAIL", "aktualizace neuspesna")
- return false --#it didn't work, return false
- end
- function bar(styl, text)
- if (styl == "OK") then -- Uspech
- term.setTextColor(colors.green)
- elseif (styl == "FAIL") then -- Neuspesne
- term.setTextColor(colors.red)
- elseif (styl == "INFO") then -- Informativni
- term.setTextColor(colors.lightBlue)
- elseif (styl == "def") then -- defaultni
- term.setTextColor(colors.white)
- elseif (styl == "PRO") then -- Progress
- term.setTextColor(colors.yellow)
- else
- styl = "def"
- term.setTextColor(colors.white)
- end
- if not (styl == "def") then
- zprava = ("["..textutils.formatTime(os.time(), true).."] ["..styl.."] "..text)
- else
- zprava = text
- end
- print (zprava)
- end
- function update()
- bar("PRO", "Probiha aktualizace desktop.lua")
- if fs.exists ("/C/system/server/rules/Update/desktop.lua") then fs.delete ("/C/system/server/rules/Update/desktop.lua") end
- download("HyhMtGvd", "/C/system/server/rules/Update/desktop.lua")
- bar("PRO", "Probiha aktualizace startup.lua")
- if fs.exists ("/C/system/server/rules/Update/startup.lua") then fs.delete ("/C/system/server/rules/Update/startup.lua") end
- download("0xh6jEx1", "/C/system/server/rules/Update/startup.lua")
- bar("PRO", "Probiha aktualizace setting.lua")
- if fs.exists ("/C/system/server/rules/Update/setting.lua") then fs.delete ("/C/system/server/rules/Update/setting.lua") end
- download("vxJjQzem", "/C/system/server/rules/Update/setting.lua")
- sleep(tonumber(updatetime))
- update()
- end
- update()
Add Comment
Please, Sign In to add comment