Skip to content

Commit

Permalink
feat(systemd): save systemd file to /etc/systemd, not /lib/systemd
Browse files Browse the repository at this point in the history
closes TryGhost#414
- change location to /etc/systemd/system
- ensure uninstall will delete from either location
  • Loading branch information
acburdine committed Aug 4, 2017
1 parent 3f6d8cc commit 3da4fc7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions extensions/systemd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SystemdExtension extends cli.Extension {
user: uid,
environment: this.system.environment,
ghost_exec_path: process.argv.slice(0,2).join(' ')
}), 'systemd service', serviceFilename, '/lib/systemd/system').then((generated) => {
}), 'systemd service', serviceFilename, '/etc/systemd/system').then((generated) => {
if (!generated) {
this.ui.log('Systemd unit file not generated', 'yellow');
return;
Expand All @@ -49,12 +49,17 @@ class SystemdExtension extends cli.Extension {
return;
}

let serviceFilename = `/lib/systemd/system/ghost_${instance.name}.service`;
let serviceFilename = `/etc/systemd/system/ghost_${instance.name}.service`;
let oldServiceFilename = `/lib/systemd/system/ghost_${instance.name}.service`;

if (fs.existsSync(serviceFilename)) {
return this.ui.sudo(`rm ${serviceFilename}`).catch(
() => Promise.reject(new cli.errors.SystemError('Systemd service file link could not be removed, you will need to do this manually.'))
);
} else if (fs.existsSync(oldServiceFilename)) {
return this.ui.sudo(`rm ${oldServiceFilename}`).catch(
() => Promise.reject(new cli.errors.SystemError('Systemd service file link could not be removed, you will need to do this manually.'))
);
}
}
}
Expand Down

0 comments on commit 3da4fc7

Please sign in to comment.