mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-22 18:22:41 +00:00
Rename systemd.ts to dbus.ts
This is because it's more general, and just provides methods which act over dbus. Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
aa3d02b3a9
commit
68936a10a8
@ -8,8 +8,8 @@ import Logger from './logger';
|
|||||||
|
|
||||||
import { ConfigOptions, DeviceConfigBackend } from './config/backend';
|
import { ConfigOptions, DeviceConfigBackend } from './config/backend';
|
||||||
import * as configUtils from './config/utils';
|
import * as configUtils from './config/utils';
|
||||||
|
import * as dbus from './lib/dbus';
|
||||||
import { UnitNotLoadedError } from './lib/errors';
|
import { UnitNotLoadedError } from './lib/errors';
|
||||||
import * as systemd from './lib/systemd';
|
|
||||||
import { EnvVarObject } from './lib/types';
|
import { EnvVarObject } from './lib/types';
|
||||||
import { checkInt, checkTruthy } from './lib/validation';
|
import { checkInt, checkTruthy } from './lib/validation';
|
||||||
import { DeviceStatus } from './types/state';
|
import { DeviceStatus } from './types/state';
|
||||||
@ -573,7 +573,7 @@ export class DeviceConfig {
|
|||||||
|
|
||||||
private async getVPNEnabled(): Promise<boolean> {
|
private async getVPNEnabled(): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const activeState = await systemd.serviceActiveState(vpnServiceName);
|
const activeState = await dbus.serviceActiveState(vpnServiceName);
|
||||||
return !_.includes(['inactive', 'deactivating'], activeState);
|
return !_.includes(['inactive', 'deactivating'], activeState);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (UnitNotLoadedError(e)) {
|
if (UnitNotLoadedError(e)) {
|
||||||
@ -588,9 +588,9 @@ export class DeviceConfig {
|
|||||||
const enable = v != null ? v : true;
|
const enable = v != null ? v : true;
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
await systemd.startService(vpnServiceName);
|
await dbus.startService(vpnServiceName);
|
||||||
} else {
|
} else {
|
||||||
await systemd.stopService(vpnServiceName);
|
await dbus.stopService(vpnServiceName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ import { loadTargetFromFile } from './device-state/preload';
|
|||||||
import * as globalEventBus from './event-bus';
|
import * as globalEventBus from './event-bus';
|
||||||
import * as hostConfig from './host-config';
|
import * as hostConfig from './host-config';
|
||||||
import constants = require('./lib/constants');
|
import constants = require('./lib/constants');
|
||||||
|
import * as dbus from './lib/dbus';
|
||||||
import { InternalInconsistencyError, UpdatesLockedError } from './lib/errors';
|
import { InternalInconsistencyError, UpdatesLockedError } from './lib/errors';
|
||||||
import * as systemd from './lib/systemd';
|
|
||||||
import * as updateLock from './lib/update-lock';
|
import * as updateLock from './lib/update-lock';
|
||||||
import * as validation from './lib/validation';
|
import * as validation from './lib/validation';
|
||||||
import * as network from './network';
|
import * as network from './network';
|
||||||
@ -555,7 +555,7 @@ export class DeviceState extends (EventEmitter as new () => DeviceStateEventEmit
|
|||||||
private async reboot(force?: boolean, skipLock?: boolean) {
|
private async reboot(force?: boolean, skipLock?: boolean) {
|
||||||
await this.applications.stopAll({ force, skipLock });
|
await this.applications.stopAll({ force, skipLock });
|
||||||
this.logger.logSystemMessage('Rebooting', {}, 'Reboot');
|
this.logger.logSystemMessage('Rebooting', {}, 'Reboot');
|
||||||
const reboot = await systemd.reboot();
|
const reboot = await dbus.reboot();
|
||||||
this.shuttingDown = true;
|
this.shuttingDown = true;
|
||||||
this.emitAsync('shutdown', undefined);
|
this.emitAsync('shutdown', undefined);
|
||||||
return reboot;
|
return reboot;
|
||||||
@ -564,7 +564,7 @@ export class DeviceState extends (EventEmitter as new () => DeviceStateEventEmit
|
|||||||
private async shutdown(force?: boolean, skipLock?: boolean) {
|
private async shutdown(force?: boolean, skipLock?: boolean) {
|
||||||
await this.applications.stopAll({ force, skipLock });
|
await this.applications.stopAll({ force, skipLock });
|
||||||
this.logger.logSystemMessage('Shutting down', {}, 'Shutdown');
|
this.logger.logSystemMessage('Shutting down', {}, 'Shutdown');
|
||||||
const shutdown = await systemd.shutdown();
|
const shutdown = await dbus.shutdown();
|
||||||
this.shuttingDown = true;
|
this.shuttingDown = true;
|
||||||
this.emitAsync('shutdown', undefined);
|
this.emitAsync('shutdown', undefined);
|
||||||
return shutdown;
|
return shutdown;
|
||||||
|
@ -7,9 +7,9 @@ import * as path from 'path';
|
|||||||
|
|
||||||
import Config from './config';
|
import Config from './config';
|
||||||
import * as constants from './lib/constants';
|
import * as constants from './lib/constants';
|
||||||
|
import * as dbus from './lib/dbus';
|
||||||
import { ENOENT } from './lib/errors';
|
import { ENOENT } from './lib/errors';
|
||||||
import { writeFileAtomic } from './lib/fs-utils';
|
import { writeFileAtomic } from './lib/fs-utils';
|
||||||
import * as systemd from './lib/systemd';
|
|
||||||
|
|
||||||
const mkdirp = Bluebird.promisify(mkdirCb) as (
|
const mkdirp = Bluebird.promisify(mkdirCb) as (
|
||||||
path: string,
|
path: string,
|
||||||
@ -140,8 +140,8 @@ async function setProxy(maybeConf: ProxyConfig | null): Promise<void> {
|
|||||||
await writeFileAtomic(redsocksConfPath, redsocksConf);
|
await writeFileAtomic(redsocksConfPath, redsocksConf);
|
||||||
}
|
}
|
||||||
|
|
||||||
await systemd.restartService('resin-proxy-config');
|
await dbus.restartService('resin-proxy-config');
|
||||||
await systemd.restartService('redsocks');
|
await dbus.restartService('redsocks');
|
||||||
}
|
}
|
||||||
|
|
||||||
const hostnamePath = path.join(constants.rootMountPoint, '/etc/hostname');
|
const hostnamePath = path.join(constants.rootMountPoint, '/etc/hostname');
|
||||||
@ -152,7 +152,7 @@ async function readHostname() {
|
|||||||
|
|
||||||
async function setHostname(val: string, configModel: Config) {
|
async function setHostname(val: string, configModel: Config) {
|
||||||
await configModel.set({ hostname: val });
|
await configModel.set({ hostname: val });
|
||||||
await systemd.restartService('resin-hostname');
|
await dbus.restartService('resin-hostname');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't use async/await here to maintain the bluebird
|
// Don't use async/await here to maintain the bluebird
|
||||||
|
Loading…
x
Reference in New Issue
Block a user