Skip to content

Commit 7875262

Browse files
authored
also allow UI upgrade if ioBroker is not running as systemd (eg WSL) (#2353)
- closes #2352
1 parent 9599f24 commit 7875262

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

packages/common/src/lib/common/tools.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4013,4 +4013,16 @@ export function ensureDNSOrder(): void {
40134013
setDefaultResultOrder(dnsOrder);
40144014
}
40154015

4016+
/**
4017+
* Determine if ioBroker is installed as systemd service
4018+
*/
4019+
export async function isIoBrokerInstalledAsSystemd(): Promise<boolean> {
4020+
try {
4021+
const res = await execAsync('systemctl status iobroker');
4022+
return !res.stderr;
4023+
} catch {
4024+
return false;
4025+
}
4026+
}
4027+
40164028
export * from './maybeCallback';

packages/controller/src/main.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3166,7 +3166,7 @@ async function processMessage(msg: ioBroker.SendableMessage): Promise<null | voi
31663166
const { version, adminInstance } = msg.message;
31673167

31683168
logger.info(`${hostLogPrefix} Controller will upgrade itself to version ${version}`);
3169-
startUpgradeManager({ version, adminInstance });
3169+
await startUpgradeManager({ version, adminInstance });
31703170

31713171
if (msg.callback) {
31723172
sendTo(msg.from, msg.command, { result: true }, msg.callback);
@@ -6080,17 +6080,14 @@ async function _getNumberOfInstances(): Promise<
60806080
*
60816081
* @param options Arguments passed to the UpgradeManager process
60826082
*/
6083-
function startUpgradeManager(options: UpgradeArguments): void {
6083+
async function startUpgradeManager(options: UpgradeArguments): Promise<void> {
60846084
const { version, adminInstance } = options;
60856085
const upgradeProcessPath = require.resolve('./lib/upgradeManager');
60866086
let upgradeProcess: cp.ChildProcess;
60876087

6088-
if (tools.isDocker()) {
6089-
upgradeProcess = spawn(process.execPath, [upgradeProcessPath, version, adminInstance.toString()], {
6090-
detached: true,
6091-
stdio: 'ignore'
6092-
});
6093-
} else {
6088+
const isSystemd = await tools.isIoBrokerInstalledAsSystemd();
6089+
6090+
if (isSystemd) {
60946091
upgradeProcess = spawn(
60956092
'sudo',
60966093
[
@@ -6106,6 +6103,11 @@ function startUpgradeManager(options: UpgradeArguments): void {
61066103
stdio: 'ignore'
61076104
}
61086105
);
6106+
} else {
6107+
upgradeProcess = spawn(process.execPath, [upgradeProcessPath, version, adminInstance.toString()], {
6108+
detached: true,
6109+
stdio: 'ignore'
6110+
});
61096111
}
61106112

61116113
upgradeProcess.unref();

0 commit comments

Comments
 (0)