-
Notifications
You must be signed in to change notification settings - Fork 4
/
druml.sh
executable file
·136 lines (110 loc) · 3.76 KB
/
druml.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
# Get Druml dir.
SCRIPT_DIR=$(cd "$(dirname "$(test -L "$0" && readlink "$0" || echo "$0")")" && pwd)
# Get command.
COMMAND=$1
shift
# Load includes.
source "$SCRIPT_DIR/druml-inc-init.sh"
# Check if command exists
if [[ -n $COMMAND ]]
then
EXISTS=$(script_exists $COMMAND)
if [[ -z $EXISTS ]]
then
echo "Command '$COMMAND' does not exist!"
exit 1
fi
fi
# Display help.
if [[ -n $COMMAND && -n $PARAM_HELP ]]
then
echo "$(run_script $COMMAND)"
exit 1
elif [[ -z $COMMAND || -n $PARAM_HELP ]]
then
echo "usage: druml [--help] [--config=<path>] [--docroot=<path>] <command> <arguments>"
echo ""
echo "Available commands are:"
echo " local-dbsync Syncs a subsite DB from a remote env to a local one"
echo " local-listupdate Updates a list file that contains subsites"
echo " local-keysupdate Updates known hosts file with SSH keys from remote servers"
echo " local-samlsign Signes SAML metadata file"
echo " local-sitesync Syncs a subsite (DB and files) from a remote env to a"
echo " local one"
echo " remote-ac-codedeploy Deploys code from one environment to another"
echo " remote-ac-codepathdeploy Deployes a tag/branch to the specific enviornment"
echo " remote-ac-command Executes Acquia command and checks status of it"
echo " remote-ac-dbbackup Backup a DB"
echo " remote-ac-dbsync Syncs a subsite DB from one env to another"
echo " remote-ac-oldbackupsrm Removes old DB backups"
echo " remote-ac-restorefrombackup Restores DB from recent backup"
echo " remote-ac-sitesync Syncs a subsite (DB and fies) from one env to another"
echo " remote-ac-status Waits until the task is completed"
echo " remote-ac-tagget Returns tag or branch associated with environment"
echo " remote-bash Performs arbitrary bash commands for a specific env"
echo " remote-drush Performs arbitrary drush commands for a specific subsite"
echo " remote-filesync Syncs subsite fies from one env to another"
echo " remote-memcacheflush Syncs subsite fies from one env to another"
echo " remote-php Performs a php code for a specific subsite"
echo ""
echo "See 'druml <command> --help' to read about a specific command."
exit 1
fi
# Load config.
source $SCRIPT_DIR/druml-inc-config.sh
# Read parameters.
LIST=$PARAM_LIST
SITE=$(get_site_alias $PARAM_SITE)
if [[ -n $PARAM_DELAY ]]
then
DELAY=$PARAM_DELAY
else
DELAY=0
fi
if [[ -n $PARAM_JOBS ]]
then
JOBS=$PARAM_JOBS
else
JOBS=1
fi
# Log command.
log_command $COMMAND "${PROXY_PARAMS_ARGS[@]}"
# Log output (this should be prior log_command).
log_output
echo "=== Druml script started at $(date)"
echo ""
# Run commands for multiple subsites in multiple threads.
if [[ -n $LIST && "$COMMAND" != "local-listupdate" ]]
then
iterate_script $LIST $JOBS $DELAY $COMMAND "${PROXY_PARAMS_ARGS[@]}"
RESULT="$?"
if [[ $RESULT > 0 ]]
then
echo "=== Druml script failed at $(date)"
echo ""
# Log command.
log_command_failed $COMMAND "${PROXY_PARAMS_ARGS[@]}"
exit 1
fi
echo "=== Druml script ended successfully at $(date)"
echo ""
# Log command.
log_command_succeed $COMMAND "${PROXY_PARAMS_ARGS[@]}"
exit
fi
# Run command for a single subsite or other commands.
run_script $COMMAND "${PROXY_PARAMS_ARGS[@]}"
RESULT="$?"
if [[ $RESULT > 0 ]]
then
echo "=== Druml script failed at $(date)"
echo ""
# Log command.
log_command_failed $COMMAND "${PROXY_PARAMS_ARGS[@]}"
exit 1
fi
echo "=== Druml script ended successfully at $(date)"
echo ""
# Log command.
log_command_succeed $COMMAND "${PROXY_PARAMS_ARGS[@]}"