#!/bin/sh # Switch between OS-packaged Subversion and custom-built Subversion. # # Usage: 'switch-svn ' ("c" for custom, "p" for packaged) DIRECTION="${1}" # Use $USER instead of $UID because the latter doesn't always get set # in a sudo-created shell, apparently. if [ "${USER}" != "root" ]; then echo "ERROR: you must be root to run this" >&2 exit 1 fi if [ "${DIRECTION}" = "" ]; then echo "ERROR: missing required argument ('p')ackage or ('c')ustom" >&2 exit 1 fi if [ "${DIRECTION}" = "p" ]; then cd /usr/local/lib if [ -e libsvn_wc-1.so ]; then if [ -d svn-switch-locker ]; then mv svn-switch-locker TMP-SAFE-svn-switch-locker fi mkdir svn-switch-locker mv libsvn* svn-switch-locker/ if [ -d TMP-SAFE-svn-switch-locker ]; then rm -rf TMP-SAFE-svn-switch-locker fi else echo "ERROR: no custom SVN libraries are present to move out of the way" \ >&2 exit 1 fi cd /usr/local/bin if [ -e svn ]; then if [ -d svn-switch-locker ]; then mv svn-switch-locker TMP-SAFE-svn-switch-locker fi mkdir svn-switch-locker for name in svn svnadmin svnbench svndumpfilter \ svnfsfs svnlook svnmucc svnrdump \ svnserve svnsync svnversion \ ; do mv ${name} svn-switch-locker/ done if [ -d TMP-SAFE-svn-switch-locker ]; then rm -rf TMP-SAFE-svn-switch-locker fi else echo "ERROR: no custom SVN binaries are present to move out of the way" \ >&2 exit 1 fi elif [ "${DIRECTION}" = "c" ]; then cd /usr/local/lib if [ -d svn-switch-locker ]; then mv svn-switch-locker/* . rmdir svn-switch-locker else echo "ERROR: no custom SVN libraries are preserved to move back" \ >&2 exit 1 fi cd /usr/local/bin if [ -d svn-switch-locker ]; then mv svn-switch-locker/* . rmdir svn-switch-locker else echo "ERROR: no custom SVN binaries are preserved to move back" \ >&2 exit 1 fi else echo "ERROR: argument '${DIRECTION}' is neither ('p')ackage nor ('c')ustom" \ >&2 exit 1 fi