From 5d29cbc0f7606aaeddfec252c3087f6b05352ba3 Mon Sep 17 00:00:00 2001 From: jash Date: Sun, 21 Oct 2018 00:02:12 +0200 Subject: [PATCH] cyphernodeconf can take password from env for automatic lunanode setup --- dist/setup.sh | 7 +++++- .../generators/app/index.js | 25 +++++++++++-------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/dist/setup.sh b/dist/setup.sh index fb5aaac..5415707 100755 --- a/dist/setup.sh +++ b/dist/setup.sh @@ -135,9 +135,14 @@ configure() { clear && echo "Thinking..." fi + PW_ENV='' + if [[ $CFG_PASSWORD ]]; then + PW_ENV=" -e CFG_PASSWORD=$CFG_PASSWORD" + fi + # configure features of cyphernode docker run -v $current_path:/data \ - --log-driver=none\ + --log-driver=none$PW_ENV \ --rm -it cyphernodeconf:latest $(id -u):$(id -g) yo --no-insight cyphernode $recreate } diff --git a/install/generator-cyphernode/generators/app/index.js b/install/generator-cyphernode/generators/app/index.js index 727ec00..6c4737b 100644 --- a/install/generator-cyphernode/generators/app/index.js +++ b/install/generator-cyphernode/generators/app/index.js @@ -81,16 +81,21 @@ module.exports = class extends Generator { async _initConfig() { if( fs.existsSync(this.destinationPath('config.7z')) ) { let r = {}; - while( !r.password ) { - r = await this.prompt([{ - type: 'password', - name: 'password', - message: chalk.bold.blue('Enter your configuration password?'), - filter: this._trimFilter - }]); + + if( process.env.CFG_PASSWORD ) { + this.configurationPassword = process.env.CFG_PASSWORD; + } else { + process.stdout.write(reset); + while( !r.password ) { + r = await this.prompt([{ + type: 'password', + name: 'password', + message: chalk.bold.blue('Enter your configuration password?'), + filter: this._trimFilter + }]); + } + this.configurationPassword = r.password; } - - this.configurationPassword = r.password; const archive = new Archive( this.destinationPath('config.7z'), this.configurationPassword ); @@ -121,6 +126,7 @@ module.exports = class extends Generator { } else { let r = {}; + process.stdout.write(reset); while( !r.password0 || !r.password1 || r.password0 !== r.password1 ) { if( r.password0 && r.password1 && r.password0 !== r.password1 ) { @@ -152,7 +158,6 @@ module.exports = class extends Generator { async prompting() { - process.stdout.write(reset); await this._initConfig(); await sleep(1000); await splash();