Project

General

Profile

Paste
Download (1.59 KB) Statistics
| Branch: | Revision:

root / bin / usage.sh @ eec59787

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
. scripts-utils.sh
42

    
43

    
44
if [ "${drupal_version}" = d7 ] ; then
45
    cd "${d7_dir_sites}"
46
else
47
    echo Unrecognize version.
48
fi
49

    
50
number_found=0
51

    
52
for dir in $(find . -maxdepth 1 -mindepth 1 -type d ! -name all ! -name languages ! -name images | sort) ; do
53
    # List projects that correspond to the status.
54
    # Keep project_name if listed.
55
    # Count line result. 0 if not listed or 1 if listed.
56
    # Print site_dir if listed.
57

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

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