Skip to content

Commit

Permalink
✨ Allow SSL Email to be provided, skip prompts
Browse files Browse the repository at this point in the history
refs TryGhost#194

- If --sslemail is provided, use that instead of prompting
- Makes it easier to call ghost programmatically
  • Loading branch information
ErisDS committed May 3, 2017
1 parent 89df020 commit d62154e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/commands/config/advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ module.exports = [{
name: 'dbname',
description: 'Database name',
configPath: 'database.connection.database'
}, {
name: 'sslemail',
description: 'SSL email address',
configPath: 'ssl.email'
}, {
name: 'auth',
description: 'Type of authentication to use',
Expand Down
15 changes: 12 additions & 3 deletions lib/services/nginx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,20 @@ class NginxService extends BaseService {
});
}

let answers;
let ghostExec = process.argv.slice(0,2).join(' ');
let answerPromise;
let answers;

if (this.config.values.ssl && this.config.values.ssl.email) {
answerPromise = Promise.resolve({
ssl: true,
email: this.config.values.ssl.email
});
} else {
answerPromise = this.ui.prompt(prompts);
}

return this.ui.prompt(prompts).then((_answers) => {
return answerPromise.then((_answers) => {
answers = _answers;

return this.ui.noSpin(execa.shell(`sudo ${ghostExec} service nginx-conf${!answers.ssl ? ' no-ssl' : ''}`, {stdio: 'inherit'})).catch((error) => {
Expand Down Expand Up @@ -163,7 +173,6 @@ class NginxService extends BaseService {
// add listen directives
https._add('listen', '443 ssl http2');
https._add('listen', '[::]:443 ssl http2');
https._add('server_name', this.parsedUrl.hostname);
// add ssl cert directives
https._add('ssl_certificate', `/etc/letsencrypt/live/${this.parsedUrl.hostname}/fullchain.pem`);
https._add('ssl_certificate_key', `/etc/letsencrypt/live/${this.parsedUrl.hostname}/privkey.pem`);
Expand Down

0 comments on commit d62154e

Please sign in to comment.