mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 13:47:54 +00:00
Merge pull request #1970 from balena-os/1968-read-hostname-from-config-or-container-etc
Read hostname from config.json with container /etc/hostname as backup
This commit is contained in:
commit
6d6f09eb59
@ -1,6 +1,5 @@
|
||||
import * as _ from 'lodash';
|
||||
import { promises as fs } from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
import Network from './network';
|
||||
import Volume from './volume';
|
||||
@ -742,7 +741,7 @@ export class App {
|
||||
opts,
|
||||
supervisorApiHost,
|
||||
hostPathExists,
|
||||
hostnameOnHost,
|
||||
hostname,
|
||||
] = await Promise.all([
|
||||
config.get('extendedEnvOptions'),
|
||||
dockerUtils
|
||||
@ -752,20 +751,17 @@ export class App {
|
||||
firmware: await pathExistsOnHost('/lib/firmware'),
|
||||
modules: await pathExistsOnHost('/lib/modules'),
|
||||
}))(),
|
||||
(async () =>
|
||||
_.trim(
|
||||
await fs.readFile(
|
||||
path.join(constants.rootMountPoint, '/etc/hostname'),
|
||||
'utf8',
|
||||
),
|
||||
))(),
|
||||
(
|
||||
(await config.get('hostname')) ??
|
||||
(await fs.readFile('/etc/hostname', 'utf-8'))
|
||||
).trim(),
|
||||
]);
|
||||
|
||||
const svcOpts = {
|
||||
appName: app.name,
|
||||
supervisorApiHost,
|
||||
hostPathExists,
|
||||
hostnameOnHost,
|
||||
hostname,
|
||||
...opts,
|
||||
};
|
||||
|
||||
|
@ -300,7 +300,7 @@ export class Service {
|
||||
|
||||
// Any other special case handling
|
||||
if (config.networkMode === 'host' && !config.hostname) {
|
||||
config.hostname = options.hostnameOnHost;
|
||||
config.hostname = options.hostname;
|
||||
}
|
||||
config.restart = ComposeUtils.createRestartPolicy(config.restart);
|
||||
config.command = ComposeUtils.getCommand(config.command, options.imageInfo);
|
||||
|
@ -327,7 +327,7 @@ export interface DeviceMetadata {
|
||||
apiSecret: string;
|
||||
supervisorApiHost: string;
|
||||
osVersion: string;
|
||||
hostnameOnHost: string;
|
||||
hostname: string;
|
||||
hostPathExists: {
|
||||
modules: boolean;
|
||||
firmware: boolean;
|
||||
|
@ -90,7 +90,7 @@
|
||||
"firmware": true,
|
||||
"modules": true
|
||||
},
|
||||
"hostnameOnHost": "7dadabd",
|
||||
"hostname": "7dadabd",
|
||||
"uuid": "a7feb967fac7f559ccf2a006a36bcf5d",
|
||||
"listenPort": "48484",
|
||||
"name": "Office",
|
||||
|
@ -116,7 +116,7 @@
|
||||
"firmware": true,
|
||||
"modules": true
|
||||
},
|
||||
"hostnameOnHost": "7dadabd",
|
||||
"hostname": "7dadabd",
|
||||
"uuid": "7dadabd4edec3067948d5952c2f2f26f",
|
||||
"listenPort": "48484",
|
||||
"name": "Office",
|
||||
|
@ -116,7 +116,7 @@
|
||||
"firmware": true,
|
||||
"modules": true
|
||||
},
|
||||
"hostnameOnHost": "7dadabd",
|
||||
"hostname": "7dadabd",
|
||||
"uuid": "7dadabd4edec3067948d5952c2f2f26f",
|
||||
"listenPort": "48484",
|
||||
"name": "Office",
|
||||
|
Loading…
Reference in New Issue
Block a user