Projet

Général

Profil

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

root / bin / usage.sh @ fc3d89c3

1
#!/bin/sh
2

    
3
usage() {
4
    help="usage.sh -v Drupal_version -s project_status -n project_name\n
5
# List sites that have the project_name with the corresponding project_status.\n
6
# project status: enabled or disabled"
7
    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
. /home/assos/bin/scripts-utils.sh
42

    
43

    
44
if [ ! "${drupal_version}" = d7 ] ; then
45
    echo Unrecognize version. >&2
46
    exit 1
47
fi
48

    
49
number_found=0
50

    
51
for site in $(sites_list) ; do
52
    # List projects that correspond to the status.
53
    # Keep project_name if listed.
54
    # Count line result. 0 if not listed or 1 if listed.
55
    # Print site_dir if listed.
56

    
57
    if [ 1 -le $(drush @"${site}" pml --status="${project_status}" | grep "${project_name}" | wc -l) ] ; then
58
        echo "${site}";
59
        number_found=$((${number_found} + 1))
60
    fi
61
done
62

    
63
echo "Number of sites found for project ${project_name} and status ${project_status} : $number_found";