Files
zigbee-OTA/scripts/updateall.js
Felix Kaechele 65ef139428 feat: support for custom CA certificates (#422)
- Adds custom CA certificate for Philips Hue OTA updates
- Adds support to use these certificates to `scripts/add.js`
- Adds concatenation of CA certs to `scripts/updateall.js`

Part of the fixes for https://github.com/Koenkk/zigbee-OTA/issues/420

Signed-off-by: Felix Kaechele <felix@kaechele.ca>
2024-01-04 16:23:22 +01:00

30 lines
956 B
JavaScript

const child_process = require('child_process');
const fs = require('fs');
const path = require('path');
const concatCaCerts = (folder = 'cacerts', outputFilename = 'cacerts.pem') => {
const files = fs.readdirSync(folder);
const caCertFiles = files.filter((file) => path.extname(file) === '.pem');
const outputFile = fs.openSync(outputFilename, 'w');
caCertFiles.forEach((caCert) => {
const filePath = path.join(folder, caCert);
const fileContent = fs.readFileSync(filePath, 'utf8');
fs.appendFileSync(outputFile, fileContent + '\n');
});
};
const main = async () => {
concatCaCerts();
const indexJSON = JSON.parse(fs.readFileSync('index.json'));
indexJSON.forEach(entry => {
const result = child_process.execSync(`node ./scripts/add.js "${entry.path || entry.url}" "${entry.modelId || ''}"`, {
cwd: path.dirname(__dirname)
})
console.log(result.toString())
})
}
return main();