forked from TryGhost/Ghost-CLI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(systemd): improve setup checks of extension and process manager
closes TryGhost#291 - add function to double check that linux-user has been run - make help messaging more clear
- Loading branch information
Showing
3 changed files
with
44 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const execa = require('execa'); | ||
|
||
/** | ||
* Helper function used by both the extension setup method | ||
* and the systemd process manager | ||
*/ | ||
module.exports = function getUid(dir) { | ||
try { | ||
let uid = execa.shellSync('id -u ghost').stdout; | ||
let stat = fs.lstatSync(dir); | ||
|
||
if (stat.uid !== uid) { | ||
// Ghost user is not the owner of this folder, return null | ||
return null; | ||
} | ||
|
||
return uid; | ||
} catch (e) { | ||
if (!e.message.match(/no such user/)) { | ||
throw e; | ||
} | ||
|
||
return null; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters