Created
April 5, 2012 17:28
-
-
Save capnslipp/2312697 to your computer and use it in GitHub Desktop.
*nix Group Permissionify (if it works for me, it should work for my buddies too)
This file contains hidden or 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
| #!/usr/bin/env bash | |
| shared_group="$1" # e.g.: 'admin' | |
| group_exists=`grep "^$shared_group:" /etc/group` | |
| if [ -z $group_exists ]; then | |
| echo "Error: There seems to be no group by the name of \"$shared_group\" (totally checked out your '/etc/group' file)." | |
| else | |
| echo "Permissifying within ./ directory..." | |
| echo ' '"Changing group to \"$shared_group\"..." | |
| sudo chown -R :"$shared_group" . | |
| echo ' '"Setting group read permission for all files with owner read permission..." | |
| sudo find ./ -perm -u+r -not -perm -g+r -exec chmod -h g+r '{}' \; | |
| echo ' '"Setting group write permission for all files with owner write permission..." | |
| sudo find ./ -perm -u+w -not -perm -g+w -exec chmod -h g+w '{}' \; | |
| echo ' '"Setting group execute permission for all files with owner execute permission..." | |
| sudo find ./ -perm -u+x -not -perm -g+x -exec chmod -h g+x '{}' \; | |
| echo ' '"Setting setgid bit on directories (to hopefully avoid incorrect group issues in the future)..." | |
| sudo find ./ -type d -perm -g+w -not -perm -g+s -exec chmod g+s '{}' \; | |
| echo "All permissied up. Enjoy." | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment