add internal route to update the cloudron

need to way to trigger updates of cloudron using the caas tool
This commit is contained in:
girish@cloudron.io
2016-01-14 11:13:00 -08:00
parent 8f43236e2e
commit 70ac18d139
4 changed files with 33 additions and 8 deletions
+12
View File
@@ -13,6 +13,7 @@ exports = module.exports = {
sendHeartbeat: sendHeartbeat,
updateToLatest: updateToLatest,
update: update,
reboot: reboot,
migrate: migrate,
@@ -111,6 +112,7 @@ CloudronError.BAD_EMAIL = 'Bad email';
CloudronError.BAD_PASSWORD = 'Bad password';
CloudronError.BAD_NAME = 'Bad name';
CloudronError.BAD_STATE = 'Bad state';
CloudronError.ALREADY_UPTODATE = 'No Update Available';
CloudronError.NOT_FOUND = 'Not found';
function initialize(callback) {
@@ -525,6 +527,16 @@ function update(boxUpdateInfo, callback) {
callback(null);
}
function updateToLatest(callback) {
assert.strictEqual(typeof callback, 'function');
var boxUpdateInfo = updateChecker.getUpdateInfo().box;
if (!boxUpdateInfo) return callback(new CloudronError(CloudronError.ALREADY_UPTODATE, 'No update available'));
update(boxUpdateInfo, callback);
}
function doUpgrade(boxUpdateInfo, callback) {
assert(boxUpdateInfo !== null && typeof boxUpdateInfo === 'object');