#!/usr/pkg/bin/bash # svnimport - automate the subversion import process # copyright and GPL 2004 jc@jcomeau.com die() { echo "$@" >&2 exit 1 } svndir=/var/www/svn # make sure it's correct on remote server apacheuser=www-data # it might be "nobody" on your server [ -z "$ROOTSSHPORT" ] && die "Must specify ssh port as ROOTSSHPORT" server=$1 package=$2 [ -z "$2" ] && die "Usage: $0 SERVER PACKAGE" package=$(basename $package) rm -rf /tmp/svntemp.$$ mkdir -p /tmp/svntemp.$$/{branches,tags,trunk} (cd $package && tar cf - \ --exclude "*/.svn*" --exclude "*/RCS*" .) | \ (cd /tmp/svntemp.$$/trunk && tar xvf -) ssh -p $ROOTSSHPORT root@$server \ "su $apacheuser -c 'cd $svndir && svnadmin create $package'" (cd /tmp/svntemp.$$ && \ svn import http://$server/svn/$package -m "initial import") # now make this the working directory rm -rf /tmp/$package.tmp.$$ mv $package /tmp/$package.tmp.$$ svn checkout http://$server/svn/$package/trunk $package