Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local VERSION_FILE = "/stockpile/version"
- function parseVersion(v)
- local version = {}
- for i in string.gmatch(v, "%d+") do
- table.insert(version, i)
- end
- return version
- end
- function isNewerVersion(v1, v2)
- for i = 1, #v1 do
- if v1[i] > v2[i] then
- return true
- elseif v1[i] < v2[i] then
- return false
- end
- end
- return false
- end
- local runInstall = false
- if fs.exists(VERSION_FILE) then
- local handle = fs.open(VERSION_FILE, "r")
- local rawVersion = handle.readAll()
- handle.close()
- local currentVersion = parseVersion(rawVersion)
- handle = http.get("https://raw.githubusercontent.com/sidoh/stockpile/master" .. VERSION_FILE)
- local rawRemoteVersion = handle.readAll()
- handle.close()
- local remoteVersion = parseVersion(rawRemoteVersion)
- if not isNewerVersion(remoteVersion, currentVersion) then
- print("Already at newest version (" .. rawVersion .. ")! Continue update anyway?")
- print("(y)es / (n)o")
- io.write("> ")
- while true do
- local sEvent, key = os.pullEvent("key")
- if key == keys.y then
- runInstall = true
- break
- elseif key == keys.n then
- print("Aborting.")
- break
- end
- end
- else
- runInstall = true
- end
- else
- runInstall = true
- end
- if runInstall = true
- then
- shell.run("pastebin get wPtGKMam github")
- shell.run("github sidoh stockpile /downloads")
- shell.run("/downloads/stockpile/bootstrap")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement