View difference between Paste ID: 0WZHZdU3 and 1niw24Vd
SHOW: | | - or go back to the newest paste.
1
updateloop = 0
2
updateargs = {...} 
3
--udlstbl = {"updateprogram", "pastelink", "udloc", "startupls", "strtprg"}
4
5
updateprogram = updateargs[1]
6
pastelink = updateargs[2]
7
udloc = updateargs[3]
8
startupls = updateargs[4]
9
strtprg = updateargs[5]
10
if errhnd ~= 1 then
11-
function printud()
11+
    function printud()
12-
    term.clear()
12+
        term.clear()
13-
    term.setCursorPos(1,1)
13+
        term.setCursorPos(1,1)
14-
    print("Updating...")
14+
        print("Updating...")
15-
end
15+
16-
printud()
16+
17-
local _, countsl = string.gsub(udloc,"/","")
17+
    local _, countsl = string.gsub(udloc,"/","")
18-
countslw = countsl + 1
18+
    countslw = countsl + 1
19-
for i=1,countslw do
19+
    for i=1,countslw do
20-
    shell.run("cd", "..")
20+
        shell.run("cd", "..")
21
        printud()
22-
end
22+
23-
numprogargs = 6
23+
    numprogargs = 6
24-
if #updateargs > 5 then
24+
    if #updateargs > 5 then
25-
    progargs = {}
25+
        progargs = {}
26-
    for i=numprogargs,#updateargs do
26+
        for i=numprogargs,#updateargs do
27-
        table.insert(progargs, updateargs[i])
27+
            table.insert(progargs, updateargs[i])
28
        end
29-
end
29+
30-
while true do
30+
    while true do
31-
    if fs.isDir(udloc) == false then
31+
        if errhnd ~= 1 then
32-
        fs.makeDir(udloc)
32+
            if fs.isDir(udloc) == false then
33
                fs.makeDir(udloc)
34-
    shell.run("cd", udloc)
34+
35-
    if fs.exists(udloc.."/"..updateprogram.."new") then
35+
            shell.run("cd", udloc)
36-
        shell.run("delete",updateprogram.."new") 
36+
            if fs.exists(udloc.."/"..updateprogram.."new") then
37
                shell.run("delete",updateprogram.."new") 
38
                printud()
39-
    shell.run("pastebin","get",pastelink,updateprogram.."new")
39+
40
            shell.run("pastebin","get",pastelink,updateprogram.."new")
41-
    --print(udloc.."/"..updateprogram.."new")
41+
42-
    if fs.exists(udloc.."/"..updateprogram.."new") then
42+
            --print(udloc.."/"..updateprogram.."new")
43-
        if fs.exists(udloc.."/"..updateprogram.."old") then
43+
            if fs.exists(udloc.."/"..updateprogram.."new") then
44-
            shell.run("delete",updateprogram.."old")
44+
                if fs.exists(udloc.."/"..updateprogram.."old") then
45
                    shell.run("delete",updateprogram.."old")
46
                    printud()
47-
        if fs.exists(udloc.."/"..updateprogram) then
47+
                end
48-
            shell.run("rename",updateprogram,updateprogram.."old")
48+
                if fs.exists(udloc.."/"..updateprogram) then
49
                    shell.run("rename",updateprogram,updateprogram.."old")
50
                    printud()
51-
        shell.run("rename",updateprogram.."new",updateprogram)
51+
                end
52-
        if fs.exists(udloc.."/"..updateprogram) then
52+
                shell.run("rename",updateprogram.."new",updateprogram)
53-
            break
53+
                if fs.exists(udloc.."/"..updateprogram) then
54
                    break
55
                end
56-
    if fs.exists(udloc.."/"..updateprogram) then
56+
57-
        if updateloop > 20 then
57+
58-
            break
58+
                if updateloop > 20 then
59
                    break
60
                end
61-
    if fs.exists(udloc.."/"..updateprogram.."old") then
61+
62-
        if updateloop > 30 then
62+
            if fs.exists(udloc.."/"..updateprogram.."old") then
63-
            shell.run("rename",updateprogram.."old",updateprogram)
63+
                if updateloop > 30 then
64
                    shell.run("rename",updateprogram.."old",updateprogram)
65-
                break
65+
                    if fs.exists(udloc.."/"..updateprogram) then
66
                        break
67
                    end
68
                end
69-
    updateloop = updateloop + 1
69+
70-
    sleep(0)
70+
            updateloop = updateloop + 1
71-
end
71+
            sleep(0)
72-
sleep(0)
72+
73-
countslw = countsl + 1
73+
74-
for i=1,countslw do
74+
    if errhnd ~= 1 then
75-
    shell.run("cd", "..")
75+
        sleep(0)
76
        countslw = countsl + 1
77-
end
77+
        for i=1,countslw do
78-
--print(startupls)
78+
            shell.run("cd", "..")
79-
--sleep(10)
79+
80-
if startupls ~= "none" and startupls ~= nil then
80+
81-
    local stu = fs.open("startup.lua", "w")
81+
        --print(startupls)
82-
    stu.write(startupls)
82+
        --sleep(10)
83-
    stu.close()
83+
        if startupls ~= "none" and startupls ~= nil then
84-
end
84+
            local stu = fs.open("startup.lua", "w")
85-
if strtprg == nil and strtprg == "no" and strtprg == "none" then
85+
            stu.write(startupls)
86-
else
86+
            stu.close()
87
        end
88-
if progargs ~= nil then
88+
        if strtprg == nil and strtprg == "no" and strtprg == "none" then
89-
    shell.run(udloc.."/"..updateprogram.." "..unpack(progargs))
89+
        else
90-
else
90+
91-
    shell.run(udloc.."/"..updateprogram)
91+
        --if progargs ~= nil then
92-
end
92+
        --    shell.run(udloc.."/"..updateprogram.." "..unpack(progargs))
93
        --else
94
        --    shell.run(udloc.."/"..updateprogram)
95
        --end
96
        end
97
    end
98
end