-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0641610
commit 3bc7e20
Showing
7 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
build/container.fmp: cleartmp build/consolidated.fmp | ||
cd tmp; \ | ||
cp ../files/container.json ./manifest.json; \ | ||
cp ../files/server.js ../build/consolidated.fmp ../files/fabmo-temp-updater.service .; \ | ||
tar -cvzf updater-stub.tar.gz server.js; \ | ||
tar -cvzf consolidated.tar.gz consolidated.fmp; \ | ||
tar -cvzf service.tar.gz fabmo-temp-updater.service; \ | ||
tar -cvzf ../build/container.fmp updater-stub.tar.gz manifest.json consolidated.tar.gz service.tar.gz | ||
|
||
dl/engine.fmp dl/updater.fmp: | ||
mkdir -p dl | ||
node fetch.js | ||
|
||
engine.tar.gz: cleartmp dl/engine.fmp | ||
cd tmp; \ | ||
tar -xvzf ../dl/engine.fmp; \ | ||
mv files.tar.gz ../engine.tar.gz ;\ | ||
mv g2.bin ../ | ||
|
||
updater.tar.gz: cleartmp dl/updater.fmp | ||
cd tmp; \ | ||
tar -xvzf ../dl/updater.fmp; \ | ||
mv files.tar.gz ../updater.tar.gz | ||
|
||
token.tar.gz: cleartmp | ||
cd tmp; \ | ||
touch install_token; \ | ||
tar -cvzf token.tar.gz install_token; \ | ||
mv token.tar.gz .. | ||
|
||
build/consolidated.fmp: cleartmp token.tar.gz updater.tar.gz engine.tar.gz g2.bin files/consolidated.json | ||
mkdir -p build | ||
cd tmp; \ | ||
cp ../engine.tar.gz .; \ | ||
cp ../updater.tar.gz .; \ | ||
cp ../token.tar.gz .; \ | ||
cp ../g2.bin .; \ | ||
cp ../files/consolidated.json ./manifest.json; \ | ||
tar -cvzf ../build/consolidated.fmp engine.tar.gz updater.tar.gz g2.bin manifest.json | ||
|
||
cleartmp: | ||
mkdir -p tmp | ||
rm -rf tmp/* | ||
|
||
clean: | ||
rm -rf tmp dl engine.tar.gz updater.tar.gz token.tar.gz g2.bin build | ||
.PHONY: cleartemp clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var request = require('request') | ||
var fs = require('fs') | ||
|
||
var MANIFEST_URL = 'http://fabmo.github.io/manifest/packages-rc.json' | ||
var engineURL = null; | ||
var updaterURL = null; | ||
//var filesDownloaded = 0; | ||
|
||
request(MANIFEST_URL, { json: true }, function(err, res, body) { | ||
packages = body['packages'] | ||
for(var i=0; i<packages.length; i++) { | ||
if(packages[i]['product'] === 'FabMo-Updater') { | ||
updaterURL = packages[i]['url'] | ||
} | ||
if(packages[i]['product'] === 'FabMo-Engine') { | ||
engineURL = packages[i]['url'] | ||
} | ||
} | ||
|
||
console.log("Downloading engine fmp") | ||
request(updaterURL) | ||
.pipe(fs.createWriteStream('dl/updater.fmp')) | ||
.on('finish', function() { | ||
// filesDownloaded += 1; | ||
console.log("Finished downloading updater.") | ||
// if(filesDownloaded === 2) { | ||
// buildPackage() | ||
// } | ||
|
||
}); | ||
|
||
console.log("Downloading updater fmp") | ||
request(engineURL) | ||
.pipe(fs.createWriteStream('dl/engine.fmp')) | ||
.on('finish', function() { | ||
// filesDownloaded += 1; | ||
console.log("Finished downloading engine.") | ||
// if(filesDownloaded === 2) { | ||
// buildPackage(); | ||
// } | ||
}); | ||
|
||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"product":"FabMo-Updater", | ||
"os":"linux", | ||
"platform":"edison", | ||
"system":"handibot", | ||
"token":"/fabmo/updater/install_token", | ||
"repository":"https://github.com/FabMo/FabMo-Updater", | ||
"updaterNeeded":"v2.0.0", | ||
"services":[ | ||
"fabmo", | ||
"fabmo-updater" | ||
], | ||
"operations":[ | ||
{ | ||
"op":"deleteFiles", | ||
"paths":[ | ||
"/fabmo/updater", | ||
"/fabmo/engine" | ||
] | ||
}, | ||
{ | ||
"op":"expandArchive", | ||
"src":"updater.tar.gz", | ||
"dest":"/fabmo/updater" | ||
}, | ||
{ | ||
"op":"expandArchive", | ||
"src":"engine.tar.gz", | ||
"dest":"/fabmo/engine" | ||
}, | ||
{ | ||
"op":"installFirmware", | ||
"src":"g2.bin" | ||
}, | ||
{ | ||
"op":"deleteFiles", | ||
"paths":[ | ||
"/opt/fabmo/approot" | ||
] | ||
}, | ||
{ | ||
"op":"expandArchive", | ||
"src":"token.tar.gz", | ||
"dest":"/fabmo/engine" | ||
} | ||
|
||
], | ||
"version":"v2.3.0-gc851de8-rc" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"product":"FabMo-Engine", | ||
"os":"linux", | ||
"platform":"edison", | ||
"system":"handibot", | ||
"token":"/fabmo/engine/install_token", | ||
"repository":"https://github.com/FabMo/FabMo-Updater", | ||
"updaterNeeded":"v2.0.0", | ||
"services":[ | ||
"fabmo" | ||
], | ||
"operations":[ | ||
{ | ||
"op":"deleteFiles", | ||
"paths":[ | ||
"/fabmo/updater/install_token" | ||
] | ||
}, | ||
{ | ||
"op":"expandArchive", | ||
"src":"updater-stub.tar.gz", | ||
"dest":"/fabmo/engine" | ||
}, | ||
{ | ||
"op":"expandArchive", | ||
"src":"consolidated.tar.gz", | ||
"dest":"/tmp" | ||
}, | ||
{ | ||
"op":"expandArchive", | ||
"src":"service.tar.gz", | ||
"dest":"/etc/systemd/system" | ||
} | ||
], | ||
"version":"v2.3.0-gc851de8-rc" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Unit] | ||
Description=One time updater consolidated update | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/bin/node /tmp/temp-updater/server.js --selfupdate /tmp/consolidated.fmp --task abcd | ||
StandardOutput=journal | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var fs = require("fs-extra") | ||
var cp = require('child_process') | ||
|
||
function exec(command, callback) { | ||
console.log('Executing: ' + command) | ||
cp.exec(command, {shell:true}, function(err, stderr, stdout) { | ||
if (err) { | ||
console.log('Error: ',err) | ||
return callback() | ||
} | ||
console.log('stdout, stderr: ', stdout, stderr) | ||
callback() | ||
}); | ||
|
||
} | ||
|
||
exec('systemctl daemon-reload', function() { | ||
exec('systemctl stop fabmo-updater', function() { | ||
fs.removeSync('/tmp/temp-updater') | ||
fs.copy('/fabmo/updater', '/tmp/temp-updater', function(err) { | ||
if(err) { | ||
console.error(err); | ||
return | ||
} | ||
console.info('Updater cloned, handing update off to clone'); | ||
console.info('See you, space cowboy.'); | ||
|
||
exec('systemctl start fabmo-temp-updater',function() {}) | ||
}); | ||
}) | ||
}) | ||
|
||
process.stdin.resume(); |