Posted 01 May 2013 - 11:54 PM
Hey guys! how do you make a updater for your program??
local count = 2
local updateInfo = {}
updateInfo[1] = { "disk/file1", "URL-ID1" }
updateInfo[2] = { "disk/file2", "URL-ID2" }
local turtleCount = 2
local turtleCopy = {}
turtleCopy[1] = { "disk/fileToTurtle1", "URL-ID3" }
turtleCopy[2] = { "disk/fileToTurtle2", "URL-ID4" }
for x = 1, count do
print("Removing " .. updateInfo[x][1] .. "...")
shell.run("rm", updateInfo[x][1])
print("Downloading new file from " .. updateInfo[x][2] .. " for " .. updateInfo[x][1])
shell.run("pastebin", "get", updateInfo[x][2], updateInfo[x][1])
end
if (not (turtle == nil)) then
print()
print("Updating turtle...")
for x = 1, turtleCount do
print("Removing " .. turtleCopy[x][2] .. " from turtle...")
shell.run("rm", turtleCopy[x][2])
print("Copying " .. turtleCopy[x][1] .. " to turtle...")
shell.run("cp", turtleCopy[x][1], turtleCopy[x][2])
end
end
if not(turtle == nil) then
shell.run("update")
end
local version = "x.x.x"
--you need a webhoster for the next thing
local ckeckForUpdate = http.get("http://www.example.com/currentVersion.php") --you have to enter your link
local checkForUpdate = checkForUpdate.readAll()
if not version == checkForUpdate then
--Here comes the download from pastebin
else
print("You have the newest version")
end