-
Notifications
You must be signed in to change notification settings - Fork 130
/
manual_update.js
44 lines (34 loc) · 1.03 KB
/
manual_update.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use strict'
/*
* How to use:
* 1. Copy `update.tar` into `/opt/lamassu-updates/download/`
* 2. Run `node manual_update.js`
*/
var fs = require('fs')
var path = require('path')
var codeRoot = __dirname
var DEVICE_CONFIG_PATH = path.resolve(codeRoot, 'device_config.json')
var deviceConfig = JSON.parse(fs.readFileSync(DEVICE_CONFIG_PATH))
var config = deviceConfig.updater.extractor
config.skipVerify = true
var extractor = require(codeRoot + '/lib/update/extractor').factory(config)
var fileInfo = {
rootPath: '/opt/lamassu-updates/extract',
filePath: '/opt/lamassu-updates/download/update.tar'
}
function triggerWatchdog (cb) {
var donePath = '/opt/lamassu-updates/extract/done.txt'
fs.writeFile(donePath, 'DONE\n', null, function (err) {
if (err) throw err
console.log('watchdog triggered')
cb()
})
}
process.on('SIGTERM', function () {
// Immune
})
extractor.extract(fileInfo, function (err) {
console.log('extracting...')
if (err) throw err
triggerWatchdog(function () { console.log('all done.') })
})