Couldn't set default admin username and password in config.json

Technical Support
  • In code src/install.js, it seems configure variables like admin:username , defaultTheme are loaded from config.json. But it seems there configure variables don't affect the setup results at all. How could I setup with a configured admin account and theme?

    {
         "url": "http://0.0.0.0:4567",
        "secret": "123456-eb70-4605-kkerg-720752bc4aca",
        "defaultTheme": "nodebb-theme-timuu",
        "setup": {
            "admin:username": "admin",
            "admin:password": "abcdefg",
            "admin:password:confirm": "abcdefg",
            "admin:email": "[email protected]"
        }
    }
    
  • $ ./nodebb setup --help
    
     Usage: setup [options] [config]
    
     Run the NodeBB setup script, or setup with an initial config
    
    
     Options:
    
      -h, --help output usage information
    

    You want to pass JSON text as the config. You can read a config file into an environmental variable and pass that as the config parameter:

    BASE_CONFIG=$(cat config.base.json)
    ./nodebb setup $BASE_CONFIG
    

    I think that's right anyways

  • @pitaj

    I have tried using the above command, but not succeeded..

    ./nodebb setup '{"url":"http://localhost:4567","secret":" 92b094a0-f72b-45d9-9640-243de540012d","database":"mongo","port":"4567","mongo":{"host":"127.0.0.1","port":27017,"username":"","password":"","database":"nodebb","uri":"mongodb://11.2.3.75:27017"},"setup":{"admin:username":"admin_vsv","admin:password":"Password@1","admin:password:confirm":"Test@123","admin:email":"[email protected]"}}'
    2021-01-06T10:44:19.246Z [6623] - info: NodeBB Setup Triggered via Command Line
    
    Welcome to NodeBB v1.13.3!
    
    This looks like a new installation, so you'll have to answer a few questions about your environment before we can proceed.
    Press enter to accept the default setting (shown in brackets).
    2021-01-06T10:44:19.253Z [6623] - error: Invalid json in nconf.get('setup'), ignoring setup values
    2021-01-06T10:44:19.254Z [6623] - error: Required values are missing for automated setup:
    2021-01-06T10:44:19.254Z [6623] - error:   admin:username
    2021-01-06T10:44:19.254Z [6623] - error:   admin:password
    2021-01-06T10:44:19.255Z [6623] - error:   admin:password:confirm
    2021-01-06T10:44:19.255Z [6623] - error:   admin:email
    
    
  • You might have to escape the json values, see here. I remember we had to escape the json like that for travis.

  • @baris
    Thanks for your quick response.

    I tried the below command

    ./nodebb app --setup="{\\\"url\\\":\\\"http:\\/\\/localhost:4567\\\",\\\"secret\\\":\\\" 92b094a0-f72b-45d9-9640-243de540012d\\\",\\\"database\\\":\\\"mongo\\\",\\\"port\\\":\\\"4567\\\",\\\"mongo\\\":{\\\"host\\\":\\\"127.0.0.1\\\",\\\"port\\\":27017,\\\"username\\\":\\\"\\\",\\\"password\\\":\\\"\\\",\\\"database\\\":\\\"nodebb\\\",\\\"uri\\\":\\\"mongodb:\\/\\/11.2.3.75:27017\\\"},\\\"setup\\\":{\\\"admin:username\\\":\\\"admin_vsv\\\",\\\"admin:password\\\":\\\"Password@1\\\",\\\"admin:password:confirm\\\":\\\"Test@123\\\",\\\"admin:email\\\":\\\"[email protected]\\\"}}"
    2021-01-06T15:38:22.528Z [24887] - info: Launching web installer on port 4567
    2021-01-06T15:38:24.048Z [24887] - info: Web installer listening on http://0.0.0.0:4567
    

    I got stuck at web installer. We have to manually feed the information again in web page http://0.0.0.0:4567

    But our requirement is we should able to setup through jenkins command shell.

    @PitaJ @julian

  • @vinu you want node app --setup, not ./nodebb app --setup

  • @pitaj I am getting

    vinu@tilap330-vinu:~/Projects/nodebb$ node app --setup="{\\\"url\\\":\\\"http:\\/\\/localhost:4567\\\",\\\"secret\\\":\\\" 92b094a0-f72b-45d9-9640-243de540012d\\\",\\\"database\\\":\\\"mongo\\\",\\\"port\\\":\\\"4567\\\",\\\"mongo\\\":{\\\"host\\\":\\\"127.0.0.1\\\",\\\"port\\\":27017,\\\"username\\\":\\\"\\\",\\\"password\\\":\\\"\\\",\\\"database\\\":\\\"nodebb\\\",\\\"uri\\\":\\\"mongodb:\\/\\/11.2.3.75:27017\\\"},\\\"setup\\\":{\\\"admin:username\\\":\\\"admin_vsv\\\",\\\"admin:password\\\":\\\"Password@1\\\",\\\"admin:password:confirm\\\":\\\"Test@123\\\",\\\"admin:email\\\":\\\"[email protected]\\\"}}"
    2021-01-06T16:45:09.311Z [undefined/31941] - info: NodeBB v1.13.3 Copyright (C) 2013-2021 NodeBB Inc.
    2021-01-06T16:45:09.312Z [undefined/31941] - info: This program comes with ABSOLUTELY NO WARRANTY.
    2021-01-06T16:45:09.313Z [undefined/31941] - info: This is free software, and you are welcome to redistribute it under certain conditions.
    2021-01-06T16:45:09.313Z [undefined/31941] - info: 
    2021-01-06T16:45:09.646Z [31941] - info: NodeBB Setup Triggered via Command Line
    
    Welcome to NodeBB v1.13.3!
    
    This looks like a new installation, so you'll have to answer a few questions about your environment before we can proceed.
    Press enter to accept the default setting (shown in brackets).
    2021-01-06T16:45:09.650Z [31941] - error: Invalid json in nconf.get('setup'), ignoring setup values
    URL used to access this NodeBB (http://localhost:4567) (node:31941) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
    (Use `node --trace-warnings ...` to show where the warning was created)
    
    
  • It says pretty clearly that the json you provided is invalid. I don't know what to tell you.

  • @pitaj Not sure what is the valid JSON to be added here.

    As per @baris comment as commented above, I started using json by escaping.

    I am using below JSON. Please correct me how can we use the below JSON in setup command

    {
        "url": "http://0.0.0.0:4567",
        "secret": "123456-eb70-4605-kkerg-720752bc4aca",
        "setup": {
            "admin:username": "adminvsv",
            "admin:password": "Password@123",
            "admin:password:confirm": "Password@123",
            "admin:email": "[email protected]"
        },
        "database": "mongo",
        "mongo": {
            "host": "127.0.0.1",
            "port": "27017",
            "username": "",
            "password": "",
            "database": "nodebb"
        }
    }
    
  • I think it's because you're escaping the forward-slashes. To make it easier, you can do this in your browser console to output what should go in the shell command:

    JSON.stringify(<obj>).replace(/"/g, '\\"')
    

    Let me know if that works for you

  • @PitaJ @vinu
    I am using the above command what you mention in the post for nodebb setup

    node app --setup="{\"url\":\"http://0.0.0.0:4567\",\"secret\":\"123456-eb70-4605-kkerg-720752bc4aca\",\"admin:username\":\"venkat\",\"admin:password\":\"Test@123\",\"admin:password:confirm\":\"Test@123\",\"admin:email\":\"[email protected]\",\"database\":\"mongo\",\"mongo\":{\"host\":\"127.0.0.1\",\"port\":\"27017\",\"username\":\"\",\"password\":\"\",\"database\":\"nodebb\"}}"
    

    but I am unable perform login what ever the login details adding in the json string. It is always giving invalid credentials.
    can you help me on that

  • @venkat what was the output of that command? NodeBB starts up fine?


Suggested Topics