Skip to content

Instantly share code, notes, and snippets.

@CaporalDead
Created September 8, 2013 02:29
Show Gist options
  • Save CaporalDead/6481373 to your computer and use it in GitHub Desktop.
Save CaporalDead/6481373 to your computer and use it in GitHub Desktop.
Création d'un dépôt SVN pour un domaine donné
#!/bin/sh
#/usr/local/bin/create-repo
if [ -z "$1" ]; then
echo "First parameter must be a project name"
exit 1
fi
if [ -z "$2" ]; then
echo "Second parameter must be a common project name"
exit 2
fi
if [ -z "$3" ]; then
echo "Third parameter must be a domain name"
exit 3
fi
PROJECT_NAME=$1
PROJECT_NAME_NICE=$2
DOMAIN_NAME=$3
APACHE_CONF=/data/www/$DOMAIN_NAME/svn/projects/$PROJECT_NAME.svn-project
AUTH_FILE=/data/www/$DOMAIN_NAME/svn/projects/.$PROJECT_NAME.passwd
DIRECTORY=/data/www/$DOMAIN_NAME/svn/$PROJECT_NAME
if [ -d "$DIRECTORY" ]; then
echo "This project already exists at $DIRECTORY"
exit 4
fi
svnadmin create $DIRECTORY
cat <<EOF > $APACHE_CONF
<Location /$PROJECT_NAME>
DAV svn
SVNPath $DIRECTORY
AuthType Basic
AuthName "Devitek - $PROJECT_NAME_NICE"
AuthUserFile $AUTH_FILE
Require valid-user
</Location>
EOF
echo "" > $AUTH_FILE
chown -R www-data:www-data $DIRECTORY
echo ""
echo "You have to add some users to $AUTH_FILE"
echo "Your project will be ready after restarting apache"
echo ""
echo "Adding first user : htpasswd -m -c $AUTH_FILE test1"
echo "Adding more user : htpasswd -m $AUTH_FILE test2"
echo ""
echo "Now you have to restart your Apache server..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment