Skip to content

Instantly share code, notes, and snippets.

@JanPetr
Last active September 28, 2018 09:31
Show Gist options
  • Save JanPetr/a6a26dae245673a648dd948e0798399e to your computer and use it in GitHub Desktop.
Save JanPetr/a6a26dae245673a648dd948e0798399e to your computer and use it in GitHub Desktop.
Install M2 with Algolia extension
{
"http-basic": {
"repo.magento.com": {
"username": "[[FIXME]]",
"password": "[[FIXME]]"
}
}
}
#!/usr/bin/env bash
PROG="$0"
VERSION=
BRANCH=master
ONLY_INSTALL=No
INSTALL_SAMPLE_DATA=Yes
usage() {
echo "Usage:" >&2
echo "$PROG -v MAGENTO_VERSION" >&2
echo "" >&2
echo "Options:" >&2
echo " -v | --magento-version Version of Magento" >&2
echo " -b | --branch Extension's branch" >&2
echo " --only-install Runs only install command without downloading new copy of Magento" >&2
echo " --no-sample-data Doesn't install sample data" >&2
}
while [[ $# > 0 ]]; do
case "$1" in
-v|--magento-version)
VERSION="$2"
shift
;;
-b|--branch)
BRANCH="$2"
shift
;;
--only-install)
ONLY_INSTALL=Yes
shift
;;
--no-sample-data)
INSTALL_SAMPLE_DATA=No
shift
;;
esac
shift
done
ensure() {
if [ -z "$2" ]; then
echo "Missing option $1."
echo ""
usage
exit 1
fi
}
ensure "-v" "$VERSION"
cd [[FIXME - path to your server root directory]]
DIRECTORY_NAME="magento${VERSION//./}"
if [ ${ONLY_INSTALL} == No ]; then
mysql -uroot -e "drop database ${DIRECTORY_NAME}" >/dev/null 2>&1
mysql -uroot -e "create database ${DIRECTORY_NAME}"
rm -rf ${DIRECTORY_NAME}
mkdir ${DIRECTORY_NAME}
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition:${VERSION} ${DIRECTORY_NAME}
cd ${DIRECTORY_NAME}
mkdir var/composer_home
cp [[FIXME - Composer auth.json with Magento credentials]] var/composer_home/auth.json
if [ ${INSTALL_SAMPLE_DATA} == Yes ]; then
php bin/magento sampledata:deploy
fi
composer require algolia/algoliasearch-magento-2:dev-${BRANCH} --prefer-source
composer require algolia/algoliasearch-custom-algolia-magento-2
else
cd ${DIRECTORY_NAME}
fi
php bin/magento setup:install --backend-frontname="admin" --base-url=http://127.0.0.1/${DIRECTORY_NAME}/ --db-host="127.0.0.1" --db-name=${DIRECTORY_NAME} --db-user=root --admin-firstname=Admin --admin-lastname=Admin --admin-email=dummy@email.com --admin-user=admin --admin-password=[[FIXME]] --language=en_US --currency=USD --timezone=Europe/Paris --use-rewrites=1 --session-save=db
php bin/magento config:set algoliasearch_credentials/credentials/application_id "${ALGOLIA_APPLICATION_ID}"
php bin/magento config:set algoliasearch_credentials/credentials/search_only_api_key "${ALGOLIA_SEARCH_API_KEY}"
php bin/magento config:set algoliasearch_credentials/credentials/api_key "${ALGOLIA_API_KEY}"
php bin/magento config:set algoliasearch_credentials/credentials/index_prefix "${DIRECTORY_NAME}_"
php bin/magento config:set algoliasearch_instant/instant/is_instant_enabled "1"
php bin/magento indexer:reindex algolia_products algolia_categories algolia_pages algolia_suggestions algolia_additional_sections
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment