mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
When `openclaw update` regenerates the systemd service file, any user customizations to ExecStart (e.g. proxychains4 wrapper) are silently lost. Now the existing unit file is copied to `.bak` before writing the new one, so users can restore their customizations. The backup path is printed in the install output so users are aware. Co-authored-by: echoVic <AkiraVic@outlook.com>
This commit is contained in:
@@ -193,6 +193,18 @@ export async function installSystemdService({
|
||||
|
||||
const unitPath = resolveSystemdUnitPath(env);
|
||||
await fs.mkdir(path.dirname(unitPath), { recursive: true });
|
||||
|
||||
// Preserve user customizations: back up existing unit file before overwriting.
|
||||
let backedUp = false;
|
||||
try {
|
||||
await fs.access(unitPath);
|
||||
const backupPath = `${unitPath}.bak`;
|
||||
await fs.copyFile(unitPath, backupPath);
|
||||
backedUp = true;
|
||||
} catch {
|
||||
// File does not exist yet — nothing to back up.
|
||||
}
|
||||
|
||||
const serviceDescription = resolveGatewayServiceDescription({ env, environment, description });
|
||||
const unit = buildSystemdUnit({
|
||||
description: serviceDescription,
|
||||
@@ -227,6 +239,14 @@ export async function installSystemdService({
|
||||
label: "Installed systemd service",
|
||||
value: unitPath,
|
||||
},
|
||||
...(backedUp
|
||||
? [
|
||||
{
|
||||
label: "Previous unit backed up to",
|
||||
value: `${unitPath}.bak`,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
],
|
||||
{ leadingBlankLine: true },
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user