Projet

Général

Profil

Paste
Télécharger (1,5 ko) Statistiques
| Branche: | Révision:

root / bin / usage.sh @ 81b16cc2

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 653aeb8e Julien Enselme
. /home/assos/bin/scripts-utils.sh
42 d52a5b2f jenselme
43
44 d4c4525a Julien Enselme
if [ ! "${drupal_version}" = d7 ] ; then
45
    echo Unrecognize version. >&2
46
    exit 1
47 d52a5b2f jenselme
fi
48
49 b679f22e Florent Torregrosa
number_found=0
50
51 d4c4525a Julien Enselme
for site in $(sites_list) ; do
52 1fbc61c9 Florent Torregrosa
    # List projects that correspond to the status.
53 d52a5b2f jenselme
    # Keep project_name if listed.
54
    # Count line result. 0 if not listed or 1 if listed.
55 333baf85 Julien Enselme
    # Print site_dir if listed.
56 d52a5b2f jenselme
57 d4c4525a Julien Enselme
    if [ 1 -le $(drush @"${site}" pml --status="${project_status}" | grep "${project_name}" | wc -l) ] ; then
58
        echo "${site}";
59 653aeb8e Julien Enselme
        number_found=$((${number_found} + 1))
60 d52a5b2f jenselme
    fi
61
done
62 b679f22e Florent Torregrosa
63 15ed27d8 Julien Enselme
echo "Number of sites found for project ${project_name} and status ${project_status} : $number_found";