summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2010-02-02 23:59:06 -0500
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2010-02-02 23:59:06 -0500
commita138d86703096bfbf2949b6591d95e456c018a14 (patch)
treed16b1540026f9d92d90129246d2890c0aa365f36
parent782b26e8073d84b3beff2a02d088f4a5e10b1260 (diff)
Add make-shared-repo and server-side ACL mangler.
Convenient tool to move repositories to the shared spaced on CVS.
-rwxr-xr-xmake-shared-repo87
-rwxr-xr-xset_repo_rights33
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
6REPO=`basename "$1"`
7
8### configuration section ###
9
10# where to copy it to
11REMOTE_PATH="/cvs/proj/litmus/repo/${REPO}.git"
12SERVER="cvs.cs.unc.edu"
13
14# command to execute after repository creation
15CHMOD="/cvs/proj/litmus/sw/bin/set_repo_rights --quiet"
16
17### end of configuration ###
18
19
20# implementation from here on dow
21CONFIG="$1/.git/config"
22BARE="/tmp/${REPO}.git"
23TARGET="$SERVER:$REMOTE_PATH"
24
25function die {
26 echo "(EE) $*"
27 exit 1
28}
29
30function info {
31 echo "(II) $*"
32}
33
34function warn {
35 echo "(WW) $*"
36}
37
38if [ -z "$1" ]
39then
40 die "Argument missing. Usage: '$0 /path/to/git/repo'."
41fi
42
43info "Creating shared repository for $REPO on $SERVER at $REMOTE_PATH."
44
45info "Checking whether ${TARGET} exists."
46ssh "$SERVER" test -e "$REMOTE_PATH" && die "Remote path exists already."
47
48if [ -e "$BARE" ]
49then
50 warn "$BARE exists. Moving it out of the way."
51 warn "Faking" rm -rf "$BARE"
52 die "Not yet implemented..."
53fi
54
55info "Cloning repository ${REPO} to ${BARE}."
56git clone --bare "$1" "$BARE" || die "git clone failed."
57
58info "Copying to ${TARGET}."
59scp -rpq "$BARE" "$TARGET" || die "scp failed."
60
61if [ ! -z "$CHMOD" ]
62then
63 info "Setting up permissions."
64 ssh "$SERVER" "$CHMOD" "$REMOTE_PATH" || die "$CHMOD failed"
65fi
66
67info "Cleaning up."
68rm -rf "$BARE" || die "rm failed."
69
70info "Appending origin setup to $CONFIG"
71cat >> "$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
80EOF
81
82echo "****************************"
83info "Your new remote repository is at: $TARGET"
84info "Enjoy!"
85echo
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
3function die()
4{
5 echo "Error: $1"
6 echo "Usage: $0 <REPOSITORY>"
7 exit 1
8}
9
10if [ "$1" == "--quiet" ]
11then
12 QUIET=yes
13 shift
14fi
15
16REPO=$1
17
18if [ -z "$REPO" ]; then
19 die "You need to specify a repository!";
20fi
21
22chown -R $USER:litmus "$REPO" || die "chown failed"
23chmod -R o-rwx "$REPO" || die "chmod failed"
24setfacl -R -m g::rwx "$REPO" || die "setfacl failed"
25setfacl -d -R -m g::rwx "$REPO" || die "setfacl -d failed"
26
27
28if [ -z "$QUIET" ]
29then
30 echo "Repository $REPO is ready for use:"
31 ls -l "$REPO"
32 getfacl "$REPO"
33fi