Created
February 4, 2019 16:45
-
-
Save chrissharp123/e6707009e5e043b055cbb0ff152a2f89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get_combined_perms_per_profile.sh: | |
#!/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 | |
get_profiles_with_perm.sh: | |
#!/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'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment