forked from zylklab/alfresco-export-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getSiteMemberships.sh
68 lines (60 loc) · 1.57 KB
/
getSiteMemberships.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
#!/bin/bash
###
### Script for getting Alfresco Site Memership via REST API
###
# Usage functions
usage() { echo "Usage: $0 [-f | -s <site>]" 1>&2; exit 1; }
# Command line options
while getopts "fu:p:he:s:" o; do
case "${o}" in
f)
FULL=1
;;
u)
MYUSER=${OPTARG}
;;
p)
MYPASS=${OPTARG}
;;
e)
URL=${OPTARG}
;;
s)
SITE=${OPTARG}
;;
\?)
echo "Invalid Option: -$OPTARG" 1>&2
exit 1
;;
h)
usage
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
# Exports ALFURL,MYUSER,MYPASS
source ./exportENVARS.sh
# Needs at least URL as parameter
if [ -z "${ALFURL}" ] || [ -z "${MYUSER}" ] || [ -z "${MYPASS}" ]; then
usage
fi
if [ -z "${SITE}" ] && [ -z "${FULL}" ]; then
usage
fi
# Default parameters
#ALFURL=${ALFURL:-http://localhost:8080/alfresco}
#MYUSER=${MYUSER:-admin}
#MYPASS=${MYPASS:-admin}
#SITE=${SITE:-swsdp}
FULL=${FULL:-0}
if [ "${FULL}" == "1" ]; then
for i in `curl -s -u $MYUSER:$MYPASS "$ALFURL/service/api/sites" | jq '.[] .shortName' | sed -e 's#\"##g'`;
do
curl -s -u $MYUSER:$MYPASS "$ALFURL/service/api/sites/$i/memberships" | jq '.[] | "\(.authority.userName),\(.role)"' | sed -e 's#\"##g' | sed -e "s/^/$i,/g"
done
else
curl -s -u $MYUSER:$MYPASS "$ALFURL/service/api/sites/$SITE/memberships" | jq '.[] | "\(.authority.userName),\(.role)"' | sed -e 's#\"##g' | sed -e "s/^/${SITE},/g"
fi