summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2010-10-22 22:13:33 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2010-10-22 22:13:33 -0400
commit1046db24fcda8c3665fd2c0f70fc05e7dfd89c99 (patch)
tree9eb415d65f7d0147c0cb5d067f4498d3afd16b2c
parentf048d99b46dd763ba00f147c48de6ac8d553e1f9 (diff)
Add --public option to set_repo_rights and provide some help
-rwxr-xr-xset_repo_rights98
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
4function usage()
5{
6 cat <<EOF
7Usage: set_repo_rights [OPTIONS] <REPOSITORY1> <REPOSITORY2> ...
8
9Options:
10 --quiet do not give a report after setting permssions
11 --public give read access rights to others (e.g., the gitweb daemon)
12
13EOF
14}
15
3function die() 16function 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
10if [ "$1" == "--quiet" ] 23QUIET=
11then 24PUBLIC=
12 QUIET=yes 25PROJECT_GROUP=litmus
13 shift 26
14fi 27while true
28do
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
51done
15 52
16REPO=$1
17 53
18if [ -z "$REPO" ]; then 54function 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!";
20fi 61 fi
62
63 # everything should belong the calling user
64 chown -R $USER:$PROJECT_GROUP "$REPO" || die "chown failed"
21 65
22chown -R $USER:litmus "$REPO" || die "chown failed"
23chmod -R g+s "$REPO" || die "chmod -R g+s failed"
24chmod -R o-rwx "$REPO" || die "chmod -R o-rwx failed"
25setfacl -R -m g::rwx "$REPO" || die "setfacl failed"
26setfacl -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
29if [ -z "$QUIET" ] 74 if [ -n "$PUBLIC" ]
30then 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"
34fi 91 fi
92}
93
94while [ ! -z "$1" ]
95do
96 set_rights "$1"
97 shift
98done