Commit 94732bb1 authored by Visay Keo's avatar Visay Keo

[FEATURE] Add possibility to sync to any flow context

Change-Id: I11511806761401e68c2c0363b46037d5b30efdbd
parent 4839744a
## Introduction ## Introduction
This is a helper tool for fetch content from TYPO3 Flow / Neos installation on a remote server to your local computer running with docker. This is a helper tool for fetch content from Flow Framework / Neos CMS installation on a remote server to your local computer running with docker.
## Dependency ## Dependency
This is requires that your TYPO3 Flow / Neos installation is configured to run with `dockerflow` package. See https://github.com/Sebobo/Shel.DockerFlow This is requires that your Flow Framework / Neos CMS installation is configured to run with `dockerflow` package. See https://github.com/Sebobo/Shel.DockerFlow
## Installation ## Installation
Add the `syncontent` package into your `composer.json` file and update `composer.lock`. It is recommended to add in the `require-dev` section of your composer. Add the `syncontent` package into your `composer.json` file and update `composer.lock`. It is recommended to add in the
`require-dev` section of your composer.
``` ```
"visay/syncontent": "dev-master" "visay/syncontent": "dev-master"
...@@ -19,17 +20,18 @@ Add the `syncontent` package into your `composer.json` file and update `composer ...@@ -19,17 +20,18 @@ Add the `syncontent` package into your `composer.json` file and update `composer
In the root directory of your project, execute: In the root directory of your project, execute:
```bash ```bash
bin/syncontent latest-014-073 bin/syncontent demo-014-007
``` ```
- Replace the user `latest-014-073` with the one you want to get content from. - Replace the user `demo-014-007` with the one you want to get content from.
- You need to make sure that you have auto login with public key to `latest-014-073@10.10.10.27` - You need to make sure that you have auto login with public key to `demo-014-007@10.10.10.27`
- Only `latest` or `demo` is supported at the moment. We don't recommend you to have autologin access to the live site - Only `latest` or `demo` is supported at the moment. We don't recommend you to have autologin access to the live site
- You can only run the command from the root directory of your project - You can only run the command from the root directory of your project
### Customization ### Customization
If you are lazy typing the user again and again, you can define it by creating a file in `Packages/Libraries/visay/syncontent/config/master` with the name as user of the server you want to use. If you are lazy typing the user again and again, you can define it by creating a file in
`Packages/Libraries/visay/syncontent/config/master` with the same name as the user of the server you want to use.
``` ```
Packages Packages
...@@ -41,7 +43,7 @@ Packages ...@@ -41,7 +43,7 @@ Packages
├── composer.json ├── composer.json
├── config ├── config
│   └── master │   └── master
│   └── latest-014-073 │   └── demo-014-007
└── README.md └── README.md
``` ```
...@@ -51,12 +53,14 @@ With this file, you can now execute the content sync with just: ...@@ -51,12 +53,14 @@ With this file, you can now execute the content sync with just:
bin/syncontent bin/syncontent
``` ```
And the script will automatically take `latest-014-073` as the content master. And the script will automatically take `demo-014-007` as the content master.
- There should be only one master at a time. That means you should not have more than more file in the `config/master` directory. In case there are more than one file exists, the script will take first file only to process. - There should be only one master at a time. That means you should not have more than more file in the `config/master`
directory. In case there are more than one file exists, the script will take first file only to process.
## Author ## Author
Visay Keo <visay@web-essentials.asia> Visay Keo <visay@web-essentials.asia>
If you have any feedback, comments and/or questions, feel free to contact with email address above. And of course, a merge request is always welcomed. If you have any feedback, comments and/or questions, feel free to contact with email address above. And of course,
a merge request is always welcomed.
...@@ -35,15 +35,15 @@ ...@@ -35,15 +35,15 @@
synchronize: mode=pull src="/tmp/{{ db_name.stdout }}.sql" dest="/tmp/{{ db_name.stdout }}.sql" synchronize: mode=pull src="/tmp/{{ db_name.stdout }}.sql" dest="/tmp/{{ db_name.stdout }}.sql"
- name: Check local database name - name: Check local database name
local_action: shell bin/dockerflow run -T app /var/www/flow configuration:show --type Settings --path TYPO3.Flow.persistence.backendOptions | grep 'dbname' | cut -d ' ' -f2 local_action: shell FLOW_CONTEXT={{ local_flow_context }} bin/dockerflow run -T app ./flow configuration:show --type Settings --path TYPO3.Flow.persistence.backendOptions | grep 'dbname' | cut -d ' ' -f2
chdir="{{ local_path }}" chdir="{{ local_path }}"
register: local_db_name register: local_db_name
- name: Drop local database (TODO) - name: Drop local database
local_action: shell bin/dockerflow run db mysqladmin -h db -u root -proot drop {{ local_db_name.stdout }} -f local_action: shell bin/dockerflow run db mysqladmin -h db -u root -proot drop {{ local_db_name.stdout }} -f
chdir="{{ local_path }}" chdir="{{ local_path }}"
- name: Re-create local database (TODO) - name: Re-create local database
local_action: shell bin/dockerflow run db mysqladmin -h db -u root -proot create {{ local_db_name.stdout }} --default-character-set=utf8 local_action: shell bin/dockerflow run db mysqladmin -h db -u root -proot create {{ local_db_name.stdout }} --default-character-set=utf8
chdir="{{ local_path }}" chdir="{{ local_path }}"
...@@ -51,10 +51,14 @@ ...@@ -51,10 +51,14 @@
local_action: shell bin/dockerflow run db mysql -h db -u root -proot {{ local_db_name.stdout }} < /tmp/{{ db_name.stdout }}.sql local_action: shell bin/dockerflow run db mysql -h db -u root -proot {{ local_db_name.stdout }} < /tmp/{{ db_name.stdout }}.sql
chdir="{{ local_path }}" chdir="{{ local_path }}"
- name: Execute ./flow database:setcharset
local_action: shell FLOW_CONTEXT={{ local_flow_context }} bin/dockerflow run app ./flow database:setcharset
chdir="{{ local_path }}"
- name: Execute ./flow flow:cache:flush --force - name: Execute ./flow flow:cache:flush --force
local_action: shell bin/dockerflow run app /var/www/flow flow:cache:flush --force local_action: shell FLOW_CONTEXT={{ local_flow_context }} bin/dockerflow run app ./flow flow:cache:flush --force
chdir="{{ local_path }}" chdir="{{ local_path }}"
- name: Execute ./flow cache:warmup - name: Execute ./flow cache:warmup
local_action: shell bin/dockerflow run app /var/www/flow cache:warmup local_action: shell FLOW_CONTEXT={{ local_flow_context }} bin/dockerflow run app ./flow cache:warmup
chdir="{{ local_path }}" chdir="{{ local_path }}"
...@@ -12,9 +12,9 @@ fi ...@@ -12,9 +12,9 @@ fi
if [ -z "${MASTER}" ]; then if [ -z "${MASTER}" ]; then
echo "Please specify the server to sync from:" echo "Please specify the server to sync from:"
echo "Example: bin/syncontent latest-014-073" echo "Example: bin/syncontent latest-014-007"
echo "Example: bin/syncontent demo-014-073" echo "Example: bin/syncontent demo-014-007"
echo "Or specify it in Configuration/.syncontent" echo "Or specify it in config/master directory, read the doc"
exit 0 exit 0
fi fi
...@@ -22,8 +22,8 @@ STAGE=`echo ${MASTER} | cut -d '-' -f1` ...@@ -22,8 +22,8 @@ STAGE=`echo ${MASTER} | cut -d '-' -f1`
if [ "${STAGE}" != "latest" ] && [ "${STAGE}" != "demo" ]; then if [ "${STAGE}" != "latest" ] && [ "${STAGE}" != "demo" ]; then
echo "Only latest or demo is supported at the moment:" echo "Only latest or demo is supported at the moment:"
echo "Example: bin/syncontent latest-014-073" echo "Example: bin/syncontent latest-014-007"
echo "Example: bin/syncontent demo-014-073" echo "Example: bin/syncontent demo-014-007"
exit 0 exit 0
fi fi
...@@ -37,12 +37,16 @@ if [ "${PING}" != "OK" ]; then ...@@ -37,12 +37,16 @@ if [ "${PING}" != "OK" ]; then
exit 0 exit 0
fi fi
echo "Start content sync from ${SSH_USER} to local" # Use Development context if Flow Context is not set
FLOW_CONTEXT=${FLOW_CONTEXT:=Development}
echo "Start content sync from ${SSH_USER} (Production context) to local (${FLOW_CONTEXT} context)"
ansible-playbook -i ${PACKAGE_DIR}/ansible/hosts.ini ${PACKAGE_DIR}/ansible/playbook.yml \ ansible-playbook -i ${PACKAGE_DIR}/ansible/hosts.ini ${PACKAGE_DIR}/ansible/playbook.yml \
--extra-vars "stage=${STAGE} --extra-vars "stage=${STAGE}
ssh_user=${SSH_USER} ssh_user=${SSH_USER}
local_path=${ROOT_DIR} local_path=${ROOT_DIR}
remote_path=/home/${SSH_USER}/public_html" remote_path=/home/${SSH_USER}/public_html
local_flow_context=${FLOW_CONTEXT}"
echo "Sync content from ${STAGE} completed!" echo "Sync content from ${STAGE} completed!"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment