syncs any directory with new deployment script
This commit is contained in:
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,11 +1,11 @@
|
|||||||
.env
|
.env
|
||||||
backup-volumes/
|
backup-volumes/
|
||||||
env_files/certs.env
|
|
||||||
env_files/manage.env
|
|
||||||
env_files/migrate-db.env
|
|
||||||
env_files/remote.env
|
|
||||||
exclude-list
|
exclude-list
|
||||||
tmp/
|
tmp/
|
||||||
traefik-volumes/
|
traefik-volumes/
|
||||||
webroot-remote/
|
webroot-remote/
|
||||||
webroot-volume/
|
webroot-volume/
|
||||||
|
/env_files/*
|
||||||
|
!/env_files/*example*
|
||||||
|
/deployment/*
|
||||||
|
!/deployment/*example*
|
||||||
|
|||||||
50
deploy-directory-to-remote.sh
Executable file
50
deploy-directory-to-remote.sh
Executable file
@@ -0,0 +1,50 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ "$#" -eq 0 ] || [ "$#" -gt 1 ]; then
|
||||||
|
echo takes only one argument
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e "${1}" ]; then
|
||||||
|
echo cannot find "${1}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# shellcheck source=./deployment/deployment-example.env
|
||||||
|
. "${1}"
|
||||||
|
|
||||||
|
if ssh ${remote_ssh_string} "mkdir --parents ${remote_deployment_directory_path}"; then
|
||||||
|
echo deployment folder successfully created on remote
|
||||||
|
else
|
||||||
|
echo deployment folder creation on remote failed
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ssh ${remote_ssh_string} "cp --archive --recursive ${remote_directory_path} ${remote_deployment_directory_path}/$(basename ${remote_directory_path}).backup.${now}"; then
|
||||||
|
echo backup of current remote directory successfully created on remote
|
||||||
|
else
|
||||||
|
echo backup of current remote directory failed
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ssh ${remote_ssh_string} "wp option patch update wpmm_settings general status 1 --path=${remote_wp_path}"; then
|
||||||
|
echo maintenance mode activated
|
||||||
|
else
|
||||||
|
echo something went horribly wrong
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if rsync --archive --compress --delete --delete-excluded --exclude-from="${deployment_exclude_file}" --human-readable --progress "${local_directory_path}/" "${remote_ssh_string}":"${remote_directory_path}"; then
|
||||||
|
echo syncing OK
|
||||||
|
else
|
||||||
|
echo syncing NOK
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ssh ${remote_ssh_string} "wp option patch update wpmm_settings general status 0 --path=${remote_wp_path}"; then
|
||||||
|
echo maintenance mode deactivated
|
||||||
|
else
|
||||||
|
echo something went horribly wrong
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
6
deployment/deployment-example.env
Normal file
6
deployment/deployment-example.env
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
local_directory_path=
|
||||||
|
now="$(date +%Y-%m-%d-%H-%M-%S)"
|
||||||
|
remote_deployment_path=
|
||||||
|
remote_directory_path=
|
||||||
|
remote_ssh_string=
|
||||||
|
remote_wp_path=
|
||||||
Reference in New Issue
Block a user