1 |
d52a5b2f
|
jenselme
|
#!/bin/sh
|
2 |
|
|
|
3 |
15ed27d8
|
Julien Enselme
|
usage() {
|
4 |
|
|
help="usage.sh -v Drupal_version -s project_status -n project_name\n
|
5 |
d52a5b2f
|
jenselme
|
# List sites that have the project_name with the corresponding project_status.\n
|
6 |
|
|
# project status: enabled or disabled"
|
7 |
15ed27d8
|
Julien Enselme
|
echo -e "${help}"
|
8 |
|
|
}
|
9 |
|
|
|
10 |
|
|
drupal_version=''
|
11 |
|
|
project_status=''
|
12 |
|
|
project_name=''
|
13 |
|
|
while getopts "hv:s:n:" opt; do
|
14 |
|
|
case "${opt}" in
|
15 |
|
|
h)
|
16 |
|
|
usage; exit 0;;
|
17 |
|
|
v)
|
18 |
|
|
drupal_version="${OPTARG}";;
|
19 |
|
|
s)
|
20 |
|
|
project_status="${OPTARG}";;
|
21 |
|
|
n)
|
22 |
|
|
project_name="${OPTARG}";;
|
23 |
|
|
:)
|
24 |
|
|
echo "Option -$OPTARG requires an argument." >&2
|
25 |
|
|
usage >&2; exit 1;;
|
26 |
|
|
\?)
|
27 |
|
|
usage >&2; exit 1;;
|
28 |
|
|
esac
|
29 |
|
|
done
|
30 |
|
|
shift $((OPTIND-1))
|
31 |
|
|
|
32 |
|
|
# Check that all required parameters are there
|
33 |
|
|
if [ -z "${drupal_version}" ] || [ -z "${project_status}" ] || [ -z "${project_name}" ]; then
|
34 |
|
|
echo "At least a required parameter is missing." >&2
|
35 |
|
|
usage >&2
|
36 |
|
|
exit 1
|
37 |
|
|
fi
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
. /home/assos/bin/scripts-config.sh
|
41 |
|
|
. scripts-utils.sh
|
42 |
d52a5b2f
|
jenselme
|
|
43 |
|
|
|
44 |
15ed27d8
|
Julien Enselme
|
if [ "${drupal_version}" = d7 ] ; then
|
45 |
3e9236bd
|
Julien Enselme
|
cd "${d7_dir_sites}"
|
46 |
9e84cfde
|
Julien Enselme
|
else
|
47 |
|
|
echo Unrecognize version.
|
48 |
d52a5b2f
|
jenselme
|
fi
|
49 |
|
|
|
50 |
b679f22e
|
Florent Torregrosa
|
number_found=0
|
51 |
|
|
|
52 |
8550e097
|
Julien Enselme
|
for dir in $(find . -maxdepth 1 -mindepth 1 -type d ! -name all ! -name languages ! -name images | sort) ; do
|
53 |
1fbc61c9
|
Florent Torregrosa
|
# List projects that correspond to the status.
|
54 |
d52a5b2f
|
jenselme
|
# Keep project_name if listed.
|
55 |
|
|
# Count line result. 0 if not listed or 1 if listed.
|
56 |
333baf85
|
Julien Enselme
|
# Print site_dir if listed.
|
57 |
d52a5b2f
|
jenselme
|
|
58 |
3e9236bd
|
Julien Enselme
|
cd "${dir}";
|
59 |
15ed27d8
|
Julien Enselme
|
if [ 1 -le $(drush pml --status="${project_status}" | grep "${project_name}" | wc -l) ] ; then
|
60 |
3e9236bd
|
Julien Enselme
|
echo "${dir}";
|
61 |
333baf85
|
Julien Enselme
|
number_found=$(($number_found + 1))
|
62 |
d52a5b2f
|
jenselme
|
fi
|
63 |
|
|
cd -
|
64 |
|
|
done
|
65 |
b679f22e
|
Florent Torregrosa
|
|
66 |
15ed27d8
|
Julien Enselme
|
echo "Number of sites found for project ${project_name} and status ${project_status} : $number_found"; |