mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-11 12:01:40 +00:00
Create config.txt if there isn't one already
Change-type: patch Signed-off-by: Theodor Gherzan <theodor@balena.io>
This commit is contained in:
parent
c46c1e04d3
commit
1570fd424b
@ -106,12 +106,20 @@ export class RPiConfigBackend extends DeviceConfigBackend {
|
|||||||
return _.startsWith(deviceType, 'raspberry') || deviceType === 'fincm3';
|
return _.startsWith(deviceType, 'raspberry') || deviceType === 'fincm3';
|
||||||
}
|
}
|
||||||
|
|
||||||
public getBootConfig(): Promise<ConfigOptions> {
|
public async getBootConfig(): Promise<ConfigOptions> {
|
||||||
return Promise.resolve(
|
let configContents = '';
|
||||||
fs.readFile(RPiConfigBackend.bootConfigPath, 'utf-8'),
|
|
||||||
).then(confStr => {
|
if (await fs.exists(RPiConfigBackend.bootConfigPath)) {
|
||||||
|
configContents = await fs.readFile(
|
||||||
|
RPiConfigBackend.bootConfigPath,
|
||||||
|
'utf-8',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await fs.writeFile(RPiConfigBackend.bootConfigPath, '');
|
||||||
|
}
|
||||||
|
|
||||||
const conf: ConfigOptions = {};
|
const conf: ConfigOptions = {};
|
||||||
const configStatements = confStr.split(/\r?\n/);
|
const configStatements = configContents.split(/\r?\n/);
|
||||||
|
|
||||||
for (const configStr of configStatements) {
|
for (const configStr of configStatements) {
|
||||||
// Don't show warnings for comments and empty lines
|
// Don't show warnings for comments and empty lines
|
||||||
@ -150,7 +158,6 @@ export class RPiConfigBackend extends DeviceConfigBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return conf;
|
return conf;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public setBootConfig(opts: ConfigOptions): Promise<void> {
|
public setBootConfig(opts: ConfigOptions): Promise<void> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user