Commits

Yuji Hanamura committed e5d52ee

Add script.

  • Participants
  • Parent commits be0bf3f

Comments (0)

Files changed (1)

File syncsvnrepo.sh

+#!/bin/bash
+
+# $1 NewRepoPath
+# $2 RemoteRepo
+
+SVN_BIN_DIR=/usr/local/svn/bin
+
+function usage {
+  echo "Usage: $0 NEW_REPO_PATH REMOTE_REPO"
+}
+
+if [ $# -lt 2 ]; then
+  echo 'ERROR: too few arguments.'
+  usage
+  exit 1
+fi
+
+if [ -e $1 ]; then
+  if [ -d $1 ]; then
+    # empty check
+    if [ ! -z "$(ls -A $1)" ]; then
+      echo "$1 is not empty."
+      exit 1
+    fi
+  else
+    echo "$1 is file."
+    exit 1
+  fi
+else
+  mkdir $1
+  if [ $? -ne 0 ]; then
+    echo "$1 could not be created."
+    exit 1
+  fi
+fi
+NEW_REPO_DIR=$(cd $1 && pwd)
+NEW_REPO=file:///$NEW_REPO_DIR
+REMOTE_REPO=$2
+
+$SVN_BIN_DIR/svnadmin create $1
+if [ $? -ne 0 ]; then exit 1; fi
+
+echo '#!/bin/sh
+exit 0' > $1/hooks/pre-revprop-change
+if [ $? -ne 0 ]; then exit 1; fi
+
+chmod +x  $1/hooks/pre-revprop-change
+if [ $? -ne 0 ]; then exit 1; fi
+
+$SVN_BIN_DIR/svnsync init $NEW_REPO $REMOTE_REPO 
+if [ $? -ne 0 ]; then exit 1; fi
+
+$SVN_BIN_DIR/svnsync sync $NEW_REPO
+if [ $? -ne 0 ]; then exit 1; fi
+
+exit 0