Posted 26 May 2013 - 10:05 AM
I am making an auto updater for my OS, and i got stuck. It checks to see if the OS version is not the version of the OS that is on pastebin, by downloading a separate pastebin file called version. Then it checks if you want to update, and if so, it updates. It IS downloading the version file, this i KNOW is happening, but why is it not working? it should run, because A0.20 and A0.15 are NOT the same.
Here is my code:
Here is my code:
local version = "A0.15";
function pastebinGet(code,path)
local sPath = shell.resolve(path);
local response = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode(code));
if response then
local contents = response.readAll();
response.close();
local file = fs.open(sPath,"w");
file.writeLine(contents);
file.close();
return true;
else
return false;
end
end
function update()
pastebinGet("jh1xgkC5","/.winMC/.OS/version");
verr = fs.open("/.winMC/.OS/version","r");
vers = verr.readLine();
verr.close();
print(vers); --THIS WORKS, JUST FYI SO IT IS DOWNLOADING THE VERSION, BUT WHY IS IT NOT CHECKING THE VERSION? ("A0.20", which is OBVIOUSLY not the same as "A0.15")
if not version == vers then
screenClear(); --FYI THIS IS S FUNCTION, JUST NOT SHOWN IN THE CODE HERE! AND IT WORKS!
term.setCursorPos("1,1");
col("colors.green"); --THIS IS A FUNCTION TOO, JUST NOT SHOWN. IT IS: local col = term.setTextColor;
print("AN UPDATE IS AVAILABLE, WOULD YOU LIKE TO UPDATE NOW? (YES/NO)");
local yn = string.lower(read());
if yn == "yes" then
print("Downloading update data...");
if not pastebinGet("gMPNTcBe","/.winMC/.OS/update") then
col(colors.red);
error("An error occured while updating Windows MC");
end
print("Installing");
fs.delete("winMC");
fs.move("/.winMC/.OS/update",winMC);
print("UPDATED SUCESSFULLY, REBOOTING");
shell.run("winMC");
else
print("Okay");
end
end
end
update();