adding script to get perms per permission profile
authorChris Sharp <csharp@georgialibraries.org>
Fri, 9 Oct 2015 16:55:37 +0000 (12:55 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Fri, 9 Oct 2015 16:55:37 +0000 (12:55 -0400)
get_combined_perms_per_profile.sh [new file with mode: 0755]

diff --git a/get_combined_perms_per_profile.sh b/get_combined_perms_per_profile.sh
new file mode 100755 (executable)
index 0000000..0c0b5f8
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+Usage () {
+echo "USAGE: $0 <permission group name>"
+exit 1
+}
+
+GROUP_NAME="$1"
+PG_USER="evergreen"
+PSQL="/usr/bin/psql"
+PG_DB="evergreen"
+
+
+if [ -z $GROUP_NAME ]; then
+    Usage
+fi
+read -d '' SQL <<EOF
+select  perm.code as "Permission", 
+        perm.description as "Description", 
+        grp.name as "Permission Level", 
+        case 
+            when map.depth = 0 then 'Consortium' 
+            when map.depth = 1 then 'System' 
+            when map.depth = 2 then 'Branch' 
+        end as "Depth", 
+        case 
+            when map.grantable = true then 'Grantable' 
+            when map.grantable = false then 'Not Grantable' 
+        end as "Grantability" 
+from    permission.grp_tree grp 
+        join permission.grp_perm_map map on (map.grp = grp.id) 
+        join permission.perm_list perm on (map.perm = perm.id) 
+where   grp.id in (
+            select id 
+            from permission.grp_ancestors(
+                (select id 
+                    from permission.grp_tree 
+                    where name = '$GROUP_NAME')
+            )
+        ) 
+        order by 1, 2;
+EOF
+
+PGUSER="$PG_USER" "$PSQL" -A --pset footer --field-separator ',' -o "$GROUP_NAME-perms.out" -c "$SQL" "$PG_DB"
+