SHOW:
|
|
- or go back to the newest paste.
| 1 | function udprog(updateprogram, pastelink, udloc, updatefunargs, startupls) | |
| 2 | - | udfarmargs = {...}
|
| 2 | + | |
| 3 | - | if udfarmargs[1] == "noset" then |
| 3 | + | --fupdateargs = {...}
|
| 4 | - | udopenset = 0 |
| 4 | + | updateargs = updatefunargs |
| 5 | os.loadAPI("/rom/programs/shell.lua")
| |
| 6 | while true do | |
| 7 | - | if fs.exists("Farmnew") then
|
| 7 | + | if fs.isDir(udloc) == false then |
| 8 | - | shell.run("delete","Farmnew")
|
| 8 | + | fs.makeDir(udloc) |
| 9 | end | |
| 10 | - | shell.run("pastebin","get","ZW6q8wWs","Farmnew")
|
| 10 | + | shell.shell.run("cd", udloc)
|
| 11 | - | if fs.exists("Farmnew") then
|
| 11 | + | |
| 12 | - | if fs.exists("Farmold") then
|
| 12 | + | |
| 13 | - | shell.run("delete","Farmold")
|
| 13 | + | if fs.exists(updateprogram.."new") then |
| 14 | shell.shell.run("delete",updateprogram.."new")
| |
| 15 | end | |
| 16 | - | shell.run("rename","Farm","Farmold")
|
| 16 | + | shell.shell.run("pastebin","get",pastelink,updateprogram.."new")
|
| 17 | if fs.exists(updateprogram.."new") then | |
| 18 | - | shell.run("rename","Farmnew","Farm")
|
| 18 | + | if fs.exists(updateprogram.."old") then |
| 19 | shell.shell.run("delete",updateprogram.."old")
| |
| 20 | end | |
| 21 | if fs.exists("Farm") then
| |
| 22 | shell.shell.run("rename",updateprogram,updateprogram.."old")
| |
| 23 | - | if fs.exists("Farm") then
|
| 23 | + | |
| 24 | shell.shell.run("rename",updateprogram.."new",updateprogram)
| |
| 25 | if fs.exists(updateprogram) then | |
| 26 | break | |
| 27 | end | |
| 28 | - | if fs.exists("Farmold") then
|
| 28 | + | |
| 29 | if fs.exists(updateprogram) then | |
| 30 | - | shell.run("rename","Farmold","Farm")
|
| 30 | + | |
| 31 | - | if fs.exists("Farm") then
|
| 31 | + | |
| 32 | end | |
| 33 | end | |
| 34 | if fs.exists(updateprogram.."old") then | |
| 35 | if updateloop > 30 then | |
| 36 | shell.shell.run("rename",updateprogram.."old",updateprogram)
| |
| 37 | if fs.exists(updateprogram) then | |
| 38 | - | local stu = fs.open("startup.lua", "w")
|
| 38 | + | |
| 39 | - | stu.write('sleep(5)\nshell.run("farmupdate", "noset")')
|
| 39 | + | |
| 40 | - | stu.close() |
| 40 | + | |
| 41 | - | if udopenset == 0 then |
| 41 | + | |
| 42 | - | shell.run("Farm", "noset")
|
| 42 | + | |
| 43 | end | |
| 44 | - | shell.run("Farm")
|
| 44 | + | local _, countsl = string.gsub(udloc,"/","") |
| 45 | countsl = countsl + 1 | |
| 46 | ||
| 47 | if startupls ~= "none" or startupls ~= nil then | |
| 48 | local stu = fs.open("startup.lua", "w")
| |
| 49 | stu.write(startupls) | |
| 50 | stu.close() | |
| 51 | end | |
| 52 | if updatefunargs ~= nil or updatefunargs ~= "none" then | |
| 53 | shell.shell.run(updateprogram .. "," .. unpack(updateargs)) | |
| 54 | else | |
| 55 | shell.shell.run(updateprogram) | |
| 56 | end | |
| 57 | for i=1,countsl do | |
| 58 | shell.shell.run("cd", "..")
| |
| 59 | end | |
| 60 | end |