diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-02-02 23:59:06 -0500 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-02-02 23:59:06 -0500 |
commit | a138d86703096bfbf2949b6591d95e456c018a14 (patch) | |
tree | d16b1540026f9d92d90129246d2890c0aa365f36 | |
parent | 782b26e8073d84b3beff2a02d088f4a5e10b1260 (diff) |
Add make-shared-repo and server-side ACL mangler.
Convenient tool to move repositories to the shared spaced on CVS.
-rwxr-xr-x | make-shared-repo | 87 | ||||
-rwxr-xr-x | set_repo_rights | 33 |
2 files changed, 120 insertions, 0 deletions
diff --git a/make-shared-repo b/make-shared-repo new file mode 100755 index 0000000..13fd039 --- /dev/null +++ b/make-shared-repo | |||
@@ -0,0 +1,87 @@ | |||
1 | #!/bin/bash | ||
2 | # Shell script to create new repositories on a remote server. | ||
3 | # | ||
4 | # (c) 2010, B. Brandenburg. | ||
5 | |||
6 | REPO=`basename "$1"` | ||
7 | |||
8 | ### configuration section ### | ||
9 | |||
10 | # where to copy it to | ||
11 | REMOTE_PATH="/cvs/proj/litmus/repo/${REPO}.git" | ||
12 | SERVER="cvs.cs.unc.edu" | ||
13 | |||
14 | # command to execute after repository creation | ||
15 | CHMOD="/cvs/proj/litmus/sw/bin/set_repo_rights --quiet" | ||
16 | |||
17 | ### end of configuration ### | ||
18 | |||
19 | |||
20 | # implementation from here on dow | ||
21 | CONFIG="$1/.git/config" | ||
22 | BARE="/tmp/${REPO}.git" | ||
23 | TARGET="$SERVER:$REMOTE_PATH" | ||
24 | |||
25 | function die { | ||
26 | echo "(EE) $*" | ||
27 | exit 1 | ||
28 | } | ||
29 | |||
30 | function info { | ||
31 | echo "(II) $*" | ||
32 | } | ||
33 | |||
34 | function warn { | ||
35 | echo "(WW) $*" | ||
36 | } | ||
37 | |||
38 | if [ -z "$1" ] | ||
39 | then | ||
40 | die "Argument missing. Usage: '$0 /path/to/git/repo'." | ||
41 | fi | ||
42 | |||
43 | info "Creating shared repository for $REPO on $SERVER at $REMOTE_PATH." | ||
44 | |||
45 | info "Checking whether ${TARGET} exists." | ||
46 | ssh "$SERVER" test -e "$REMOTE_PATH" && die "Remote path exists already." | ||
47 | |||
48 | if [ -e "$BARE" ] | ||
49 | then | ||
50 | warn "$BARE exists. Moving it out of the way." | ||
51 | warn "Faking" rm -rf "$BARE" | ||
52 | die "Not yet implemented..." | ||
53 | fi | ||
54 | |||
55 | info "Cloning repository ${REPO} to ${BARE}." | ||
56 | git clone --bare "$1" "$BARE" || die "git clone failed." | ||
57 | |||
58 | info "Copying to ${TARGET}." | ||
59 | scp -rpq "$BARE" "$TARGET" || die "scp failed." | ||
60 | |||
61 | if [ ! -z "$CHMOD" ] | ||
62 | then | ||
63 | info "Setting up permissions." | ||
64 | ssh "$SERVER" "$CHMOD" "$REMOTE_PATH" || die "$CHMOD failed" | ||
65 | fi | ||
66 | |||
67 | info "Cleaning up." | ||
68 | rm -rf "$BARE" || die "rm failed." | ||
69 | |||
70 | info "Appending origin setup to $CONFIG" | ||
71 | cat >> "$CONFIG" <<EOF | ||
72 | |||
73 | # config added by $0 | ||
74 | [remote "origin"] | ||
75 | url = ${TARGET} | ||
76 | fetch = +refs/heads/*:refs/remotes/origin/* | ||
77 | [branch "master"] | ||
78 | remote = origin | ||
79 | merge = refs/heads/master | ||
80 | EOF | ||
81 | |||
82 | echo "****************************" | ||
83 | info "Your new remote repository is at: $TARGET" | ||
84 | info "Enjoy!" | ||
85 | echo | ||
86 | |||
87 | |||
diff --git a/set_repo_rights b/set_repo_rights new file mode 100755 index 0000000..65940db --- /dev/null +++ b/set_repo_rights | |||
@@ -0,0 +1,33 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | function die() | ||
4 | { | ||
5 | echo "Error: $1" | ||
6 | echo "Usage: $0 <REPOSITORY>" | ||
7 | exit 1 | ||
8 | } | ||
9 | |||
10 | if [ "$1" == "--quiet" ] | ||
11 | then | ||
12 | QUIET=yes | ||
13 | shift | ||
14 | fi | ||
15 | |||
16 | REPO=$1 | ||
17 | |||
18 | if [ -z "$REPO" ]; then | ||
19 | die "You need to specify a repository!"; | ||
20 | fi | ||
21 | |||
22 | chown -R $USER:litmus "$REPO" || die "chown failed" | ||
23 | chmod -R o-rwx "$REPO" || die "chmod failed" | ||
24 | setfacl -R -m g::rwx "$REPO" || die "setfacl failed" | ||
25 | setfacl -d -R -m g::rwx "$REPO" || die "setfacl -d failed" | ||
26 | |||
27 | |||
28 | if [ -z "$QUIET" ] | ||
29 | then | ||
30 | echo "Repository $REPO is ready for use:" | ||
31 | ls -l "$REPO" | ||
32 | getfacl "$REPO" | ||
33 | fi | ||