Commit 6d9f8ad3 authored by Visay Keo's avatar Visay Keo
Browse files

Merge branch 'WI-283' into 'master'

[FEATURE] Add possibility to overwrite remote path

@chivy please test and let me know if it works for you. Please use the https version to add the remote to your local working directory

```
git remote add visay https://git.web-essentials.asia/visay/syncontent.git
git fetch --all
git checkout WI-283
```

See merge request !1
parents 94732bb1 976a94f6
Loading
Loading
Loading
Loading
+8 −0
Changes for README.md: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -27,6 +27,12 @@ bin/syncontent demo-014-007
- 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
- You can only run the command from the root directory of your project
- If your remote path is in another directory below `public_html`, set it in the second argument like below:

```bash
bin/syncontent demo-014-007 neosbox
bin/syncontent demo-014-007 neosbox/my_root_dir
```

### Customization

@@ -58,6 +64,8 @@ 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.

- With this mode, you cannot overwrite the remote path as argument. This will come in the next release of this package.

## Author

Visay Keo <visay@web-essentials.asia>
+11 −4
Changes for bin/syncontent: 11 added lines, 4 removed lines.
Original line number Diff line number Diff line
#!/bin/bash

ARG=$1
USER_NAME=$1
ROOT_DIR=`pwd`
PACKAGE_DIR="${ROOT_DIR}/Packages/Libraries/visay/syncontent"

if [ -z "${ARG}" ]; then
if [ -z "${USER_NAME}" ]; then
	MASTER=`ls ${PACKAGE_DIR}/config/master | sort -n | head -1`
else
	MASTER="${ARG}"
	MASTER="${USER_NAME}"
	REMOTE_DIR=$2
fi

if [ -z "${MASTER}" ]; then
@@ -37,6 +38,12 @@ if [ "${PING}" != "OK" ]; then
	exit 0
fi

if [ -z "${REMOTE_DIR}" ]; then
	REMOTE_PATH="/home/${SSH_USER}/public_html"
else
	REMOTE_PATH="/home/${SSH_USER}/public_html/${REMOTE_DIR}"
fi

# Use Development context if Flow Context is not set
FLOW_CONTEXT=${FLOW_CONTEXT:=Development}

@@ -46,7 +53,7 @@ ansible-playbook -i ${PACKAGE_DIR}/ansible/hosts.ini ${PACKAGE_DIR}/ansible/play
	--extra-vars "stage=${STAGE}
				  ssh_user=${SSH_USER}
				  local_path=${ROOT_DIR}
				  remote_path=/home/${SSH_USER}/public_html
				  remote_path=${REMOTE_PATH}
				  local_flow_context=${FLOW_CONTEXT}"

echo "Sync content from ${STAGE} completed!"