:3
This commit is contained in:
parent
f83565a402
commit
6900a19205
7
rtmc.lua
7
rtmc.lua
|
@ -360,15 +360,19 @@ rawset(__BUNDLER_FILES, "updater", function ()
|
||||||
self:update(path, url);
|
self:update(path, url);
|
||||||
end
|
end
|
||||||
function updater:checkAndUpdateAll()
|
function updater:checkAndUpdateAll()
|
||||||
|
local updated = false;
|
||||||
for path, entry in pairs(self.updated_files) do
|
for path, entry in pairs(self.updated_files) do
|
||||||
if self:check(entry.branch) then
|
if self:check(entry.branch) then
|
||||||
self:update(path, entry.url);
|
self:update(path, entry.url);
|
||||||
|
updated = true;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if updated then
|
||||||
log.info("Rebooting!");
|
log.info("Rebooting!");
|
||||||
sleep(3);
|
sleep(3);
|
||||||
os.reboot();
|
os.reboot();
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
function updater:check(branch)
|
function updater:check(branch)
|
||||||
local curr = os.time();
|
local curr = os.time();
|
||||||
if not ((math.abs(curr - self.last_check) >= self.threshold) and (self.curr_commit_hash ~= "")) then
|
if not ((math.abs(curr - self.last_check) >= self.threshold) and (self.curr_commit_hash ~= "")) then
|
||||||
|
@ -411,6 +415,7 @@ rawset(__BUNDLER_FILES, "updater", function ()
|
||||||
end
|
end
|
||||||
if fs.exists(path) then
|
if fs.exists(path) then
|
||||||
fs.copy(path, path..".bak");
|
fs.copy(path, path..".bak");
|
||||||
|
fs.delete(path);
|
||||||
end
|
end
|
||||||
local fd = fs.open(path, "w");
|
local fd = fs.open(path, "w");
|
||||||
fd.write(body);
|
fd.write(body);
|
||||||
|
|
|
@ -38,14 +38,18 @@ function updater:addEntry(path, branch, url)
|
||||||
end
|
end
|
||||||
|
|
||||||
function updater:checkAndUpdateAll()
|
function updater:checkAndUpdateAll()
|
||||||
|
local updated = false;
|
||||||
for path, entry in pairs(self.updated_files) do
|
for path, entry in pairs(self.updated_files) do
|
||||||
if self:check(entry.branch) then
|
if self:check(entry.branch) then
|
||||||
self:update(path, entry.url);
|
self:update(path, entry.url);
|
||||||
|
updated = true;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if updated then
|
||||||
log.info("Rebooting!");
|
log.info("Rebooting!");
|
||||||
sleep(3);
|
sleep(3);
|
||||||
os.reboot();
|
os.reboot();
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function updater:check(branch)
|
function updater:check(branch)
|
||||||
|
@ -98,6 +102,7 @@ function updater:update(path, url)
|
||||||
end
|
end
|
||||||
if fs.exists(path) then
|
if fs.exists(path) then
|
||||||
fs.copy(path, path..".bak");
|
fs.copy(path, path..".bak");
|
||||||
|
fs.delete(path);
|
||||||
end
|
end
|
||||||
|
|
||||||
local fd = fs.open(path, "w");
|
local fd = fs.open(path, "w");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user