--- /dev/null
+#!/bin/bash
+
+Usage () {
+echo "USAGE: $0 <permission group name>"
+exit 1
+}
+
+GROUP_NAME="$1"
+
+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=evergreen psql -A --pset footer -o "$GROUP_NAME-perms.out" -c "$SQL" evergreen
--- /dev/null
+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 profile
+ from actor.usr
+ where usrname = 'username'
+-- where card in (
+-- select id
+-- from actor.card
+-- where barcode = 'barcode'
+-- )
+ )
+ )
+ )
+order by 1, 2;
--- /dev/null
+#!/bin/bash
+
+Usage () {
+echo "USAGE: $0 <perm_code>. Example: $0 VIEW_COPY_ALERT"
+exit 1
+}
+
+PERM_CODE="$1"
+PSQL="/usr/bin/psql"
+DB_USER="evergreen"
+
+if [ -z "$PERM_CODE" ]; then
+Usage
+fi
+
+PGUSER=$DB_USER $PSQL -c "select grp.name, perm.code, map.depth, map.grantable from permission.grp_perm_map map join permission.grp_tree grp on (map.grp = grp.id) join permission.perm_list perm on (map.perm = perm.id) where perm.code = '$PERM_CODE'"