Created
July 27, 2012 13:51
-
-
Save jgoodall/3188148 to your computer and use it in GitHub Desktop.
Setup git and configure apache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Define your LDAP URL | |
#LDAP_URL=ldaps... | |
GIT_DIR=/var/lib/git | |
APACHE_CONFIG_FILE=/etc/httpd/conf.d/git.conf | |
if [ `whoami` != "root" ]; then | |
echo "You must run this script as root (sudo $0)" | |
exit 1 | |
fi | |
if [ $# -lt 2 ]; then | |
echo 'You must specifiy the name of the repo to create.' | |
echo 'Specify usernames in quotes separated by spaces.' | |
echo " $0 repository 'user [user user ...]'" | |
exit 1 | |
fi | |
repo=$1 | |
users=$2 | |
repo_path="$GIT_DIR/$repo" | |
if [ -d $repo_path ]; then | |
echo 'Directory $repo_path already exists' | |
exit 1 | |
fi | |
echo "Creating the repo at $repo_path" | |
mkdir $repo_path | |
git init --bare $repo_path | |
echo "Changing permissions for apache" | |
chown -R apache:apache $repo_path | |
chmod -R g+rwX,o-rwx $repo_path | |
APACHE_CONFIG=" | |
\nScriptAlias /git/$repo /usr/libexec/git-core/git-http-backend/ | |
\n<Location /git/$repo> | |
\n SSLRequireSSL | |
\n AuthType Basic | |
\n AuthName \"$repo Git Repository\" | |
\n AuthBasicProvider ldap | |
\n AuthLDAPURL $LDAP_URL | |
\n AuthLDAPGroupAttribute memberUid | |
\n AuthLDAPGroupAttributeIsDN off | |
\n Require user $users | |
\n</Location> | |
\n" | |
echo "Configuring apache config file at $APACHE_CONFIG_FILE:" | |
echo -e "$APACHE_CONFIG" | |
echo -e $APACHE_CONFIG >> $APACHE_CONFIG_FILE | |
/sbin/service httpd restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment