sh Oro重新安装脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Oro重新安装脚本相关的知识,希望对你有一定的参考价值。
#!/bin/bash
function parse_yaml {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\):|\1|" \
-e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
if (length($3) > 0) {
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
printf("%s%s%s=\"%s\"\n", "'$prefix'",vn, $2, $3);
}
}'
}
XDEBUG_INI=$(php --ini | egrep -o '\/[A-Za-z0-9|\/|\.|-]+/xdebug.ini')
XDEBUG_INI_BAK="${XDEBUG_INI}.bak"
if [[ -f $XDEBUG_INI ]]
then
echo "Disabling XDebug extension"
sudo mv $XDEBUG_INI $XDEBUG_INI_BAK
fi
currentDir=${PWD##*/}
repoDir=$(basename $(dirname $(dirname $(readlink -f .))))
APP_HOST=$currentDir.$repoDir.loc
ENV=$1
PARAMETERS_FILE="./app/config/parameters.yml"
if [[ ${ENV} == "test" ]]
then
PARAMETERS_FILE="./app/config/parameters_test.yml"
fi
if [[ ${currentDir} == *"commerce"* ]]
then
APP_NAME="OroCommerce"
fi
if [[ ${currentDir} == *"crm"* ]]
then
APP_NAME="OroCRM"
fi
sudo chown dkhrysev:nginx -R `pwd`;sudo chmod g+rwX -R `pwd`
echo "Checking for composer fxp/composer-asset-plugin"
if [[ `composer global show fxp/composer-asset-plugin` ]]
then
echo "Plugin installed"
else
echo "Plugin not installed. Installing"
composer global require "fxp/composer-asset-plugin:~1.2"
fi
echo "Installing composer dependencies"
COMPOSER=dev.json composer install -o
eval $(parse_yaml ${PARAMETERS_FILE} "CONF_")
echo "Recreating DB ${CONF_parameters__database_driver} ${CONF_parameters__database_name}"
if [[ ${CONF_parameters__database_driver} == "pdo_pgsql" ]]
then
echo "Creating PostgreSQL database ${CONF_parameters__database_name}"
dropdb -U ${CONF_parameters__database_user} ${CONF_parameters__database_name}
createdb -U ${CONF_parameters__database_user} ${CONF_parameters__database_name}
psql -U ${CONF_parameters__database_user} -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";' -d ${CONF_parameters__database_name};
else
echo "Creating MySQL database ${CONF_parameters__database_name}"
mysqladmin --user="${CONF_parameters__database_user}" --password="${CONF_parameters__database_password}" --force drop ${CONF_parameters__database_name}
mysqladmin --user="${CONF_parameters__database_user}" --password="${CONF_parameters__database_password}" --force create ${CONF_parameters__database_name}
fi
echo "Dropping caches"
#redis-cli FLUSHALL
if [[ ${ENV} == "test" ]]
then
rm -rf app/cache/test
echo "Reinstalling TEST"
app/console oro:install -v --user-name=admin --user-email=admin@example.com --user-firstname=John --user-lastname=Doe --user-password=admin --sample-data=n --force --symlink --organization-name=OroCRM --env=test --skip-assets --application-url="http://localhost/"
else
rm -rf app/cache/{dev,prod,sessions}
echo "Reinstalling APP for http://$APP_HOST"
app/console oro:install --organization-name="$APP_NAME" --user-name=admin --user-email=dkhrysev@magecore.com --user-firstname=Test --user-lastname=User --user-password=admin --symlink --application-url="http://$APP_HOST" --sample-data=$2 --force
fi
sudo chown dkhrysev:nginx -R `pwd`;sudo chmod g+rwX -R `pwd`
if [[ "`ping -c 1 ${APP_HOST}`" ]]
then
echo "Host is configured correctly"
else
echo "Adding ${APP_HOST} to hosts"
sudo -- sh -c -e "echo '127.0.0.1 ${APP_HOST}' >> /etc/hosts";
fi
if [[ -f $XDEBUG_INI_BAK ]]
then
echo "Reverting XDebug extension"
sudo mv $XDEBUG_INI_BAK $XDEBUG_INI
fi
echo "Installed application http://${APP_HOST}/app_dev.php"
以上是关于sh Oro重新安装脚本的主要内容,如果未能解决你的问题,请参考以下文章
我可以使用 DRF 重新创建 ORO CRM API 来为我的项目获取自定义功能吗