source: branches/fc15-dev/locker/deploy/bin/git @ 2364

Last change on this file since 2364 was 1938, checked in by achernya, 13 years ago
Merge r1878-r1937 from trunk to branches/fc15-dev
  • Property svn:executable set to *
File size: 2.1 KB
Line 
1#!/usr/bin/perl
2use strict;
3use FindBin qw($Bin);
4use lib $Bin;
5use onserver;
6
7setup();
8
9my $gitbase = "$scriptsdir/git";
10my $htpasswd = "$gitbase/$addrend.git/.htpasswd";
11
12open HTACCESS, ">.htaccess";
13print HTACCESS <<EOF;
14RewriteEngine On
15
16RewriteCond %{QUERY_STRING} =service=git-receive-pack [OR]
17RewriteCond %{REQUEST_URI} /git-receive-pack\$
18RewriteRule ^($addrend\\.git/.*)\$ /~$USER/$addrend/_git-auth.cgi/\$1
19<Files _git-auth.cgi>
20    AuthName "Git Access"
21    AuthType basic
22    AuthUserFile $htpasswd
23    Require user $admin_username
24
25    # Alternatively, replace "require user" with:
26    #Require group somegroup
27    #AuthGroupFile $gitbase/$addrend/.htgroup
28    # and set up .htgroup appropriately
29</Files>
30
31RewriteRule ^($addrend\\.git/.*)\$ /~$USER/$addrend/_git.cgi/\$1
32EOF
33close HTACCESS;
34chmod 0777, ".htaccess";
35
36open GIT_CGI, ">_git.cgi";
37print GIT_CGI <<EOF;
38#!/bin/sh
39case "\$PATH_INFO" in
40    .. | ../* | */.. | */../*)
41        echo "Content-type: text/plain"
42        echo "Status: 403 Forbidden"
43        echo ""
44        echo "Error: Illegally found '..' in PATH_INFO='\$PATH_INFO'"
45        echo "gitautoinstaller: \$HOME: found '..' in PATH_INFO='\$PATH_INFO'" >&2
46        exit 1;;
47    /$addrend.git/*)
48        # pass
49        ;;
50    *)
51        echo "Content-type: text/plain"
52        echo "Status: 403 Forbidden"
53        echo ""
54        echo "Error: PATH_INFO='\$PATH_INFO' must start with /$addrend.git/"
55        echo "gitautoinstaller: \$HOME: found bad start in PATH_INFO='\$PATH_INFO'" >&2
56        exit 1;;
57esac
58export GIT_PROJECT_ROOT="$gitbase"
59export PATH_TRANSLATED="\$GIT_PROJECT_ROOT\$PATH_INFO"
60exec git http-backend
61EOF
62close GIT_CGI;
63chmod 0755, "_git.cgi";
64symlink "_git.cgi","_git-auth.cgi";
65
66chdir $gitbase;
67system qw{git init --bare}, "$addrend.git";
68chdir "$addrend.git";
69
70open ENABLE, ">git-daemon-export-ok";
71print ENABLE "";
72close ENABLE;
73
74system qw{htpasswd -c}, $htpasswd, $admin_username;
75
76print "Your git repository is located in:\n";
77print "  $gitbase/$addrend.git/\n";
78print "To clone, run\n  git clone https://$USER.scripts.mit.edu/$addrend/$addrend.git\n\n";
79press_enter;
80
81exit 0;
Note: See TracBrowser for help on using the repository browser.