cyphernodeconf can take password from env for automatic lunanode setup

This commit is contained in:
jash
2018-10-21 00:02:12 +02:00
committed by kexkey
parent c0d439da8d
commit 5d29cbc0f7
2 changed files with 21 additions and 11 deletions

7
dist/setup.sh vendored
View File

@@ -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
}

View File

@@ -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();