HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Setting up Vanilla via cURL

LincLinc Detroit Admin

I'm trying to set up a Vanilla site from a bash prompt. I've tried lots of flags in lots of formats (using -F; joining the parameters together with ampersands; and so on) and I either get back the form in HTML with an error, or I get nothing at all. Here's what I tried last:

 read -p "Name: " SITE
 curl -d "Database-dot-Host=localhost" -d "Database-dot-Name=${SITE}" -d "Database-dot-User=root" -d "Database-dot-Password=" -d "Garden-dot-Title=${SITE}" -d "Email=lincoln%40vanillaforums.com" -d "Name=admin" -d "Password=admin" -d "PasswordMatch=admin" http://${SITE}.dev/index.php?p=/dashboard/setup

Any ideas how to get this thing to work? What am I missing?

Comments

  • I tried what you did. I get this.

    Failed to connect to the database with the username and password you entered. Did you mistype them? The database reported: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

    I suppose if I create the database first, it might work.

    what errors do you see in the html reported?

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • ToddTodd Chief Product Officer Vanilla Staff

    I don't know command line curl. I know you need to POST and not GET. Can you try writing this as a php script and do that from the command line?

  • you may have rip the transient key, curl does not automatically handle redirects check trailing slashes, etc.

    grep is your friend.

  • peregrineperegrine MVP
    edited July 2013

    here is what I did and it created vanilla.

    but i had to create the table first.

    I modified a bit what you had to point to where I wanted to go

    and put it in a text file called testfile

    read -p "Name: " SITE
    curl -d "Database-dot-Host=localhost" -d "Database-dot-Name=${SITE}" -d "Database-dot-User=root" -d "Database-dot-Password=mypass" -d "Garden-dot-Title=${SITE}" -d "Email=lincoln%40vanillaforums.com" -d "Name=admin" -d "Password=admin" -d "PasswordMatch=admin" http://localhost/${SITE}/index.php?p=/dashboard/setup
    

    I chmoded the config uploads and something else as standard.
    I created the database via phpmyadmin.

    I then ran the command as

    sh -x testfile

    and it completed and populated the database with tables. and properly created a config.php.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • and then i typed

    http://localhost/vanilla3/

    and it shows the discussion page and shows the discussion page as bam you've got a sweet forum.

    Not sure what you were trying to do, but as long as you create the database first.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited July 2013

    obviously if you didn't want to see html output you could redirect to dev/null

    note the password is the same password I used in database creation.

    but it created the following 2 users in the user table

    admin with lincolns email
    and system user

    this is the config it created.

        <?php if (!defined('APPLICATION')) exit();
    
        // Conversations
        $Configuration['Conversations']['Version'] = '2.1b1';
    
        // Database
        $Configuration['Database']['Name'] = 'vanilla3';
        $Configuration['Database']['Host'] = 'localhost';
        $Configuration['Database']['User'] = 'root';
        $Configuration['Database']['Password'] = 'mypass';
    
        // EnabledApplications
        $Configuration['EnabledApplications']['Conversations'] = 'conversations';
        $Configuration['EnabledApplications']['Vanilla'] = 'vanilla';
    
        // EnabledPlugins
        $Configuration['EnabledPlugins']['GettingStarted'] = 'GettingStarted';
        $Configuration['EnabledPlugins']['HtmLawed'] = 'HtmLawed';
    
        // Garden
        $Configuration['Garden']['Title'] = 'vanilla3';
        $Configuration['Garden']['Cookie']['Salt'] = '4BHDAKA1J2';
        $Configuration['Garden']['Cookie']['Domain'] = '';
        $Configuration['Garden']['Registration']['ConfirmEmail'] = TRUE;
        $Configuration['Garden']['Email']['SupportName'] = 'vanilla3';
        $Configuration['Garden']['Version'] = '2.1b1';
        $Configuration['Garden']['RewriteUrls'] = FALSE;
        $Configuration['Garden']['CanProcessImages'] = TRUE;
        $Configuration['Garden']['SystemUserID'] = '2';
        $Configuration['Garden']['Installed'] = TRUE;
    
        // Plugins
        $Configuration['Plugins']['GettingStarted']['Dashboard'] = '1';
    
        // Routes
        $Configuration['Routes']['DefaultController'] = 'discussions';
    
        // Vanilla
        $Configuration['Vanilla']['Version'] = '2.1b1';
    
        // Last edited by Unknown (127.0.0.1)2013-07-11 18:02:37
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • LincLinc Detroit Admin

    @peregrine Maybe it doesn't like the blank MySQL password field in mine? That's maddening that it's working as expected for you. I get no error, but then I go to the site and it throws me to the setup page. It makes a blank config.php and no database tables.

    Errors I've gotten have generally been related to malformed cURL requests as I was muddling thru the docs and trying different things. Perversely, I actually enjoy getting an error since it's a sign SOMETHING is actually happening.

  • LincLinc Detroit Admin

    @x00 said:
    you may have rip the transient key, curl does not automatically handle redirects check trailing slashes, etc.

    There's no transient key during setup because you have no user session. The redirect isn't required for setup either, I checked the code.

  • peregrineperegrine MVP
    edited July 2013

    maybe this will help.

    mind you everything I'm doing is from localhost on localhost. perhaps a remote system has different ways of reporting errors back.

    I'll post what I get with
    
    • no password and no database created via phpmyadmin
      everything on localhost

                 <div class="Messages Errors">
              <ul>
              <li>Failed to connect to the database with the username and password you entered. Did you mistype them? The database reported: <code>SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO)</code></li>
              </ul>
      

      with database created - no password

      <li>Failed to connect to the database with the username and password you entered. Did you mistype them? The database reported: <code>SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO)</code></li>
      </ul>
      

      • another scenario

        create vanilla3 table with phpmyadmin
        create sql user for vanilla3 via phpmyadmin with NO password.

        CREATE USER 'vanilla3pass'@'%';
        GRANT USAGE ON * . * TO 'vanilla3pass'@'%' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
        GRANT ALL PRIVILEGES ON vanilla3 . * TO 'vanilla3pass'@'%';

      testfile contents:

           read -p "Name: " SITE
          curl -d "Database-dot-Host=localhost" -d "Database-dot-Name=${SITE}" -d "Database-dot-User=vanilla3pass" -d "Database-dot-Password=" -d "Garden-dot-Title=${SITE}" -d "Email=lincoln%40vanillaforums.com" -d "Name=admin" -d "Password=admin" -d "PasswordMatch=admin" http://localhost/${SITE}/index.php?p=/dashboard/setup
      

      execution:

      sh -xv testfile
      
               read -p "Name: " SITE
      + read -p Name:  SITE
      Name: vanilla3
          curl -d "Database-dot-Host=localhost" -d "Database-dot-Name=${SITE}" -d "Database-dot-User=vanilla3pass" -d "Database-dot-Password=" -d "Garden-dot-Title=${SITE}" -d "Email=lincoln%40vanillaforums.com" -d "Name=admin" -d "Password=admin" -d "PasswordMatch=admin" http://localhost/${SITE}/index.php?p=/dashboard/setup
      + curl -d Database-dot-Host=localhost -d Database-dot-Name=vanilla3 -d Database-dot-User=vanilla3pass -d Database-dot-Password= -d Garden-dot-Title=vanilla3 -d Email=lincoln%40vanillaforums.com -d Name=admin -d Password=admin -d PasswordMatch=admin http://localhost/vanilla3/index.php?p=/dashboard/setup
      

      results: perfect setup

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited July 2013

    very cool script you wrote. I hope you get it working for yourself. i certainly like it.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • LincLinc Detroit Admin

    I figured it out. You can't post to the form before you've requested the form. I added a curl to the page before posting to it, works great now.

     # forum setup
     curl -s http://${SITE}.dev/index.php?p=/dashboard/setup > /dev/null
     curl -d "Database-dot-Host=localhost" -d "Database-dot-Name=${SITE}" -d "Database-dot-User=root" -d "Database-dot-Password=" -d "Garden-dot-Title=${SITE}" -d "Email=lincoln%40vanillaforums.com" -d "Name=admin" -d "Password=admin" -d "PasswordMatch=admin" http://${SITE}.dev/index.php?p=/dashboard/setup
    
  • businessdadbusinessdad Stealth contributor MVP
    edited July 2013

    @Lincoln said:
    I figured it out. You can't post to the form before you've requested the form.

    Actually, I think you can. I did the same in my ANT script that I use to run tests against my Vanilla plugins, and I use CURL to "trick" Vanilla into configuring a brand new website every time. I just run a single CURL command, posting to the /setup URL, and it works.

    Note: the CURL is executed using an exec task, which, I think, runs the command line tool installed on Linux.

    Extracted from ANT file

            <exec executable="curl">
                <!-- Unknown parameter, passed because it exists in original form -->
                <arg line="--data Configuration/hpt=&quot;&quot;"/>
                <arg line="--data Configuration/Database-dot-Host=&quot;${mysql.address}&quot;"/>
                <arg line="--data Configuration/Database-dot-Name=&quot;${env.DB_NAME}&quot;"/>
                <arg line="--data Configuration/Database-dot-User=&quot;${vanilla_db_uid}&quot;"/>
                <arg line="--data Configuration/Database-dot-Password=&quot;${vanilla_db_pwd}&quot;"/>
                <arg line="--data Configuration/Garden-dot-Title=&quot;${website_title}&quot;"/>
                <arg line="--data Configuration/Email=&quot;${admin_email}&quot;"/>
                <arg line="--data Configuration/Name=&quot;${admin_uid}&quot;"/>
                <arg line="--data Configuration/Password=&quot;${admin_pwd}&quot;"/>
                <arg line="--data Configuration/PasswordMatch=&quot;${admin_pwd}&quot;"/>
                <!-- The following is just the Submit button, passed as-is from original form -->
                <arg line="--data Configuration/Continue_%26rarr%3B=&quot;Continue .&quot;"/>
                <arg line="--location" />
                <arg line="--output ${curl_output_dir}/vanilla_install_result.html" />
                <arg line="&quot;${vanilla_url}/index.php?p=/dashboard/setup&quot;" />
            </exec>
    
  • LincLinc Detroit Admin

    @businessdad said:
    Actually, I think you can.

    Well, tell that to my localhost! :P

  • businessdadbusinessdad Stealth contributor MVP
    edited July 2013

    @Lincoln said:
    Well, tell that to my localhost! :P

    My ANT script runs against a localhost too. My localhost is better than your localhost. :P
    Maybe it's a Buddhist localhost, more tolerant. :D

  • LincLinc Detroit Admin

    @businessdad said:
    Maybe it's a Buddhist localhost, more tolerant. :D

    You're saying this to the co-owner of NewBuddhist.com. 0.o

  • businessdadbusinessdad Stealth contributor MVP

    @Lincoln said:
    You're saying this to the co-owner of NewBuddhist.com. 0.o

    Well, then my Buddhist localhost is better than your Buddhist localhost. A little bit more nonsense and we can go straight into the Twilight Zone...

  • x00x00 MVP
    edited July 2013

    @Lincoln said:
    I figured it out. You can't post to the form before you've requested the form. I added a curl to the page before posting to it, works great now.

     # forum setup
     curl -s http://${SITE}.dev/index.php?p=/dashboard/setup > /dev/null
     curl -d "Database-dot-Host=localhost" -d "Database-dot-Name=${SITE}" -d "Database-dot-User=root" -d "Database-dot-Password=" -d "Garden-dot-Title=${SITE}" -d "Email=lincoln%40vanillaforums.com" -d "Name=admin" -d "Password=admin" -d "PasswordMatch=admin" http://${SITE}.dev/index.php?p=/dashboard/setup
    

    I can confirm that prerequisites are required in newer versions of vanilla (2.1), it worked in older versions.

    alternative to

    curl -s http://${SITE}.dev/index.php?p=/dashboard/setup > /dev/null

    is to create a blank conf/config.php file with the correct permissions, ideally assigned to the web user. Then it works first time.

    Hope that helps.

    grep is your friend.

  • businessdadbusinessdad Stealth contributor MVP

    @x00 said:
    I can confirm that prerequisites are required in newer versions of vanilla (2.1), it worked in older versions.

    A-ha! Now that I think about it, I only run tests against 2.0.x, which explains why it works. Good finding.

  • LincLinc Detroit Admin

    Thanks for proving I'm not crazy @x00 ;)

Sign In or Register to comment.