{
  "jpsType": "install",
  "jpsVersion": "0.3",
  "application": {
    "id": "magento",
    "name": "Magento",
    "version": "2.1.6",
    "logo": "https://raw.githubusercontent.com/jelastic-jps/magento/master/magento21-apache-php56-mysql/images/magento.png",
    "type": "php",
    "categories": [
      "apps/e-commerce",
      "apps/sales-and-marketing"
    ],
    "homepage": "http://www.magentocommerce.com/",
    "description": {
      "en": "Magento is the eCommerce software and platform trusted by the world's leading brands. Grow your online business with Magento!"
    },
    "env": {
      "topology": {
        "ha": false,
        "engine": "php5.6",
        "ssl": false,
        "nodes": [
          {
            "extip": false,
            "count": 1,
            "cloudlets": 16,
            "nodeType": "apache2",
            "nodeGroup": "cp"
          },
          {
            "nodeType": "mysql5",
            "extip": false,
            "count": 1,
            "cloudlets": 16,
            "nodeGroup": "sqldb"
          }
        ]
      }
    },
    "onInstall": {
      "call": [
        "deployApp",
        "createDb",
        "replaceInFiles",
        "bindDomain"
      ]
    },
    "procedures": [
      {
        "id": "deployApp",
        "onCall": [
          {
            "deploy": [
              {
                "nodeMission": "cp",
                "archive": "https://github.com/jelastic-jps/magento/blob/master/magento21-apache-php56-mysql/dumps/Magento-CE-2.1.6-2017-03-29-12-40-05.zip?raw=true",
                "name": "Magento-2.1.6.zip",
                "context": "ROOT"
              }
            ]
          }
        ]
      },
      {
        "id": "createDb",
        "onCall": [
          {
            "prepareSqlDatabase": [
              {
                "nodeMission": "sqldb",
                "loginCredentials": {
                  "user": "root",
                  "password": "${nodes.mysql5.password}"
                },
                "newDatabaseName": "magento",
                "newDatabaseUser": {
                  "name": "magento",
                  "password": "magento"
                }
              }
            ]
          }
        ]
      },
      {
        "id": "replaceInFiles",
        "onCall": [
          {
            "replaceInFile": [
              {
                "nodeMission": "cp",
                "path": "${SYSTEM_ETC}/php.ini",
                "replacements": [
                  {
                    "pattern": ";extension=gd.so",
                    "replacement": "extension=gd.so \rextension=intl.so \rextension=xsl.so"
                  }
                ]
              }
            ]
          },
          {
            "restartNodes": [
              {
                "nodeMission": "cp"
              }
            ]
          }
        ]
      },
      {
        "id": "bindDomain",
        "onCall": [
          {
            "executeShellCommands": [
              {
                "nodeMission": "cp",
                "commands": [
                  "cd /var/www/webroot/ROOT/bin && chmod a+x magento",
                  "/usr/bin/php magento setup:install -s '--backend-frontname=admin' '--db-host=${nodes.mysql5.address}' '--db-name=magento' '--db-user=root' '--db-password=${nodes.mysql5.password}' '--base-url=${env.url}' '--admin-firstname=admin' '--admin-lastname=adminlast' '--admin-email=${user.email}' '--admin-user=admin' '--admin-password=${user.appPassword}' &> /dev/null",
                  "/usr/bin/php magento indexer:reindex && /usr/bin/php magento cache:flush &> /dev/null"
                ]
              },
              {
                "nodeMission": "cp",
                "commands": "sed -i \"162s/select]/select->limit(10000000000)]/\"  /var/www/webroot/ROOT/vendor/magento/framework/Search/Adapter/Mysql/Mapper.php"
              }
            ]
          }
        ]
      }
    ],
    "success": {
      "text": "Below you will find your admin panel link, username and password.</br></br> <table style='font-size:13px; border: none;'><tr><td width=\"70px\">Admin URL:</td><td style='padding-left: 10px;'><a href='${env.url}index.php/admin/' target='_blank'>${env.url}index.php/admin/</a></td></tr>  <tr><td>Admin name:</td><td style='padding-left: 10px;'>admin</td></tr><tr><td>Password:</td><td style='padding-left: 10px;'>${user.appPassword}</td></tr></table></br>To add custom domain name for your Magento installation follow the steps described in our <a href='http://docs.jelastic.com/custom-domains' target='_blank'>documentation</a>",
      "email": "Below you will find your admin panel link, username and password.</br></br> <table style='font-size:13px; border: none;'><tr><td width=\"70px\">Admin URL:</td><td style='padding-left: 10px;'><a href='${env.url}index.php/admin/' target='_blank'>${env.url}index.php/admin/</a></td></tr>  <tr><td>Admin name:</td><td style='padding-left: 10px;'>admin</td></tr><tr><td>Password:</td><td style='padding-left: 10px;'>${user.appPassword}</td></tr></table></br>To add custom domain name for your Magento installation follow the steps described in our <a href='http://docs.jelastic.com/custom-domains' target='_blank'>documentation</a>"
    }
  }
}