-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdruml-remote-ac-codedeploy.sh
executable file
·54 lines (44 loc) · 1.28 KB
/
druml-remote-ac-codedeploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# Get Druml dir.
SCRIPT_DIR=$1
shift
# Load includes.
source $SCRIPT_DIR/druml-inc-init.sh
# Display help.
if [[ ${#ARG[@]} -lt 2 || -n $PARAM_HELP ]]
then
echo "usage: druml remote-ac-codedeploy [--config=<path>] [--docroot=<path>]"
echo " [--server=<number>]"
echo " <environment from> <environment to>"
exit 1
fi
# Read parameters.
SUBSITE=$(get_site_alias $PARAM_SITE)
ENV_FROM=$(get_environment ${ARG[1]})
ENV_TO=$(get_environment ${ARG[2]})
# Set variables.
DRUSH=$(get_drush_command)
DRUSH_ALIAS_FROM=$(get_drush_alias $ENV_FROM)
DRUSH_ALIAS_TO=$(get_drush_alias $ENV_TO)
SSH_ARGS=$(get_ssh_args $ENV_FROM $PARAM_SERVER)
PROXY_PARAM_SERVER=$(get_param_proxy "server")
# Say Hello.
echo "=== Deploying code from $ENV_FROM to $ENV_TO"
echo ""
OUTPUT=$(ssh -Tn $SSH_ARGS "$DRUSH $DRUSH_ALIAS_FROM ac-code-deploy $ENV_TO" 2>&1)
RESULT="$?"
TASK=$(echo $OUTPUT | awk '{print $2}')
# Eixt upon an error.
if [[ $RESULT > 0 ]]; then
echo "Error deploying code."
exit 1
fi
echo "$OUTPUT"
echo "Code deployment scheduled."
# Check task status.
run_script remote-ac-status $PROXY_PARAM_SERVER $ENV_FROM $TASK
if [[ $? > 0 ]]; then
echo "Code deployment failed!"
exit 1
fi
echo "Code deployment completed!"