diff options
| author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-10-22 22:13:33 -0400 |
|---|---|---|
| committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-10-22 22:13:33 -0400 |
| commit | 1046db24fcda8c3665fd2c0f70fc05e7dfd89c99 (patch) | |
| tree | 9eb415d65f7d0147c0cb5d067f4498d3afd16b2c | |
| parent | f048d99b46dd763ba00f147c48de6ac8d553e1f9 (diff) | |
Add --public option to set_repo_rights and provide some help
| -rwxr-xr-x | set_repo_rights | 98 |
1 files changed, 81 insertions, 17 deletions
diff --git a/set_repo_rights b/set_repo_rights index 4048dc8..4de026d 100755 --- a/set_repo_rights +++ b/set_repo_rights | |||
| @@ -1,34 +1,98 @@ | |||
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | 2 | ||
| 3 | |||
| 4 | function usage() | ||
| 5 | { | ||
| 6 | cat <<EOF | ||
| 7 | Usage: set_repo_rights [OPTIONS] <REPOSITORY1> <REPOSITORY2> ... | ||
| 8 | |||
| 9 | Options: | ||
| 10 | --quiet do not give a report after setting permssions | ||
| 11 | --public give read access rights to others (e.g., the gitweb daemon) | ||
| 12 | |||
| 13 | EOF | ||
| 14 | } | ||
| 15 | |||
| 3 | function die() | 16 | function die() |
| 4 | { | 17 | { |
| 5 | echo "Error: $1" | 18 | echo "Error: $1" |
| 6 | echo "Usage: $0 <REPOSITORY>" | 19 | usage |
| 7 | exit 1 | 20 | exit 1 |
| 8 | } | 21 | } |
| 9 | 22 | ||
| 10 | if [ "$1" == "--quiet" ] | 23 | QUIET= |
| 11 | then | 24 | PUBLIC= |
| 12 | QUIET=yes | 25 | PROJECT_GROUP=litmus |
| 13 | shift | 26 | |
| 14 | fi | 27 | while true |
| 28 | do | ||
| 29 | case $1 in | ||
| 30 | --quiet) | ||
| 31 | shift | ||
| 32 | QUIET=yes | ||
| 33 | ;; | ||
| 34 | --gitweb) | ||
| 35 | shift | ||
| 36 | PUBLIC=yes | ||
| 37 | ;; | ||
| 38 | --group) | ||
| 39 | shift | ||
| 40 | PROJECT_GROUP=$1 | ||
| 41 | shift | ||
| 42 | ;; | ||
| 43 | --help|-h) | ||
| 44 | usage | ||
| 45 | exit 0 | ||
| 46 | ;; | ||
| 47 | *) # unknown argument | ||
| 48 | break | ||
| 49 | ;; | ||
| 50 | esac | ||
| 51 | done | ||
| 15 | 52 | ||
| 16 | REPO=$1 | ||
| 17 | 53 | ||
| 18 | if [ -z "$REPO" ]; then | 54 | function set_rights() |
| 55 | { | ||
| 56 | |||
| 57 | REPO=$1 | ||
| 58 | |||
| 59 | if [ -z "$REPO" ]; then | ||
| 19 | die "You need to specify a repository!"; | 60 | die "You need to specify a repository!"; |
| 20 | fi | 61 | fi |
| 62 | |||
| 63 | # everything should belong the calling user | ||
| 64 | chown -R $USER:$PROJECT_GROUP "$REPO" || die "chown failed" | ||
| 21 | 65 | ||
| 22 | chown -R $USER:litmus "$REPO" || die "chown failed" | ||
| 23 | chmod -R g+s "$REPO" || die "chmod -R g+s failed" | ||
| 24 | chmod -R o-rwx "$REPO" || die "chmod -R o-rwx failed" | ||
| 25 | setfacl -R -m g::rwx "$REPO" || die "setfacl failed" | ||
| 26 | setfacl -d -R -m g::rwx "$REPO" || die "setfacl -d failed" | ||
| 27 | 66 | ||
| 67 | # setup group rights | ||
| 68 | find "$REPO" -type d -exec chmod g+s '{}' ';' || die "could not make directories sticky" | ||
| 69 | # owning group | ||
| 70 | setfacl -R -m g::rwx "$REPO" || die "setfacl failed" | ||
| 71 | # owning group, default entry | ||
| 72 | setfacl -d -R -m g::rwx "$REPO" || die "setfacl -d failed" | ||
| 28 | 73 | ||
| 29 | if [ -z "$QUIET" ] | 74 | if [ -n "$PUBLIC" ] |
| 30 | then | 75 | then |
| 76 | # give access to others | ||
| 77 | find "$REPO" -type d -exec chmod g+rx '{}' ';' || die "could not make directories acessible" | ||
| 78 | find "$REPO" -type f -exec chmod g+r '{}' ';' || die "could not make files acessible" | ||
| 79 | # others, default entry | ||
| 80 | setfacl -d -R -m o::rx "$REPO" || die "setfacl -d failed" | ||
| 81 | else | ||
| 82 | # remove access | ||
| 83 | chmod -R o-rwx "$REPO" || die "chmod -R o-rwx failed" | ||
| 84 | fi | ||
| 85 | |||
| 86 | if [ -z "$QUIET" ] | ||
| 87 | then | ||
| 31 | echo "Repository $REPO is ready for use:" | 88 | echo "Repository $REPO is ready for use:" |
| 32 | ls -l "$REPO" | 89 | ls -l "$REPO" |
| 33 | getfacl "$REPO" | 90 | getfacl "$REPO" |
| 34 | fi | 91 | fi |
| 92 | } | ||
| 93 | |||
| 94 | while [ ! -z "$1" ] | ||
| 95 | do | ||
| 96 | set_rights "$1" | ||
| 97 | shift | ||
| 98 | done | ||
