---
keywords:
    OVH_MODULE_LANGUAGE:    $ENV{moduleLangUnderscore}
    OVH_MODULE_DOMAIN:      $ENV{moduleDomain}
    OVH_COUNTRY:            $ENV{moduleLang}
    OVH_ADMIN_PASSWORD:     $ENV{moduleAdminPassword}
    OVH_ADMIN_EMAIL:        $ENV{userEmail}
    OVH_USER_PATH:          $ENV{userPath}
    OVH_MODULE_ADMIN_PATH:  wp-admin/
    OVH_MODULE_ADMIN_NAME:  $ENV{moduleAdminName}
    OVH_MODULE_FOLDER:      $ENV{moduleFolder}
    OVH_SALT_1:             $RAND{CHAR,60}
    OVH_SALT_2:             $RAND{CHAR,60}
    OVH_SALT_3:             $RAND{CHAR,60}
    OVH_SALT_4:             $RAND{CHAR,60}
    OVH_SALT_5:             $RAND{CHAR,60}
    OVH_SALT_6:             $RAND{CHAR,60}
    OVH_SALT_7:             $RAND{CHAR,60}
    OVH_SALT_8:             $RAND{CHAR,60}
    OVH_MODULE_URL:         $ENV{moduleUrl}
    OVH_TEMP_FOLDER:        $ENV{tempFolder}

dependencies:
    - types:        [ 'mysql' ]
      mandatory:    true
      keywords:
        OVH_DB_SERVER:      server
        OVH_DB_PORT:        port
        OVH_DB_USER:        user
        OVH_DB_PASSWORD:    password
        OVH_DB_NAME:        name
        OVH_DB_PREFIX:      prefix

fallbackFiles:
    OVH_DB_SERVER:
        files:  [ 'wp-config.php' ]
        expect: define\('DB_HOST', '(.*?):[0-9]*'\);
    OVH_DB_PORT:
        files:  [ 'wp-config.php' ]
        expect: define\('DB_HOST', '.*?:([0-9]*)'\);
    OVH_DB_USER:
        files:  [ 'wp-config.php' ]
        expect: define\('DB_USER', '(.*?)'\);
    OVH_DB_PASSWORD:
        files:  [ 'wp-config.php' ]
        expect: define\('DB_PASSWORD', '(.*?)'\);
    OVH_DB_NAME:
        files:  [ 'wp-config.php' ]
        expect: define\('DB_NAME', '(.*?)'\);
    OVH_DB_PREFIX:
        files:  [ 'wp-config.php' ]
        expect: \$table_prefix\s*=\s*'(.*?)';

createProcedure: |
    PARSE_FILE 'wp-config.php'
    PARSE_FILE 'wp-includes/version.php'
    RUN '/usr/local/php7.0/bin/php --php-ini /usr/local/php7.0/etc/php.ini --file #OVH_TEMP_FOLDER#/wp-cli.phar -d sendmail_path="" -- core install --path='#OVH_MODULE_FOLDER#' --url='http://#OVH_MODULE_DOMAIN#/#OVH_MODULE_URL#' --title='WordPress' --admin_user='#OVH_MODULE_ADMIN_NAME#' --admin_password='#OVH_ADMIN_PASSWORD#' --admin_email='#OVH_ADMIN_EMAIL#'' EXPECT '^Success: WordPress installed successfully\.$'
    RUN '/usr/local/php7.0/bin/php --php-ini /usr/local/php7.0/etc/php.ini --file #OVH_TEMP_FOLDER#/wp-cli.phar -d sendmail_path='' -- option update --path='#OVH_MODULE_FOLDER#' siteurl 'http://#OVH_MODULE_DOMAIN#/#OVH_MODULE_URL#'' EXPECT '^Success:'
    RUN '/usr/local/php7.0/bin/php --php-ini /usr/local/php7.0/etc/php.ini --file #OVH_TEMP_FOLDER#/wp-cli.phar -d sendmail_path='' -- option update --path='#OVH_MODULE_FOLDER#' home 'http://#OVH_MODULE_DOMAIN#/#OVH_MODULE_URL#'' EXPECT '^Success:'

changePasswordProcedure: |
    RUN '/usr/local/php7.0/bin/php --php-ini /usr/local/php7.0/etc/php.ini --file #OVH_TEMP_FOLDER#/wp-cli.phar -d sendmail_path='' -- --path='#OVH_MODULE_FOLDER#' user update '#OVH_MODULE_ADMIN_NAME#' --user_pass='#OVH_ADMIN_PASSWORD#'' EXPECT '^Success: Updated user'

upgradeProcedure: |

deleteProcedure: |

