Verified Commit 06da5ac9 authored by Elias Häußler's avatar Elias Häußler 🐛

[FEATURE] Add possibility to define remote server port in `remote.env`

parent 079dbca1
......@@ -22,6 +22,7 @@ Version numbers are based on [Semantic Versioning](https://semver.org).
- Support of PHP-CS-Fixer for code sniffing
- Git Pre-Commit hook file
- Set correct HTTP response code on failures
- Possibility to define remote server port in [`remote.env`](remote.env.dist)
- **Breaking:** SlackController: Request user's locale when sending API request
- SlackController: Allow users to set default expiration time when using `/lunch` command in Slack
- SlackController: Introduce `SlackMessage` class for styling of Slack messages
......
TARGET_HOST=
TARGET_PATH=
TARGET_PORT=22
......@@ -17,10 +17,12 @@ set +a
# Define default variables
TARGET_HOST=${TARGET_HOST}
TARGET_PATH=${TARGET_PATH}
TARGET_PORT=${TARGET_PORT-22}
# Exit if required variables are not set
[[ -z "${TARGET_HOST}" ]] && output "TARGET_HOST not set. Exiting." ${ERROR} && exit 1
[[ -z "${TARGET_PATH}" ]] && output "TARGET_PATH not set. Exiting." ${ERROR} && exit 1
[[ -z "${TARGET_PORT}" ]] && output "TARGET_PORT not set. Exiting." ${ERROR} && exit 1
# Exit if there are unstaged files
[[ -n "$(git status --porcelain)" ]] && output "Working directory is not clean. Exiting." ${ERROR} && exit 1
......@@ -36,12 +38,12 @@ output " Done." ${SUCCESS}
# Create directory structure on remote
output "Create directory structure on remote..." ${ACTION} 0
ssh ${TARGET_HOST} -T "mkdir -p ${TARGET_PATH}/{cache,local,release}"
ssh ${TARGET_HOST} -p ${TARGET_PORT} -T "mkdir -p ${TARGET_PATH}/{cache,local,release}"
output " Done." ${SUCCESS}
# Transfer files to cache on remote
output "Transfer files to remote cache..." ${ACTION} 0
rsync -arq --delete --delete-excluded "${ROOT_PATH}"/ ${TARGET_HOST}:${TARGET_PATH}/cache \
rsync -arq --delete --delete-excluded --port ${TARGET_PORT} "${ROOT_PATH}"/ ${TARGET_HOST}:${TARGET_PATH}/cache \
--exclude /composer.json \
--exclude /composer.lock \
--exclude /.git \
......@@ -57,7 +59,7 @@ rsync -arq --delete --delete-excluded "${ROOT_PATH}"/ ${TARGET_HOST}:${TARGET_PA
output " Done." ${SUCCESS}
# Set new release on remote
ssh ${TARGET_HOST} -T << __EOF
ssh ${TARGET_HOST} -p ${TARGET_PORT} -T << __EOF
$(typeset -f output)
set -e
......
......@@ -17,10 +17,12 @@ set +a
# Define default variables
TARGET_HOST=${TARGET_HOST}
TARGET_PATH=${TARGET_PATH}
TARGET_PORT=${TARGET_PORT-22}
# Exit if required variables are not set
[[ -z "${TARGET_HOST}" ]] && output "TARGET_HOST not set. Exiting." ${ERROR} && exit 1
[[ -z "${TARGET_PATH}" ]] && output "TARGET_PATH not set. Exiting." ${ERROR} && exit 1
[[ -z "${TARGET_PORT}" ]] && output "TARGET_PORT not set. Exiting." ${ERROR} && exit 1
function create_dump() {
dump_name="$(date -u +%Y-%m-%dT%H%M%SZ).sql.gz"
......@@ -28,7 +30,7 @@ function create_dump() {
dump_file="${dump_path}/${dump_name}"
mkdir -p "${dump_path}"
ssh ${TARGET_HOST} -T "php ${TARGET_PATH}/release/console.php database:export" | gzip > "${dump_file}"
ssh ${TARGET_HOST} -p ${TARGET_PORT} -T "php ${TARGET_PATH}/release/console.php database:export" | gzip > "${dump_file}"
[[ ! -s "${dump_file}" ]] && rm ${dump_file} && output "Database dump is empty. Exiting." ${ERROR} >&2 && exit 1
echo "${dump_file}"
......
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