Skip to content

Commit

Permalink
fix(linux): fix ghost user setup permissions (#296)
Browse files Browse the repository at this point in the history
closes #290
- change ownership of content directory only
- symlink casper to the current installation
  • Loading branch information
sebgie authored and acburdine committed Jul 6, 2017
1 parent 61f1ed0 commit ba54099
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 33 deletions.
14 changes: 3 additions & 11 deletions extensions/linux/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const os = require('os');
const execa = require('execa');
const path = require('path');

const cli = require('../../lib');

Expand Down Expand Up @@ -36,17 +37,8 @@ class LinuxExtension extends cli.Extension {
skip: () => userExists,
task: () => this.ui.sudo('useradd --system --user-group ghost')
}, {
title: 'Changing directory permissions',
task: () => this.ui.sudo(`chown -R ghost:ghost ${ctx.instance.dir}`)
}, {
title: 'Adding current user to ghost group',
skip: () => userExists,
task: (ctx) => {
return execa.shell('id -un').then((result) => {
ctx.currentuser = result.stdout;
return this.ui.sudo(`gpasswd --add ${ctx.currentuser} ghost`);
});
}
title: 'Changing content directory permissions',
task: () => this.ui.sudo(`chown -R ghost:ghost ${path.join(ctx.instance.dir, 'content')}`)
}], false);
}
}
Expand Down
15 changes: 8 additions & 7 deletions lib/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ class InstallCommand extends Command {
}, {
title: 'Moving files',
task: () => this.ui.listr([{
title: 'Summoning Casper',
task: this.casper
}, {
title: 'Linking things',
task: this.link.bind(this)
}], false, {concurrent: true})
}, {
title: 'Summoning Casper',
task: this.casper
}], false)
}], {
version: version,
cliVersion: this.cliVersion
Expand All @@ -92,9 +92,10 @@ class InstallCommand extends Command {
});
}

casper(ctx) {
return fs.move(
path.join(ctx.installPath, 'content', 'themes', 'casper'),
casper() {
// Create a symlink to the theme from the current version
return symlinkSync(
path.join(process.cwd(), 'current', 'content', 'themes', 'casper'),
path.join(process.cwd(), 'content', 'themes', 'casper')
);
}
Expand Down
15 changes: 0 additions & 15 deletions lib/commands/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,6 @@ class UpdateCommand extends Command {
}, {
title: 'Linking things',
task: this.link
}, {
title: 'Installing new version of Casper',
skip: (ctx) => ctx.rollback,
task: (ctx, task) => {
let casperPath = path.join(process.cwd(), 'content', 'themes', 'casper');

if (!fs.existsSync(casperPath)) {
return task.skip();
}

return fs.remove(casperPath).then(() => fs.move(
path.join(ctx.installPath, 'content', 'themes', 'casper'),
casperPath
));
}
}, {
title: 'Running database migrations',
skip: (ctx) => ctx.rollback,
Expand Down

0 comments on commit ba54099

Please sign in to comment.