From 64f6dfeb7f7b07a91cc8fee8005ae0bc12a96e25 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Mon, 4 Dec 2017 13:25:44 +0100 Subject: Added dokumentation for tests, gitlab and deployments --- deploy.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'deploy.sh') diff --git a/deploy.sh b/deploy.sh index 18808041..f1569a61 100755 --- a/deploy.sh +++ b/deploy.sh @@ -6,9 +6,24 @@ remote_host= remote_path= deploy_id= -while getopts ":h:p:i:" opt; do +show_help(){ + echo "Usage: $0 [OPTION]..." >&2 + echo "Deploys a software with rsync over ssh" >&2 + echo "The options -i, -p and -r are required" >&2 + echo "" >&2 + echo " -h Display this help screen" >&2 + echo " -i Sets the id, a unique name for the deployment" >&2 + echo " -p Define the base path on the server" >&2 + echo " -r The remote server name and user" >&2 +} + +while getopts ":hi:p:r:" opt; do case ${opt} in h) + show_help + exit 1 + ;; + r) remote_host="$OPTARG" ;; p) @@ -29,7 +44,7 @@ while getopts ":h:p:i:" opt; do done if [ -z "${remote_host}" ] || [ -z "${remote_path}" ] || [ -z "${deploy_id}" ]; then - echo "Please specify -h[remote host], -p[remote path] and -i[deploy id]" >&2 + show_help exit 1 fi @@ -48,8 +63,7 @@ ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "${remote_hos fi echo \"Changing symlink\" - unlink \"${remote_path}/current\" - ln -s \"${remote_path}/${deploy_id}\" \"${remote_path}/current\" + unlink \"${remote_path}/current\" && ln -s \"${remote_path}/${deploy_id}\" \"${remote_path}/current\" if [[ -f \"${deploy_id}-config.php\" ]]; then echo \"Restoring config\" -- cgit v1.2.3-54-g00ecf